Introduction
This lesson establishes the real project that will be used throughout the course. Our goal is to build an ASP.NET Core Web API for managing products and the categories to which those products belong. In later lessons, the application will use Entity Framework Core and SQL Server, then it will be packaged into a Docker image and run together with SQL Server in a containerized environment.
We will not configure database access or create a Dockerfile yet. Instead, we will create a consistent solution structure, verify the required tools, and define the folders, naming conventions, and endpoint contracts that will remain stable throughout the course. This preparation matters because many container problems are caused by inconsistent project names, unclear build contexts, or an unverified local development environment.
By the end of this lesson, you will have a working layered product-category API project that is ready for Docker integration.
1. Defining the project scope and naming
The application will be named Catalog.Api. The name communicates that the application exposes an API for catalog management. We will use the following projects in the same solution:
- Catalog.Api: HTTP endpoints, controllers, and the application entry point.
- Catalog.Application: use cases, application services, and business orchestration.
- Catalog.Domain: core business entities such as Product and Category.
- Catalog.Infrastructure: Entity Framework Core, SQL Server, and other technical integrations.
This is not the only valid architecture. However, separating the API, application rules, domain model, and infrastructure makes the project easier to test, containerize, and deploy. Using the same root name for projects and namespaces also reduces reference mistakes and makes the solution easier to navigate.
2. Verifying the development tools
Docker Desktop
Docker Desktop provides Docker Engine, the Docker CLI, and Docker Compose for local development. If you are using Windows, this course assumes that Docker Desktop is running in Linux container mode. The ASP.NET Core and SQL Server images used in this course are Linux-based, so remaining in Windows container mode can cause compatibility problems.
Start Docker Desktop and run these commands in a terminal:
docker version docker compose version docker info
docker version should show both client and server information. If the Docker Engine is not running, the CLI may be installed but containers still cannot start. docker compose version confirms that the Compose plugin is available. docker info displays detailed engine information; review the output and confirm that the engine is running in Linux container mode.
On Windows, if the Docker Desktop menu shows Switch to Linux containers, Docker may currently be using Windows containers. Select that option to switch modes. On supported Docker Desktop versions, you can also use the following command:
docker desktop engine use linux
If Docker Desktop does not start, check hardware virtualization in BIOS or UEFI and review the WSL 2 or Hyper-V configuration used by Docker Desktop. Operating-system requirements change over time, so use the official installation documentation when resolving installation-specific issues.
.NET SDK
This course targets .NET 10. Installing only the ASP.NET Core Runtime is not enough because project creation, compilation, and local execution require the .NET SDK. Run the following commands:
dotnet --info dotnet --list-sdks dotnet --list-runtimes
You should see an SDK with a 10.x version. Multiple SDKs may be installed on the same machine. If that is the case, we can add a global.json file in a later lesson to select a specific SDK for the repository. If no SDK is listed, install the .NET 10 SDK for your operating system and open a new terminal.
SQL Server
In this course, SQL Server will run in a Docker container rather than being installed directly on the host operating system. Having SQL Server Management Studio, Azure Data Studio, or another SQL client can still be useful for inspecting databases and running queries. We will not start the SQL Server container in this lesson; verifying Docker is sufficient for now.
3. Creating the solution and project folders
Create a workspace directory first. The following commands work in PowerShell, Windows Terminal, Bash, and macOS or Linux terminals:
mkdir CatalogWorkspace cd CatalogWorkspace dotnet new sln -n Catalog
Create the four projects:
dotnet new webapi --use-controllers -f net10.0 -n Catalog.Api -o src/Catalog.Api dotnet new classlib -f net10.0 -n Catalog.Application -o src/Catalog.Application dotnet new classlib -f net10.0 -n Catalog.Domain -o src/Catalog.Domain dotnet new classlib -f net10.0 -n Catalog.Infrastructure -o src/Catalog.Infrastructure
The --use-controllers option is important. Depending on the SDK template defaults, creating a Web API without this option may produce a Minimal API project. This course uses controllers and a layered structure. The -f net10.0 option explicitly selects the target framework, while -o determines the output directory.
Add the projects to the solution:
dotnet sln Catalog.sln add src/Catalog.Api/Catalog.Api.csproj dotnet sln Catalog.sln add src/Catalog.Application/Catalog.Application.csproj dotnet sln Catalog.sln add src/Catalog.Domain/Catalog.Domain.csproj dotnet sln Catalog.sln add src/Catalog.Infrastructure/Catalog.Infrastructure.csproj
Now add the initial project references. The API will use the application and infrastructure layers. Infrastructure will reference Domain and Application, while Application will reference Domain:
dotnet add src/Catalog.Application/Catalog.Application.csproj reference src/Catalog.Domain/Catalog.Domain.csproj dotnet add src/Catalog.Infrastructure/Catalog.Infrastructure.csproj reference src/Catalog.Domain/Catalog.Domain.csproj dotnet add src/Catalog.Infrastructure/Catalog.Infrastructure.csproj reference src/Catalog.Application/Catalog.Application.csproj dotnet add src/Catalog.Api/Catalog.Api.csproj reference src/Catalog.Application/Catalog.Application.csproj dotnet add src/Catalog.Api/Catalog.Api.csproj reference src/Catalog.Infrastructure/Catalog.Infrastructure.csproj
The intended dependency direction is straightforward. The domain layer stays independent of SQL Server and ASP.NET Core. The API acts as the composition root, where the application and infrastructure implementations will eventually be registered with dependency injection. This separation will be useful when the application is built inside a Docker image.
4. Creating the domain models
Inside src/Catalog.Domain, create an Entities folder. Add Category.cs and Product.cs:
namespace Catalog.Domain.Entities; public sealed class Category { public int Id { get; set; } public string Name { get; set; } = string.Empty; public ICollection<Product> Products { get; set; } = new List<Product>(); } public sealed class Product { public int Id { get; set; } public string Name { get; set; } = string.Empty; public decimal Price { get; set; } public int CategoryId { get; set; } public Category? Category { get; set; } }
This simple model expresses a one-to-many relationship: one category can contain many products, while each product can be associated with a category. Database constraints and migration configuration will be introduced later. At this stage, the purpose is to replace template sample data with the actual business domain of the course.
5. Defining the initial endpoint contract
Before connecting to a database, it is useful to decide which HTTP resources the API will expose. The initial contract is:
| HTTP method | Address | Purpose |
|---|---|---|
| GET | /api/categories | List categories |
| GET | /api/categories/{id} | Get one category |
| POST | /api/categories | Create a category |
| GET | /api/products | List products |
| GET | /api/products/{id} | Get one product |
| POST | /api/products | Create a product |
Plural resource names represent collections, and the ID in the URL identifies one resource. When a product is created, the request will contain a category ID rather than an entire category object. Later, request and response DTOs will make this boundary explicit and prevent persistence entities from becoming an accidental public API contract.
6. Building and running the API
Restore dependencies and build the solution:
dotnet restore dotnet build
The Web API template creates sample WeatherForecast files. We will not use them, so remove the sample controller and model files from Catalog.Api. Then run the API:
dotnet run --project src/Catalog.Api
The terminal will display HTTP and HTTPS addresses. The ports may differ on your machine, so do not assume a fixed port. If OpenAPI or Swagger support is enabled in the template, use the address shown by the application to inspect the generated API documentation. A 404 response at the root address is expected if no root endpoint has been defined; it does not mean that the application failed to start.
HTTPS certificates will be discussed separately when we containerize the application. For the first container tests, using HTTP is simpler because development certificates require additional trust configuration on the host and inside containers.
7. Recommended folder structure
At this point, the workspace should look similar to this:
CatalogWorkspace/ ├── Catalog.sln ├── src/ │ ├── Catalog.Api/ │ │ ├── Controllers/ │ │ ├── Program.cs │ │ └── Catalog.Api.csproj │ ├── Catalog.Application/ │ │ └── Catalog.Application.csproj │ ├── Catalog.Domain/ │ │ ├── Entities/ │ │ │ ├── Category.cs │ │ │ └── Product.cs │ │ └── Catalog.Domain.csproj │ └── Catalog.Infrastructure/ │ └── Catalog.Infrastructure.csproj └── tests/
Later lessons will add test projects, a Dockerfile, a Compose file, environment configuration, and migration files. Keeping each concern in its intended location makes the Docker build context, local development workflow, and future CI/CD pipeline easier to understand.
Common mistakes
- Using the wrong container mode: On Windows, leaving Docker Desktop in Windows container mode can prevent Linux-based images from behaving as expected.
- Installing only the runtime: The runtime cannot replace the SDK for commands such as dotnet new and dotnet build.
- Forgetting the solution file: Creating project folders without adding them to the solution produces an incomplete view in the IDE and build pipeline.
- Targeting the wrong framework: Using net9.0 or an older target can produce different template behavior from the .NET 10 commands in this course.
- Assuming a fixed port: ASP.NET Core development profiles can use different ports. Always read the terminal output.
- Confusing an image with a container: An image is a reusable package or template; a container is a running instance created from an image. We will examine this distinction in the next lesson.
Practice exercise
- Create the CatalogWorkspace directory and generate the four projects targeting .NET 10.
- Add every project to the solution and verify the project references.
- Add the Category and Product classes.
- Run dotnet restore, dotnet build, and dotnet run --project src/Catalog.Api.
- Run docker version, docker compose version, and docker info.
- Write down the product and category fields you expect to need. For example, decide whether a product needs a stock code or whether a category needs a description.
Use this checklist to verify your result: Docker Engine is running, Linux container mode is active, the .NET 10 SDK appears in the SDK list, the solution builds successfully, the API starts, and the folder structure clearly separates the layers.
Conclusion
In this lesson, we created the real project for the course and established its architectural boundaries. We generated a controller-based ASP.NET Core Web API with the .NET 10 SDK, added the domain entities, organized the solution and project references, defined the initial endpoint contract, and verified the Docker Desktop development environment.
In the next lesson, we will study images, containers, port publishing, and essential Docker commands. The project names and folder structure created here will be reused by every Dockerfile and Docker Compose example that follows.
Sources
- https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-10.0
- https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-10.0
- https://learn.microsoft.com/en-us/dotnet/core/sdk
- https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-new-sdk-templates
- https://docs.docker.com/desktop/
- https://docs.docker.com/desktop/setup/install/windows-install/
- https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-overview?source=recommendations&view=sql-server-ver16