A Clean Architecture toolkit for Minimal APIs on .NET 9 and .NET 10, with vertical-slice-style application organization inside clean dependency boundaries.
Default multi-project app:
dotnet new install MinimalCleanArch.Templates
dotnet new mca -n MyApp
cd MyApp
dotnet run --project src/MyApp.ApiRecommended single-project app:
dotnet new mca -n MyApp --single-project --recommended
cd MyApp
dotnet runThen open https://localhost:<port>/scalar/v1.
For auth + OpenIddict + Scalar password flow:
dotnet new mca -n QuickAuth --single-project --auth --tests --mcaVersion 0.1.18
cd QuickAuth
dotnet runUse the auth walkthrough in templates/README.md.
For template options, generated structure, and architecture details, see templates/README.md.
- keep domain rules, repository contracts, and specifications separate from infrastructure concerns
- add EF Core persistence without pushing EF types into the domain layer
- bootstrap Minimal API applications with consistent validation, error handling, OpenAPI, rate limiting, and operational defaults
- opt into messaging, audit logging, and encryption only when the application actually needs them
- scaffold new applications with a package set that already follows the intended dependency direction
- project and package boundaries follow Clean Architecture dependency direction
- application use cases are organized in a vertical-slice/CQRS-friendly style rather than around large layered service classes
- the intent is not “pure vertical slices with no shared layers”; it is clean boundaries plus feature-oriented handlers and endpoints
- Domain building blocks (entities, repositories, unit of work, specifications, result pattern)
- Minimal API helpers (validation wiring, standardized error handling, OpenAPI + Scalar)
- Security and encryption (Data Protection/AES column encryption)
- Blob/object storage abstractions with Azure Blob Storage support
- Soft delete and auditing support
- EF Core integration with specification evaluation
- Core domain and repository abstractions:
MinimalCleanArch - EF Core repositories and specifications:
MinimalCleanArch.DataAccess - Minimal API bootstrap, error mapping, OpenAPI, rate limiting:
MinimalCleanArch.Extensions - FluentValidation registration:
MinimalCleanArch.Validation - Domain events and Wolverine integration:
MinimalCleanArch.Messaging - Audit interception and audit queries:
MinimalCleanArch.Audit - Encrypted EF properties and encryption services:
MinimalCleanArch.Security - Generic blob storage abstraction and Azure Blob Storage integration:
MinimalCleanArch.Storage - Project scaffolding:
MinimalCleanArch.Templates
- Latest stable packages/templates:
0.1.18
- Template validation uses two package sources by default: the local
MinimalCleanArchfeed andnuget.org. - This is required because generated projects reference both
MinimalCleanArch.*packages and pinned third-party packages. - Use local-feed-only validation only if your feed mirrors every external dependency used by the templates.
For new applications, the recommended order is:
- Model entities, repository contracts, and specifications with
MinimalCleanArch. - Add EF Core repositories and unit of work with
MinimalCleanArch.DataAccess. - Add API bootstrap with
MinimalCleanArch.Extensions. - Register application validators with
MinimalCleanArch.Validation. - Add
MinimalCleanArch.Messaging,MinimalCleanArch.Audit,MinimalCleanArch.Security, andMinimalCleanArch.Storageonly when the app actually needs them.
Preferred defaults:
- use specifications through
IRepository<TEntity, TKey> - use
AddMinimalCleanArchApi(...)as the main API bootstrap method - use
AddValidationFromAssemblyContaining<T>()for validator registration - use
AddMinimalCleanArchMessaging...extensions instead of wiring Wolverine from scratch - use Data Protection-based encryption for new development
- use
IExecutionContextas the shared source for user, tenant, and correlation data across HTTP and message-handler flows
MinimalCleanArchis the foundation. Other MCA packages can depend on it; your domain layer can depend on it.MinimalCleanArch.DataAccessdepends onMinimalCleanArchand belongs in infrastructure.MinimalCleanArch.Extensionsdepends onMinimalCleanArchand belongs in the API/host layer.MinimalCleanArch.Validationdepends onMinimalCleanArchandMinimalCleanArch.Extensions; use it where API validation registration happens.MinimalCleanArch.MessagingandMinimalCleanArch.Auditdepend onMinimalCleanArchand are optional infrastructure/application-host add-ons.MinimalCleanArch.Securityis an optional infrastructure package for encryption concerns.MinimalCleanArch.Storageis an optional infrastructure package for blob/object storage concerns.- Domain projects should not reference
DataAccess,Extensions,Validation,Messaging,Audit,Security, orStorage.
| Package | Helps achieve | Depends on | Typical layer |
|---|---|---|---|
MinimalCleanArch |
domain model, contracts, specifications, result types | none | Domain |
MinimalCleanArch.DataAccess |
EF Core repositories, unit of work, audited DbContext base types | MinimalCleanArch |
Infrastructure |
MinimalCleanArch.Extensions |
API bootstrap, validation pipeline, error mapping, OpenAPI, rate limiting | MinimalCleanArch |
API/Host |
MinimalCleanArch.Validation |
validator registration and API validation integration | MinimalCleanArch, MinimalCleanArch.Extensions |
API/Host or composition root |
MinimalCleanArch.Security |
encryption services and encrypted EF property support | no MCA package dependency | Infrastructure |
MinimalCleanArch.Storage |
blob/object storage abstraction with Azure Blob Storage integration | no MCA package dependency | Infrastructure |
MinimalCleanArch.Messaging |
domain events, Wolverine integration, outbox-capable messaging | MinimalCleanArch |
Infrastructure or host |
MinimalCleanArch.Audit |
audit interception, audit storage, audit queries | MinimalCleanArch |
Infrastructure |
MinimalCleanArch.Templates |
scaffold new MCA-based applications | packaged templates | Project scaffolding |
Additional docs:
- Sample app:
samples/MinimalCleanArch.Sample/README.md - Release notes template:
release-notes.md - Third-party notices:
THIRD_PARTY_NOTICES.md
Contributions are welcome. See CONTRIBUTING.md.
MIT. See LICENSE.