Skip to content

LinhNC/DotNetCleanArchitecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotNetCleanArchitecture

A modern, production-ready .NET Clean Architecture boilerplate built with ASP.NET Core, following Clean Architecture, Domain-Driven Design (DDD), and SOLID principles.

DotNetCleanArchitecture provides a clean, scalable, and maintainable foundation for building enterprise-grade .NET applications, RESTful Web APIs, and cloud-ready systems.


📑 Table of Contents


🌐 Learn More ⭐

Overall: Clean Architecture in .NET Overall

Realworld Example: Clean Architecture in .NET: A Practical Guide with Real-World Product Example


🚀 Overview

Building scalable .NET applications requires a strong architectural foundation. DotNetCleanArchitecture helps developers implement Clean Architecture in .NET from the start, reducing technical debt and improving long-term maintainability.

This repository is designed for developers who want:

  • A real-world ASP.NET Core Clean Architecture example
  • Clear separation of concerns
  • Highly testable and extensible code
  • Enterprise-ready project structure

✨ Key Features

  • ✅ Clean Architecture implementation for .NET
  • ✅ ASP.NET Core Web API with Swagger/OpenAPI
  • ✅ Domain-Driven Design (DDD) with real Product entity example
  • ✅ SOLID principles applied throughout
  • ✅ CQRS pattern (Commands & Queries)
  • ✅ Repository and Unit of Work patterns
  • ✅ Clear separation of concerns
  • ✅ High testability and maintainability
  • ✅ Infrastructure-independent business logic
  • ✅ Comprehensive documentation and blog posts
  • ✅ Production-ready test infrastructure
  • ✅ Open-source and extensible

📖 Read the full Clean Architecture guide →


🧱 Architecture

This project follows Uncle Bob’s Clean Architecture, ensuring that core business rules are independent of frameworks, databases, and external services.

Project Structure


src/
├── DotNetCleanArchitecture.Domain
│   ├── Entities
│   ├── ValueObjects
│   └── DomainEvents
│
├── DotNetCleanArchitecture.Application
│   ├── UseCases
│   ├── Interfaces
│   ├── DTOs
│   └── BusinessLogic
│
├── DotNetCleanArchitecture.Infrastructure
│   ├── Persistence
│   ├── ExternalServices
│   └── Implementations
│
└── DotNetCleanArchitecture.WebAPI
├── Controllers
├── Middleware
└── Configuration

Dependency Rule


WebAPI → Application → Domain
Infrastructure → Application

The Domain layer has no dependencies on any other layer.


🛠️ Technology Stack

  • .NET (Latest LTS)
  • ASP.NET Core
  • Clean Architecture
  • Domain-Driven Design (DDD)
  • SOLID Principles
  • RESTful APIs
  • Dependency Injection
  • Entity Framework Core (optional)
  • CQRS pattern (optional)

📦 Use Cases

This .NET Clean Architecture boilerplate is suitable for:

  • Enterprise applications
  • SaaS platforms
  • Microservices
  • Cloud-native systems
  • RESTful Web APIs
  • Long-term maintainable systems

⚙️ Getting Started

Prerequisites

  • .NET SDK (latest LTS recommended)
  • Visual Studio, Rider, or VS Code

Clone the Repository

git clone https://github.com/LinhNC/DotNetCleanArchitecture.git
cd DotNetCleanArchitecture

Build the Solution

dotnet restore
dotnet build

Run the Application

dotnet run --project src/DotNetCleanArchitecture.WebAPI

The API will be available at:

https://localhost:5001

📖 Resources & Documentation

Blog Posts & Articles

📝 Clean Architecture in .NET: A Practical Guide with Real-World Product Example

  • Complete explanation of Clean Architecture principles
  • Step-by-step implementation guide
  • Real Product entity example with code
  • Architecture diagrams and best practices
  • When to use Clean Architecture vs alternatives

🧪 Testing Strategy

The architecture promotes high testability by design.

You can easily implement:

  • Unit tests for Domain and Application layers
  • Integration tests for Infrastructure
  • API tests for the WebAPI layer

📚 Clean Architecture Principles

  • Independence of frameworks
  • Business logic isolation
  • Testable core logic
  • Dependency Inversion Principle
  • Single Responsibility Principle
  • Separation of concerns

🏗️ When to Use This Template

Use DotNetCleanArchitecture if you want to:

  • Implement Clean Architecture in .NET correctly
  • Build maintainable ASP.NET Core Web APIs
  • Start projects with best practices
  • Reduce technical debt
  • Create scalable enterprise solutions

🔍 Keywords & Topics

Primary Keywords:

  • dotnet clean architecture
  • asp.net core clean architecture
  • clean architecture boilerplate .net
  • .net clean architecture example
  • clean architecture template asp.net core

Related Topics:

  • domain driven design asp.net core
  • cqrs pattern .net
  • repository pattern entity framework
  • unit of work pattern c#
  • solid principles .net
  • enterprise architecture .net core
  • microservices clean architecture
  • onion architecture .net
  • hexagonal architecture asp.net

Learn More: Clean Architecture in .NET: A Practical Guide with Real-World Product Example


🤝 Contributing

Contributions are welcome and encouraged.

You can contribute by:

  • Reporting issues
  • Submitting pull requests
  • Improving documentation
  • Suggesting architectural enhancements

📄 License

This project is licensed under the MIT License. You are free to use, modify, and distribute this software for personal or commercial purposes.


⭐ Support

If this project helps you:

  • ⭐ Star the repository
  • 🔁 Share it with the community
  • 💬 Provide feedback or suggestions

🔗 Topics

dotnet · aspnet-core · clean-architecture · ddd · solid-principles · web-api · boilerplate

About

A modern .NET Clean Architecture boilerplate using ASP.NET Core, DDD, and SOLID principles for building scalable, maintainable, and testable applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages