Welcome to the CleanArchitecture-Template repository, a powerful solution template that exemplifies the principles of Clean Architecture and integrates them seamlessly with CQRS using ASP.NET Core.
If you find value in this project, whether you're using it for learning or kickstarting your solution, a star is a wonderful way to express your support. Thank you in advance!
- Visual Studio 2022
- .NET 10.0 Runtime
For the full architecture notes and runtime request flow, see docs/architecture.md.
flowchart LR
classDef web fill:#dbeafe,stroke:#2563eb,color:#172554
classDef core fill:#dcfce7,stroke:#16a34a,color:#14532d
classDef infra fill:#fef3c7,stroke:#d97706,color:#78350f
classDef shared fill:#f3e8ff,stroke:#9333ea,color:#3b0764
classDef external fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
Client["HTTP Client / Swagger UI"]:::external
Api["CleanTemplate.Api<br/>Controllers, auth, versioning,<br/>Swagger/ReDoc, health checks"]:::web
ApiFramework["CleanTemplate.ApiFramework<br/>API results, Swagger filters,<br/>Autofac helpers"]:::web
Application["CleanTemplate.Application<br/>Command/query contracts<br/>and response models"]:::core
Domain["CleanTemplate.Domain<br/>Entities and repository contracts"]:::core
Persistence["CleanTemplate.Persistence<br/>EF Core, read/write DbContexts,<br/>handlers, repositories, migrations"]:::infra
Dispatching["CleanTemplate.Dispatching<br/>Custom dispatcher and pipeline"]:::shared
Common["CleanTemplate.Common<br/>Options, exceptions, utilities,<br/>pipeline behaviors"]:::shared
SqlServer[("SQL Server")]:::external
Redis[("Redis / PolyCache")]:::external
Client --> Api
Api --> ApiFramework
Api --> Application
Api --> Dispatching
Api --> Common
ApiFramework --> Persistence
Application --> Domain
Application --> Dispatching
Application --> Common
Persistence --> Application
Persistence --> Domain
Persistence --> Dispatching
Persistence --> Common
Persistence --> SqlServer
Persistence --> Redis
Api -.health checks.-> SqlServer
Api -.health checks.-> Redis
Here's the simplest way to get started with your project:
- Open your command-line interface.
- Execute the following command:
dotnet new install ASPNETCleanTemplate.nuspec::3.6.2
- Create an empty folder to house your solution and navigate into it.
- Run the subsequent command, replacing
MyNewCleanTemplatewith your desired project name:dotnet new aspnetcleantemplate -n MyNewCleanTemplate
To handle database migration with finesse:
- Set the default project to Persistence.
- Open the Package Manager Console and run:
Update-Database -Context AppDbContext
For health check administration, utilize the following URL: https://Url:Port/healthchecks-ui
- ASP.NET Core
- Entity Framework Core
- CleanTemplate.Dispatching
- Swagger
- Redis (for distributed caching)
- Jwt Token Authentication
- Custom Asp.Net Identity
- Api Versioning
- FluentValidation
- PolyCache (for caching)
- Serilog
- Elasticsearch (for writing Logs)
- Mapper
- Docker
- xUnit
- Clean Architecture
- Clean Code
- CQRS
- Authentication and Authorization
- Distributed caching
- SOLID Principles
- Segregated ReadOnly and Write DbContext
- Segregated ReadOnly and Write Repository
- REST API Naming Conventions
- Multi-environment Utilization in ASP.NET Core (Development, Production, Staging, etc.)
- Modular Design
- Custom Exceptions
- Tailored Exception Handling
- Unit Tests
- Integration Tests
- PipelineBehavior for Validation and Performance Tracking.
- The Significance of Clean Architecture Template with .NET
- Understanding and Implementing Scalability in CQRS
- Why We Need Clean Architecture?
Elevate your development journey with the CleanArchitecture-Template Plus!
