Skip to main content
ModernAPI

ModernAPI Clean Architecture

Explore the four-layer Clean Architecture implementation powering this .NET 9 template

Clean ArchitectureDomain-Driven DesignSOLID PrinciplesEF Core + PostgreSQL.NET 9 + ASP.NET Core
ModernAPI Clean Architecture Layers
Click each layer to explore the specific .NET 9 implementation, files, and responsibilities in the ModernAPI template

API Layer (ModernAPI.API)

HTTP concerns, Controllers, Middleware - The entry point of your application

4 files

Application Layer (ModernAPI.Application)

Business logic orchestration, Services, DTOs, Use Cases

4 files

Infrastructure Layer (ModernAPI.Infrastructure)

Data access, External services, Technical implementations

4 files

Domain Layer (ModernAPI.Domain)

Pure business logic, Entities, Value Objects, Domain Events

4 files

API Layer (ModernAPI.API) Details

HTTP concerns, Controllers, Middleware - The entry point of your application

Technologies
ASP.NET Core 9ControllersMiddlewareScalar UICORS
Responsibilities
  • HTTP request/response handling with proper status codes
  • Global exception handling with RFC 7807 Problem Details
  • JWT authentication middleware and cookie extraction
Key Files
  • Controllers/AuthController.cs - JWT authentication endpoints
  • Controllers/UsersController.cs - User management CRUD operations
  • Middleware/ExceptionMiddleware.cs - Global error handling
  • Program.cs - Dependency injection and middleware configuration

API Endpoints

12+

Auth + Users + Health

Application Services

5

Auth, JWT, User, Password

Repositories

3

User, RefreshToken, UoW

Domain Entities

2

User, RefreshToken

Why Clean Architecture in ModernAPI?
The benefits you get from this architectural approach in real-world development

Complete Test Coverage

Business logic completely isolated and testable. Domain tests run without databases or external dependencies.

Database Flexibility

Switch from PostgreSQL to SQL Server or SQLite by changing one line in configuration.

Framework Independence

Business rules don't depend on ASP.NET Core, Entity Framework, or any external library.

Clear Dependencies

Dependencies point inward. Infrastructure depends on Domain, never the reverse.