A lightweight .NET 8 based Clean Architecture template leveraging Minimal API. This repository helps you quickly set up a maintainable project structure that separates core business rules from infrastructure and presentation concerns.
- Faster Development: Pre-configured with essential design patterns like CQRS (Commands/Queries), value objects, and layered architecture.
- Domain-Driven Design: Organize your core business logic with Entities, Value Objects, Specifications, and Domain Services.
- Flexible Data Access: Uses SQLite by default but supports SQL Server and other databases with minimal changes.
- Simple API: Minimal API endpoints keep things lightweight and easy to extend.
- Extensible: Easily add new modules, microservices, or features without breaking existing code.
- Scalable: Clear separation of concerns keeps your code well-organized as your app grows.
- Robust Testing: Includes example unit tests (using xUnit and Moq) to encourage a TDD mindset.
- Polly Integration: Resilient API calls with built-in retries, circuit breaker patterns, and fallbacks.
- Domain Layer
- Entities, value objects, and domain services.
- Application Layer
- Interfaces, DTOs, commands, queries, and validators.
- Infrastructure Layer
- Persistence, database repositories, and external service integrations.
- Presentation Layer
- Minimal API endpoints, middleware, and request/response handling.
The following prerequisites are required to build and run the solution:
- .NET 8.0 SDK (LTS)
- Clone the repository to your local machine.
git clone https://github.com/iPazooki/CleanArchitecture.git
git clone [email protected]:iPazooki/CleanArchitecture.git
- Navigate to the project directory.
- Restore dependencies using:
dotnet restore
- Build and run the application:
dotnet build
dotnet run --project CleanArchitecture.Presentation
- Visit the automatically generated Swagger UI (by default at
https://localhost:7281/swagger/index.html
) for interactive documentation.
To switch from the default SQLite to SQL Server, remove the UseSQLite
constant from the DefineConstants
property in CleanArchitecture.Infrastructure.Persistence.csproj
and adjust the connection string in your appsettings.json
.
<DefineConstants>UseSQLite</DefineConstants>
To add migrations and update the database, run the following commands:
dotnet ef migrations add InitialCreate --project CleanArchitecture.Infrastructure.Persistence --startup-project CleanArchitecture.Presentation
dotnet ef database update --project CleanArchitecture.Infrastructure.Persistence --startup-project CleanArchitecture.Presentation
Pull requests are welcome! For major changes, please open an issue first to discuss proposed modifications. We appreciate your support and feedback. Don’t forget to star the project if you find it helpful.
This project is licensed under the MIT license. Feel free to use it as a foundation for your own projects!