A Clean Architecture kernel with host adapters and optional client surfaces. ASP.NET Minimal APIs on .NET 9 and .NET 10 are the first host adapter.
Navigate the repo: start at docs/index.md. Product layers: docs/07-bootstrap-product.md.
The supported way to start a real app is the generated template with --recommended --auth (multi-project, filesystem src/):
dotnet new install MinimalCleanArch.Templates
dotnet new mca -n MyApp --recommended --auth
cd MyApp
dotnet run --project src/MyApp.ApiThen open https://localhost:<port>/scalar/v1. Use the auth walkthrough in templates/README.md.
samples/MinimalCleanArch.Sample is a package smoke demo. Do not copy its endpoint-writes-the-aggregate Todo path when generating a product; generated apps use handlers.
Minimal API-only (dotnet new mca -n MyApp) and --single-project remain valid shapes. They are not the teaching default.
For flags and generated structure, 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, optional blob storage (
--storage), 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 packages/templates:
0.1.21
./scripts/pack.sh --package-version 0.1.21
./scripts/validate-templates.sh -McaVersion 0.1.21 # or: ./scripts/validate-templates.ps1
./scripts/clean-temp.sh # reclaim temp/MCA_Tests + temp/validate- Wrappers live under
scripts/; implementation istemplates/scripts/validate-templates.ps1. - Scaffolds multi/single variants (including Aspire AppHost builds by default;
-SkipAspireto omit). - Successful validation deletes its
temp/validate/<run>/tree (use-KeepOutputto keep). Template tests cleantemp/MCA_Tests/<id>/after each test unlessMCA_KEEP_TEMPLATE_OUTPUT=1. - Uses two package sources by default: the local
MinimalCleanArchfeed andnuget.org. - Use local-feed-only validation only if your feed mirrors every external dependency used by the templates.
- Repo libraries/sample/tests use Central Package Management (
eng/Directory.Packages.props). - Generated templates keep explicit package versions (no CPM dependency).
- See
docs/package-management.md.
- Template:
dotnet new mca -n MyApp --recommended --aspire --db postgres - Run:
./scripts/run-apphost.sh/pwsh ./scripts/run-apphost.ps1(ordotnet run --project MyApp.AppHost) - Connection names:
appdb(Postgres/SQL Server),redis(when caching is enabled) - Sample spike:
samples/MinimalCleanArch.Aspire/README.md(sample still uses namemca) - Direct sample (SQLite, no containers):
dotnet run --project samples/MinimalCleanArch.Sample
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.Jobs,MinimalCleanArch.Realtime,MinimalCleanArch.Features,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 (validators + rate limiting + problem details) - use
UseMinimalCleanArchApiDefaults(...)for the standard middleware pipeline (correlation ID, security headers, error handling, optional rate limiting) - prefer
options.AddValidatorsFromAssemblyContaining<T>()onAddMinimalCleanArchApiover separate validator registration calls - map endpoint outcomes with
result.MatchHttp(...)/error.ToProblem(...)(RFC 7807), not plain string bodies - validate handler-built commands/queries with
httpContext.ValidateAsync(...)(orWithValidation<T>()for body parameters) - 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
The sample app and generated templates follow this bootstrap and HTTP mapping path when API polish features are enabled.
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.MinimalCleanArch.Emailis an optional infrastructure package for SMTP / HTTP email.MinimalCleanArch.Jobsis an optional scheduling port (recurring + delayed) with anIHostedServicefallback.MinimalCleanArch.Realtimeis an optional publish port (channel, payload, tenant/user). SignalR lives in Extensions.MinimalCleanArch.Featuresis an optional feature-flag port (IFeatureGate). HTTPRequireFeaturelives in Extensions.- Domain projects should not reference
DataAccess,Extensions,Validation,Messaging,Audit,Security,Storage,Email,Jobs,Realtime, orFeatures.
| 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, SignalR realtime adapter, feature-gate filter | MinimalCleanArch, MinimalCleanArch.Realtime, MinimalCleanArch.Features |
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.Email |
email port with SMTP and HTTP API adapters | no MCA package dependency | Infrastructure |
MinimalCleanArch.Jobs |
recurring + delayed job port (IJobScheduler) |
no MCA package dependency | Application / host |
MinimalCleanArch.Realtime |
realtime publish port (IRealtimePublisher) |
no MCA package dependency | Application / host |
MinimalCleanArch.Features |
feature-flag port (IFeatureGate) |
no MCA package dependency | Application / host |
MinimalCleanArch.Messaging |
domain events, Wolverine integration, outbox-capable messaging | MinimalCleanArch, MinimalCleanArch.Jobs |
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:
- Repo navigation (DDD-style map of the system as built):
docs/index.md - Sample app:
samples/MinimalCleanArch.Sample/README.md - Package management:
docs/package-management.md - Release notes template:
release-notes.md - Third-party notices:
THIRD_PARTY_NOTICES.md
Contributions are welcome. See CONTRIBUTING.md.
MIT. See LICENSE.