Ardalis Clean Architecture
A starting point for Clean Architecture with ASP.NET Core. Clean Architecture is just the latest in a series of names for the same loosely-coupled, dependency-inverted architecture. You will also find it named hexagonal, ports-and-adapters, or onion architecture.
This repository ships two dotnet new templates that give you a working, tested, well-factored ASP.NET Core API to build on, with a little real code in place (instead of an empty Class1.cs) so you can see where things belong.
Two templates
| Clean Architecture | Minimal Clean Architecture | |
|---|---|---|
| Short name | clean-arch | min-clean |
| NuGet package | Ardalis.CleanArchitecture.Template | Ardalis.MinimalClean.Template |
| Shape | Multi-project solution: Core, UseCases, Infrastructure, Web | One Web project organized into vertical slices |
| Organized by | Layer (horizontal) | Feature (vertical) |
| Boundaries enforced by | Project references | Namespace rules (NsDepCop) |
| Tests included | Unit, integration, functional | None (add your own) |
| Best for | Larger, long-lived apps and teams that want strict boundaries | MVPs, smaller apps, and teams that want guidance without ceremony |
Both templates include FastEndpoints (REPR), EF Core, the Mediator source generator, Ardalis.Specification, Serilog, and an optional .NET Aspire host. See Choosing a Template for a detailed comparison.
Quick start
# Install (once)
dotnet new install Ardalis.CleanArchitecture.Template
dotnet new install Ardalis.MinimalClean.Template
# Create a solution
dotnet new clean-arch -o Your.ProjectName
# ...or the minimal version
dotnet new min-clean -o Your.ProjectNameThen follow Getting Started to build and run it.
Template versions are not .NET versions. For example, template v11.x targets .NET 10 and template v12.x targets .NET 11. See Versions for the full mapping before you upgrade or follow a migration guide.
Where to go next
- Getting Started: install the templates, create a solution, and run it.
- Choosing a Template: full vs. minimal, and what each one contains.
- Running the Application: Aspire, databases, API docs, and email.
- Data & Migrations: EF Core providers and migration commands.
- Building & Testing: build settings, test projects, Docker, and coverage.
- Goals & Design Decisions: why the solution is shaped the way it is.
- Enforcing Dependency Rules: how NsDepCop keeps layers and feature slices apart.
- Customizing: Controllers, Razor Pages, other databases, removing Aspire.
- Migration Guides: moving an existing app to a newer template version.
- Contributing: how to help, and how to work on the templates themselves.
- Resources: courses, the book, videos, and podcasts.
Learn more
Learn about Clean Architecture and this template in the NimblePros Learn Clean Architecture course, taught by Sarah “sadukie” Dutkiewicz and Steve “ardalis” Smith. Use code ARDALIS to save 20%.
This architecture is used in the DDD Fundamentals course by Steve Smith and Julie Lerman.
Contact Steve’s company, NimblePros, for Clean Architecture or DDD training and/or implementation assistance for your team.
Give a star
If you like or are using this project to learn or start your solution, please give it a star on GitHub. Thanks!
Or if you’re feeling really generous, the project accepts GitHub sponsorships.
Sponsors
Amazon AWS’s FOSS fund has awarded a 12-month sponsorship to this project. Thank you, and thanks to all past and current sponsors!
