Course Content
Modular Monolith Architecture in .NET

We work on one application for the whole course. It is called Fieldwork, and it runs the back office of a company whose technicians install and repair heating and cooling systems at customer sites.

The company’s customers have one or more sites. Some of them pay for a service plan that covers their visits. The company has four technicians. Each one has a few skills, such as gas or cooling, and shifts during the week.

When a customer reports a fault, the office raises a job and books a technician for it, as an appointment. Parts sit in a warehouse and on each technician’s van. When the work is done, the technician completes the job, and the office sends the invoice.

Fieldwork does nothing more. It builds in seconds and runs without Docker. Its connection string is already in appsettings.json, and it listens on plain HTTP, so you need no development certificate either.

The Solution and Its Projects

Let’s open Fieldwork.sln, which sits beside global.json. It holds our two projects:

  • Fieldwork.Web is the whole application, one ASP.NET Core web API (application programming interface) project. It has seven controllers, 14 entity classes and three services, one of which recounts the stock every six hours. The Entity Framework Core context and the seed data are in its Data folder. The database is a SQLite file, through the Microsoft.EntityFrameworkCore.Sqlite package.
  • Fieldwork.BoundaryTests is an xUnit test project. It holds a helper we use in module 1 to count the references between parts of the code, and the three tests that check the helper.

The Controllers and Their Routes

Every endpoint we call lives in one of the seven controllers, and each controller has its own route. Here they are, with what the business uses each one for:

ControllerRouteWhat the business uses it for
CustomersControllerapi/customersCustomer accounts with their sites and service plans, and opening and closing an account
SchedulingControllerapi/schedulingThe technicians, each technician's day, and booking, moving and cancelling appointments
JobsControllerapi/jobsRaising, starting, completing and cancelling jobs, and the work history of a site
PartsControllerapi/partsThe parts catalogue, the warehouse count, the stock on each van, and parts held for a job
BillingControllerapi/billingInvoices, a preview of the invoice for a job, and finished work with no invoice yet
DashboardControllerapi/dashboardThe operations dashboard for one week
MobileControllerapi/mobileThe technicians' phone app: today's visits, taking a job, completing it, and checking a part before promising it

MobileController serves the phone app the technicians carry, and the other six serve the office. We send requests to several of them in module 1.

The Seed Data

The first time we run Fieldwork, it creates the database, fieldwork.db, beside Fieldwork.Web.csproj. It then fills the database with one week of work, from Monday 7 September to Friday 11 September 2026.

Our seed week has four technicians, Mia Kovac, Marko Baric, Petra Vidak and Luka Horvat, and 11 customers with 42 jobs between them. Their sites, service plans, shifts and parts are in the seed too.

Every identifier in the seed is fixed, so every request in Fieldwork.http works on your machine the way it worked on ours.

Running the Application

Let’s run Fieldwork once, so you have seen it work. Open a terminal in your module-01/Fieldwork folder and start it with dotnet run --project Fieldwork.Web. It builds Fieldwork.Web, seeds the database and starts to listen. Our terminal printed:

Using launch settings from Fieldwork.Web\Properties\launchSettings.json...
Building...
info: Fieldwork.Web[0]
      Fieldwork database ready with 11 customers and 42 jobs.
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\course\module-01\Fieldwork\Fieldwork.Web

The highlighted line is the address Fieldwork listens on. The starter sets it twice, to the same value. One copy is in Properties/launchSettings.json, the launch profile that dotnet run reads. The other is the Urls setting in appsettings.json, the file that holds the connection string. Fieldwork keeps running until you press Ctrl+C.

On a Mac, a system service called AirPlay Receiver can hold port 5000. If the run stops because the address is already in use, or a request in the next section answers 403, turn off AirPlay Receiver under System Settings, General, AirDrop and Handoff. Then start Fieldwork again.

Sending Requests to Fieldwork

Leave it running and open a second terminal in the same folder. Now let’s ask Fieldwork for its four technicians and their skills. Pick the tab for your system:

Invoke-RestMethod http://localhost:5000/api/scheduling/technicians |
    Format-Table fullName, skills, active -AutoSize
curl -s http://localhost:5000/api/scheduling/technicians

The answer comes back as JSON (JavaScript Object Notation), and PowerShell shows it as a table:

fullName    skills                  active
--------    ------                  ------
Luka Horvat {Gas, Cooling}            True
Marko Baric {Cooling, Electrical}     True
Mia Kovac   {Gas, Heating, Cooling}   True
Petra Vidak {Heating, Electrical}     True

Mia Kovac carries three skills and the other technicians two each, and all four are active. On our machine, the curl command printed the same four technicians as one line of JSON, with each one’s identifier as well.

If you send requests from your editor, the same request is entry 18 in Fieldwork.Web/Fieldwork.http:

### 18. The four technicians and the skills each one carries.
GET {{host}}/api/scheduling/technicians

The @host variable on the first line of the file holds http://localhost:5000, so the request reaches the application we started. When you are done, press Ctrl+C in the first terminal to stop it.

Fieldwork seeds only an empty database, so a restart keeps every change your requests made. To get the clean seed week back, stop the application, delete every file whose name starts with fieldwork.db, and run it again.

Known Problems in the Code

Fieldwork is not perfect, and that is deliberate. We left these problems in it so that later modules have something real for us to fix:

  • A technician can be booked into the same hour twice.
  • The technicians’ phone app can book a technician outside every shift they have.
  • Completing the same job twice takes its parts off the van twice, and the van stock goes below zero.
  • The job screen can say a visit is covered by the service plan while its invoice charges for the work.
  • Completing a job sends the customer’s message inside the same request, and the request waits for it.
  • No test checks what Fieldwork does.

We do not fix any of that now. Each problem has a module waiting for it, and we tell you when we get there. In module 1, we make the first ones happen with requests from Fieldwork.http.

Until then, don’t send the POST requests in that file. All ten of them change the seed data, and module 1 sends the first of them.

In the next lesson, we go through the modules of the course and every kind of snippet its lessons use.

0% Complete