A production-ready .NET 10 Web API template built on Clean Architecture and CQRS. Use this as a starting point for any new API project — authentication, database, Docker, and tests are all wired up.
- JWT authentication with refresh token rotation
- Role-based authorization (User, Admin)
- CQRS via MediatR with automatic validation pipeline
- Repository pattern with Unit of Work
- Consistent API response format
- Pagination support
- Structured logging via Serilog
- Swagger UI with Bearer auth
- Docker + docker-compose
- Integration tests with real PostgreSQL (Testcontainers + Respawn + Bogus)
| Concern | Library |
|---|---|
| Framework | ASP.NET Core 10 |
| ORM | Entity Framework Core + Npgsql |
| CQRS | MediatR 14 |
| Validation | FluentValidation 12 |
| Auth | ASP.NET Identity + JWT |
| Logging | Serilog |
| Testing | xUnit + FluentAssertions + Moq + Testcontainers |
src/
├── Domain/ # Entities, Value Objects, Enums, Exceptions
├── Application/ # CQRS handlers, validators, interfaces, behaviors
├── Infrastructure/ # EF Core, repositories, JWT, email
└── API/ # Controllers, middleware, Program.cs
tests/
├── Domain.Tests/
├── Application.Tests/
└── Integration.Tests/
docs/
└── ARCHITECTURE.md
git clone https://github.com/eaback/dotnet-API.git
cd dotnet-API
docker compose upAPI available at http://localhost:8080/swagger
# Start database
make docker-up
# Apply migrations
make migrate
# Run API
make runmake test-unit
make test-integration| Method | Endpoint | Auth |
|---|---|---|
| POST | /api/auth/register |
Public |
| POST | /api/auth/login |
Public |
| POST | /api/auth/refresh |
Public |
| Method | Endpoint | Auth |
|---|---|---|
| GET | /api/users |
Admin |
| GET | /api/users/{id} |
User |
| PUT | /api/users/{id} |
User |
| DELETE | /api/users/{id} |
Admin |
See docs/ARCHITECTURE.md for a full explanation of the layer structure, CQRS pattern, and data flow.
MIT — free to use as a starting point for any project.