sam-clean-architecture
0.2.1
dotnet new install sam-clean-architecture@0.2.1
Clean Architecture Template
A production-ready .NET 10 Clean Architecture template with CQRS, Domain-Driven Design, and modern cloud-native features.
Quick Start
dotnet new install sam-clean-architecture
dotnet new sam-clean-architecture -n MyProject
cd MyProject
docker-compose up -d
dotnet run --project src/Web.Api
API runs at: http://localhost:5000
Swagger: http://localhost:5000/swagger
Key Features
✅ Clean Architecture - Organized layers (Domain, Application, Infrastructure, Web)
✅ CQRS & DDD - Commands, Queries, Domain Events, Aggregates
✅ JWT Authentication - Token-based API security
✅ Role & Permission Authorization - Fine-grained access control
✅ Entity Framework Core 10 - With audit trails and soft deletes
✅ Hybrid Caching - In-memory (L1) + Redis (L2) with failover
✅ Event-Driven - MassTransit + RabbitMQ for async messaging
✅ Structured Logging - Serilog with request/response capture
✅ Distributed Tracing - OpenTelemetry + Jaeger integration
✅ API Rate Limiting - Built-in 100 req/min throttling
✅ Data Encryption - AES encryption for sensitive fields
✅ Testing - Architecture and unit tests included
Architecture Layers
src/
├── Domain/ # Business entities & rules
├── Application/ # Use cases (Commands/Queries)
├── Infrastructure/ # Data access, services, external APIs
├── SharedKernel/ # Cross-cutting abstractions
├── Web.Api/ # REST API endpoints
└── Web.Worker/ # Background event processing
Prerequisites
- .NET 10 SDK
- Docker Desktop (for local dev services)
- SQL Server (or Docker)
Available Services
| Service | Port | Purpose |
|---|---|---|
| API | 5000 | REST endpoints |
| Swagger | 5000/swagger | API documentation |
| SQL Server | 1433 | Database |
| RabbitMQ | 5672 | Message broker |
| Redis | 6379 | Cache |
| Seq | 5341 | Log viewer |
| Jaeger | 16686 | Trace viewer |
Documentation
- Full Docs - See
README.mdin the generated project - Quick Start - See
QUICKSTART.mdfor setup instructions - Architecture - Check
docs/folder for detailed guides
What's Included
- Domain-Driven Design patterns
- CQRS with MediatR
- Entity audit trails (CreatedBy, ModifiedAt, etc.)
- Soft delete support
- Encrypted data fields (AES)
- Domain events with MassTransit
- Background worker with RabbitMQ consumers
- JWT authentication & authorization
- Structured logging with Serilog
- OpenTelemetry tracing
- Health checks (liveness/readiness)
- Swagger/OpenAPI documentation
- Docker Compose stack included
- Unit & architecture tests
Commands
# Build
dotnet build
# Run tests
dotnet test
# Run API
dotnet run --project src/Web.Api
# Run worker
dotnet run --project src/Web.Worker
# Create migration
dotnet ef migrations add [MigrationName] --project src/Infrastructure --startup-project src/Web.Api
# Apply migrations
dotnet ef database update --project src/Infrastructure --startup-project src/Web.Api
Support
- Issues - GitHub Issues
- Discussion - GitHub Discussions
License
MIT License - See LICENSE file for details
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.