A sample e-commerce reference application built with ASP.NET Core (.NET 9) demonstrating a microservices architecture. The solution is fully containerized with Docker Compose and showcases common patterns such as API gateway communication, event-driven messaging, hybrid caching, and structured logging.
+----------------+ +--------------------+ +--------------------+
| | -------> | Catalog API | -------> | |
| Web App | | (Controllers) | | |
| (Razor Pages | +--------------------+ | SQL Server |
| + MVC) | -------> | Orders API | -------> | |
| | | (Minimal APIs) | | |
+----------------+ +--------------------+ +--------------------+
|
| Publish
v
+--------------------+
| RabbitMQ |
+--------------------+
|
| Consume
v
+--------------------+
| Queue Processor |
| (Worker Service) |
+--------------------+
The application is composed of the following services:
| Service | Project | Description |
|---|---|---|
| Web | Ecom.Web |
Customer-facing storefront built with ASP.NET Core MVC and Razor Pages. Communicates with backend APIs via HttpClient with Microsoft resilience (Polly) policies. |
| Catalog API | Ecom.Catalog.Api |
REST API serving product catalog data (products, categories, recommendations). Uses controller-based routing. |
| Orders API | Ecom.Orders.Api |
REST API handling shopping cart and checkout operations. Uses Minimal APIs with endpoint groups. Publishes order events to RabbitMQ. |
| Queue Processor | Ecom.QueueProcessor |
.NET Worker Service (BackgroundService) that consumes order.received messages from RabbitMQ for downstream processing (e.g., fulfillment, email notifications). |
| Project | Purpose |
|---|---|
Ecom.Core |
Domain entities, caching abstractions (HybridCache + Redis), event publishing infrastructure, and custom middleware. |
Ecom.Data |
Entity Framework Core DbContext, generic repository pattern, and database migrations. |
| Category | Technology |
|---|---|
| Framework | .NET 9 / C# |
| Web UI | ASP.NET Core MVC + Razor Pages |
| APIs | ASP.NET Core Web API (Controllers & Minimal APIs) |
| Database | SQL Server 2022 |
| ORM | Entity Framework Core + Dapper |
| Messaging | RabbitMQ |
| Caching | Redis + HybridCache |
| Resilience | Microsoft.Extensions.Http.Resilience (Polly) |
| Logging | Serilog -> Seq |
| Containers | Docker & Docker Compose |
- .NET 9 SDK
- Docker Desktop (for containerized run)
Run all services with a single command from the repository root (where the .sln file is located):
docker-compose build
docker-compose upOpen the solution in Visual Studio and press F5. The docker-compose project is configured as the startup project.
Once the containers are running, the following endpoints are available:
| Service | URL |
|---|---|
| Web App | https://localhost:5201 |
| Catalog API (Swagger) | http://localhost:5011/swagger/index.html |
| Orders API (Swagger) | http://localhost:5012/swagger/index.html |
| RabbitMQ Management | http://localhost:8088 (guest / guest) |
| Seq (Structured Logs) | http://localhost:5342 |
- Microservice Communication -- The Web app calls backend APIs through typed
HttpClientinstances registered withIHttpClientFactory. - Resilience -- All outbound HTTP calls use
AddStandardResilienceHandler()(retry, circuit breaker, timeout) powered by Polly viaMicrosoft.Extensions.Http.Resilience. - Event-Driven Messaging -- When an order is placed, the Orders API publishes an
order.receivedmessage to RabbitMQ. The Queue Processor worker service consumes these messages asynchronously. - Hybrid Caching -- The Catalog API and Web app leverage
HybridCache(in-memory + Redis L2) for scalable, tag-based cache invalidation. - Health Checks -- Each API exposes a
/healthendpoint; Docker Compose uses these for container health monitoring. - Structured Logging -- All services ship structured logs to Seq via Serilog, enriched with request host and user-agent metadata.
- Global Exception Handling -- A custom
CustomExceptionHandlingMiddlewareprovides consistent error responses across APIs. - Repository Pattern -- A generic
IRepository<T>abstraction backed by EF Core, complemented by Dapper for performance-sensitive queries.



