# Clean Architecture in .NET: The Complete Guide

> A practical map of Clean Architecture in .NET: dependency direction, layer responsibilities, use-case organization, cross-cutting concerns, and the tradeoffs that tell you when the structure is worth its cost.

Published: 2026-07-10. Last updated: 2026-07-14. Author: Milan Jovanović.

Canonical: https://milanjovanovic.tech/blog/clean-architecture-dotnet

Clean Architecture is a widely used way to structure long-lived .NET applications.
It keeps your business logic independent of frameworks, databases, and UI, which pays off as the system grows.
But the ideas span dozens of topics: layers, the dependency rule, CQRS, cross-cutting concerns, testing, domain modeling.
This guide pulls them all together, from the fundamentals to the patterns you'll use in production.

## What is Clean Architecture?

Clean Architecture is a software design philosophy that separates the elements of a design into ring levels.
The key rule is that **dependencies can only point inward** - outer layers can depend on inner layers, but not vice versa.

In .NET, this typically means organizing your solution into layers like Domain, Application, Infrastructure, and Presentation.
Each layer has a clear responsibility, and the dependency rule ensures your business logic stays independent of frameworks, databases, and UI concerns.

This guide brings together everything you need to master Clean Architecture in .NET.

Want to go deeper? My [**Pragmatic Clean Architecture**](https://milanjovanovic.tech/pragmatic-clean-architecture) course teaches the complete system I use to ship production-ready applications.

## Getting Started

These articles cover the foundational concepts. If you're new to Clean Architecture, start here to understand the "why" before diving into implementation details.

- [Clean Architecture and the Benefits of Structured Software Design](https://milanjovanovic.tech/blog/clean-architecture-and-the-benefits-of-structured-software-design)
- [Clean Architecture Folder Structure](https://milanjovanovic.tech/blog/clean-architecture-folder-structure)
- [Building Your First Use Case with Clean Architecture](https://milanjovanovic.tech/blog/building-your-first-use-case-with-clean-architecture)
- [A Clean Architecture Solution Template for .NET](https://milanjovanovic.tech/blog/clean-architecture-solution-template-dotnet)
- [Clean Architecture with Minimal APIs](https://milanjovanovic.tech/blog/clean-architecture-minimal-apis)

## Core Concepts

Once you understand the basics, these articles explore the principles that make Clean Architecture effective in real-world projects - from handling complexity to managing cross-cutting concerns.

- [Why Clean Architecture Is Great for Complex Projects](https://milanjovanovic.tech/blog/why-clean-architecture-is-great-for-complex-projects)
- [Clean Architecture: The Missing Chapter](https://milanjovanovic.tech/blog/clean-architecture-the-missing-chapter)
- [Balancing Cross-Cutting Concerns in Clean Architecture](https://milanjovanovic.tech/blog/balancing-cross-cutting-concerns-in-clean-architecture)
- [Getting the Current User in Clean Architecture](https://milanjovanovic.tech/blog/getting-the-current-user-in-clean-architecture)
- [Clean Architecture Anti-Patterns and Common Mistakes](https://milanjovanovic.tech/blog/clean-architecture-anti-patterns)
- [Clean Architecture vs Onion vs Hexagonal Architecture](https://milanjovanovic.tech/blog/clean-architecture-vs-onion-vs-hexagonal)
- [When to Use Clean Architecture (And When Not To)](https://milanjovanovic.tech/blog/when-to-use-clean-architecture)
- [The Dependency Rule in Clean Architecture](https://milanjovanovic.tech/blog/dependency-rule-clean-architecture)

## The Layers

Clean Architecture is built from four layers, each with a distinct responsibility. These guides go layer by layer, covering what belongs where and how the pieces map onto each other.

- [The Domain Layer in Clean Architecture](https://milanjovanovic.tech/blog/domain-layer-clean-architecture)
- [The Application Layer in Clean Architecture](https://milanjovanovic.tech/blog/application-layer-clean-architecture)
- [The Infrastructure Layer in Clean Architecture](https://milanjovanovic.tech/blog/infrastructure-layer-clean-architecture)
- [Mapping Between Layers in Clean Architecture](https://milanjovanovic.tech/blog/mapping-between-layers-clean-architecture)
- [Organizing Use Cases in Clean Architecture](https://milanjovanovic.tech/blog/organize-use-cases-clean-architecture)

## CQRS and MediatR

The CQRS pattern is a natural complement to Clean Architecture. It separates read and write operations, keeping your use cases focused and testable.

- [CQRS Pattern with MediatR](https://milanjovanovic.tech/blog/cqrs-pattern-with-mediatr)
- [CQRS Pattern: The Way It Should Have Been From the Start](https://milanjovanovic.tech/blog/cqrs-pattern-the-way-it-should-have-been-from-the-start)
- [Stop Conflating CQRS and MediatR](https://milanjovanovic.tech/blog/stop-conflating-cqrs-and-mediatr)
- [CQRS Validation with MediatR Pipeline and FluentValidation](https://milanjovanovic.tech/blog/cqrs-validation-with-mediatr-pipeline-and-fluentvalidation)
- [MediatR Pipeline Behaviors in .NET](https://milanjovanovic.tech/blog/mediatr-pipeline-behaviors)

## Cross-Cutting Concerns

Clean Architecture gives cross-cutting concerns a clear home instead of letting them leak across layers. These guides cover concerns that appear in many production applications.

- [Exception Handling in Clean Architecture](https://milanjovanovic.tech/blog/exception-handling-clean-architecture)
- [Logging Strategy in Clean Architecture](https://milanjovanovic.tech/blog/logging-strategy-clean-architecture)
- [Authentication and Authorization in Clean Architecture](https://milanjovanovic.tech/blog/authentication-authorization-clean-architecture)
- [Caching in Clean Architecture](https://milanjovanovic.tech/blog/caching-clean-architecture)
- [Background Jobs in Clean Architecture](https://milanjovanovic.tech/blog/background-jobs-clean-architecture)
- [Transactions in Clean Architecture](https://milanjovanovic.tech/blog/transactions-clean-architecture)

## Testing

A well-structured Clean Architecture solution is inherently testable. These guides cover testing strategies at different levels.

- [Unit Testing Clean Architecture Use Cases](https://milanjovanovic.tech/blog/unit-testing-clean-architecture-use-cases)
- [Enforcing Software Architecture with Architecture Tests](https://milanjovanovic.tech/blog/enforcing-software-architecture-with-architecture-tests)
- [5 Architecture Tests You Should Add to Your .NET Projects](https://milanjovanovic.tech/blog/5-architecture-tests-you-should-add-to-your-dotnet-projects)

## Domain-Driven Design

Clean Architecture provides the structure, and DDD provides the modeling techniques. These articles cover the DDD fundamentals you'll use inside the Domain layer.

- [Value Objects in .NET: DDD Fundamentals](https://milanjovanovic.tech/blog/value-objects-in-dotnet-ddd-fundamentals)
- [How to Use Domain Events to Build Loosely Coupled Systems](https://milanjovanovic.tech/blog/how-to-use-domain-events-to-build-loosely-coupled-systems)
- [Refactoring From an Anemic Domain Model to a Rich Domain Model](https://milanjovanovic.tech/blog/refactoring-from-an-anemic-domain-model-to-a-rich-domain-model)
- [From Transaction Scripts to Domain Models: A Refactoring Journey](https://milanjovanovic.tech/blog/from-transaction-scripts-to-domain-models-a-refactoring-journey)

## Related Architectures

Clean Architecture isn't the only option. These complementary approaches can be used alongside it or as alternatives depending on your project's needs.

- [Vertical Slice Architecture](https://milanjovanovic.tech/blog/vertical-slice-architecture)
- [What Is a Modular Monolith?](https://milanjovanovic.tech/blog/what-is-a-modular-monolith)
- [Screaming Architecture](https://milanjovanovic.tech/blog/screaming-architecture)

## Summary

Clean Architecture organizes a .NET solution into Domain, Application, Infrastructure, and Presentation layers, with dependencies pointing only inward.
The structure pays off in long-lived applications with real business rules; for prototypes and simple CRUD systems, the extra projects and abstractions can cost more than the independence they provide.
Start with the fundamentals, work through the layers, then add CQRS, cross-cutting concerns, and architecture tests as your system grows.

## Frequently asked questions

### What are the layers of Clean Architecture in .NET?

A typical .NET solution has Domain, Application, Infrastructure, and Presentation layers. Domain owns business rules, Application coordinates use cases, Infrastructure implements external integrations, and Presentation translates transport input and output.

### What is the dependency rule in Clean Architecture?

Source-code dependencies point inward. Domain depends on no outer layer, Application can depend on Domain, and Infrastructure and Presentation depend on abstractions owned by the inner layers. The runtime call direction can differ; the compile-time dependency direction may not.

### Does Clean Architecture require CQRS or MediatR?

No. CQRS and MediatR can help organize use cases and cross-cutting behavior, but neither defines Clean Architecture. You can use application services or your own command and query handler interfaces while preserving the same dependency boundaries.

### How many projects should a Clean Architecture solution have?

Use enough projects to enforce meaningful dependency boundaries, commonly four for Domain, Application, Infrastructure, and the API. A small application can combine outer layers or begin as one feature-oriented project and extract boundaries when the complexity justifies them.

### When is Clean Architecture a poor fit?

It is usually a poor fit for prototypes, short-lived applications, and simple CRUD systems with little business logic. In those cases the extra projects, mapping, and abstractions can cost more than the independence they provide.
