Skip to content

harsh07may/CleanArchitectureAPI

Repository files navigation

Clean Architecture API Template

  1. Clean Architecture API Template --- Establish folder structure (Domain, Application, Infrastructure, Web) with MediatR and Dependency Injection.
  2. Logging & Global Error Handling --- Implement Serilog, Seq, and custom Middleware for structured error handling.
  3. Configuration Management --- Load configuration from appsettings.json, environment variables, and secret managers.
  4. Exception Handling + ProblemDetails --- Standardized RFC7807 error response format.
  5. Health Checks & Readiness Probes --- Expose /health and /ready endpoints for container environments.

Purpose

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.

High-level architecture

• 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).

Projects (what’s present)

• 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.

How to run (dev)

• From CLI:

dotnet build
dotnet run --project CleanArchitectureAPI.Api

• From Visual Studio: • Use Build Solution then Debug > Start Debugging or run the API project.

Notes

• 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.

About

A minimal clean-architecture ASP.NET Core Web API template.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages