View on GitHub
Clean Architecture Toolkit for .NET
Clean Architecture Toolkit is a clean, modular architecture foundation for .NET applications.
It embraces SOLID principles and focuses on maintainability, testability, and scalability through clear boundaries and pluggable design.

|   HOME   |   MODULE OVERVIEW   |   DEMO   |

Aspire plan

This plan covers the first Aspire AppHost of the demo.
It is part of Demo.md. The demo plan says what Aspire hosts. This plan says how we build it, in which order.

Contents

The goal

One command starts the whole demo, and the Aspire dashboard shows it.

React, the gateway, Keycloak, the Service Bus and Inventory are not part of this build. See Later.

Decisions

Topic Decision
Names Cat.Demo.AppHost and Cat.Demo.ServiceDefaults, each in its own folder in demo/.
SQL Server Two modes, switched by one AppHost setting: Container and Existing. See How the AppHost works.
First mode to build Existing, because Docker and WSL were not installed on the owner’s machine at the start. Container followed in its own phase.
Standalone start Every service still starts with dotnet run and its own appsettings. The AppHost is a convenience, not a requirement.
Price provider The first version is a plain HttpClient implementation in Orders.Infrastructure. Cat.Api.Client replaces it in the future. See Swapping the price provider.
Service to service calls Orders calls Catalog directly for now, because the gateway does not exist yet.
Contracts Orders keeps its own small model of the price response and does not reference Catalog.Contracts. This is a choice, not a rule: Orders needs only the price, so it stays independent of the rest of the Catalog contract. A later service to service call shares contracts, so the demo shows both. See Sharing contracts.
Aspire version The latest stable Aspire that supports .NET 10. Pin it in Directory.Packages.props when the projects are created.

Starting point

Projects

Follow the demo-structure skill. It also keeps CleanArchitectureToolkit.slnx in sync.

demo/
  Cat.Demo.AppHost/
    Cat.Demo.AppHost/
  Cat.Demo.ServiceDefaults/
    Cat.Demo.ServiceDefaults/

How the AppHost works

SQL Server modes

A setting in the AppHost configuration, Sql:Mode, picks one of two modes.

Mode What happens Needs
Existing The AppHost passes the connection strings catalog and orders from its own configuration to the services. A SQL Server the services can reach, such as the local instance they use today.
Container The AppHost starts a SQL Server container with a data volume, creates the databases catalog and orders and passes their connection strings. Docker.

Start order

Ports

Decided: the AppHost keeps the fixed ports 5101 and 5102, with WithHttpEndpoint(port: ...) and no Aspire proxy. The .http files, the Orders to Catalog address and standalone runs all use the same ports. The dashboard runs on 15101 (OTLP on 19101 and the resource service on 20101), set in the launch profile of the AppHost.

Swapping the price provider

IPriceProvider stays as it is. Only the class behind it changes.

Phase 1: plain HttpClient. This is the version we build now.

Catalog answers IPriceProvider returns
200 An Ok response with the price of each book.
404 A failed response. The step already turns that into PriceUnavailable.
400 or any other status An error response. Orders never trusts a half answer.
Network error or timeout An error response.

In the future: Cat.Api.Client.

Phases

  1. ServiceDefaults. Create the project. Both Api projects call it. Build and run both services standalone to check that nothing broke.
  2. AppHost, Existing mode. (Built. The .http requests pass and the traces show in the dashboard.) Create the AppHost with Catalog and Orders. Both show up in the dashboard with logs, traces and health. Run every request of both .http files against the AppHost.
  3. Price provider. (Built. A POST /orders trace shows the call to Catalog and the GET /catalog/books/prices span.) Add CatalogPriceProvider and its tests. Place an order through the AppHost and check in the dashboard that the Catalog call is part of the trace.
  4. AppHost, Container mode. (Built. A fresh start from an empty volume gives empty orders and seeded books. A restart keeps a placed order.) Needs Docker on the machine. Add the SQL Server container, the data volume and the databases. Check a fresh start from an empty volume and a restart that keeps the data.
  5. Documents. (Built. demo/README.md has the run steps for both modes, the Docker memory notes and the AppHost chapter. The drawing shows the dashboard box as built.) Update demo/README.md with the run steps for both modes and the Docker memory notes. Update Demo.md.

Phases 1 to 3 do not need Docker. Phase 4 does.

Later

These come after the first AppHost build, in the order of the demo plan.

Open questions