- Clean Architecture API Template --- Establish folder structure (Domain, Application, Infrastructure, Web) with MediatR and Dependency Injection.
- Logging & Global Error Handling --- Implement Serilog, Seq, and custom Middleware for structured error handling.
- Configuration Management --- Load configuration from appsettings.json, environment variables, and secret managers.
- Exception Handling + ProblemDetails --- Standardized RFC7807 error response format.
- Health Checks & Readiness Probes --- Expose
/healthand/readyendpoints for container environments.
A minimal clean-architecture ASP.NET Core Web API template that separates responsibilities into Domain, Application, Infrastructure, and API projects, uses repository pattern abstractions plus dependency injection, and prepares the project for incremental implementation of data persistence and services.
Focuses on setting up a clean architecture template with essential features like logging, error handling, configuration management, and health checks.
• Domain: Entities, value objects, domain events, business rules (pure domain). • Application: Use-cases, DTOs, interfaces (repositories), application services, mapping, and validation. • Infrastructure: Implementations of repository interfaces, persistence (DbContext), external service clients, file storage, actual DI registration (extension methods). • API: ASP.NET Core minimal API / controllers, endpoint wiring, middleware, and startup (Program.cs).
• CleanArchitectureAPI.Domain — domain classes and entities. • CleanArchitectureAPI.Application — app layer; references Domain. • CleanArchitectureAPI.Infrastructure — repository implementations, AppDbContext, DI extension methods. • CleanArchitectureAPI.Api — web API host; calls .AddApplication() and .AddInfrastructure() extension methods.
• From CLI:
dotnet build
dotnet run --project CleanArchitectureAPI.Api• From Visual Studio: • Use Build Solution then Debug > Start Debugging or run the API project.
• The template targets .NET 8 and uses C# 12. • Project properties show ImplicitUsings enabled. Global global using files are present and acceptable; consider whether you want both implicit and explicit global usings.