Skip to content

eaback/dotnet-API

Repository files navigation

dotnet-clean-api-starter

CI .NET 10 License

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.

What's included

  • 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)

Tech stack

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

Project structure

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

Getting started

Prerequisites

Run with Docker

git clone https://github.com/eaback/dotnet-API.git
cd dotnet-API
docker compose up

API available at http://localhost:8080/swagger

Run locally

# Start database
make docker-up

# Apply migrations
make migrate

# Run API
make run

Run tests

make test-unit
make test-integration

API endpoints

Auth

Method Endpoint Auth
POST /api/auth/register Public
POST /api/auth/login Public
POST /api/auth/refresh Public

Users

Method Endpoint Auth
GET /api/users Admin
GET /api/users/{id} User
PUT /api/users/{id} User
DELETE /api/users/{id} Admin

Architecture

See docs/ARCHITECTURE.md for a full explanation of the layer structure, CQRS pattern, and data flow.

License

MIT — free to use as a starting point for any project.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors