Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

.NET License Tests Architecture

Clean Architecture API Template

A production-ready ASP.NET Core Web API template built using Clean Architecture, CQRS, MediatR, Entity Framework Core, FluentValidation, and SQL Server.

This template is designed to demonstrate how medium and large applications can be structured for maintainability, testability, and long-term growth while keeping the codebase easy to understand.

Youtube video URL:

ASP.NET Core Clean Architecture with .NET 10 | Build Scalable & Maintainable Applications

Quick Start

git clone ...

dotnet restore

dotnet ef database update --project Infrastructure --startup-project Api

dotnet run

Open Swagger


Features

  • Clean Architecture
  • CQRS with MediatR
  • Entity Framework Core
  • SQL Server
  • FluentValidation
  • AutoMapper
  • Dependency Injection
  • Repository Pattern
  • Domain Events
  • Global Exception Handling
  • Unit Tests
  • Integration Tests
  • Swagger/OpenAPI

Why This Template Exists

Most Clean Architecture examples show folder structures but spend very little time explaining why those boundaries exist.

This project focuses on both implementation and reasoning.

Every architectural decision is documented so you understand:

  • why the decision was made
  • when it is appropriate
  • when it becomes unnecessary complexity
  • how to extend the project safely

The goal is not to create the most complicated architecture possible.

The goal is to provide a production-quality starting point that can grow with your application.


Who This Is For

This project is intended for developers who:

  • already know basic ASP.NET Core
  • have built CRUD APIs
  • want to learn production architecture
  • want a reusable starting point for new projects

Who This Is NOT For

This template is probably not the right choice if you're building:

  • a prototype
  • a small internal application
  • a weekend project
  • a simple CRUD API with only a few endpoints

In those cases, a traditional N-tier architecture is usually simpler and easier to maintain.


Architecture Overview

Dependencies always point inward.

The Domain layer never depends on any other project.

graph TD
    Api --> Application
    Api --> Infrastructure
    Infrastructure --> Application
    Infrastructure --> Domain
    Application --> Domain
Loading

Project Structure

CleanArchitecture/
│
├── Api
│   ├── Controllers
│   ├── Middleware
│   ├── Program.cs
│   └── appsettings.json
│
├── Application
│   ├── Commands
│   ├── Queries
│   ├── Validators
│   ├── DTOs
│   └── Behaviors
│
├── Domain
│   ├── Entities
│   ├── Enums
│   ├── Events
│   ├── Exceptions
│   ├── Interfaces
│   ├── ValueObjects
│   └── Common
│
├── Infrastructure
│   ├── Persistence
│   ├── Migrations
│   └── DependencyInjection.cs
│
├── Tests.Unit
│
└── Tests.Integration

Technology Stack

  • ASP.NET Core
  • C#
  • SQL Server
  • Entity Framework Core
  • MediatR
  • FluentValidation
  • AutoMapper
  • xUnit
  • Swagger

Getting Started

Prerequisites

  • .NET 10 SDK
  • SQL Server 2022+ or
  • Postgresql
  • Visual Studio 2022 17.14+
  • Git

Clone

git clone <repository>

Update Connection String

Edit

appsettings.json

Apply Migrations

dotnet ef database update

Run

dotnet run --project src/Api

Swagger

https://localhost:5001/swagger
``
---
# License

CleanArchitecture License

Read License for this.

About

A production-ready ASP.NET Core Web API template built using Clean Architecture, CQRS, MediatR, Entity Framework Core, FluentValidation, and SQL Server.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors