20 practical guides

Clean Architecture Guides for .NET

Start with the dependency rule and the responsibilities of each layer. Then work through the decisions a real .NET application needs: organizing use cases, handling transactions, adding authentication, and keeping infrastructure out of the domain model.

Start here

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.

Read the complete guide →

Explore Clean Architecture

Browse all .NET guides →
  • Clean Architecture

    Background Jobs in Clean Architecture

    Where do background jobs fit in Clean Architecture? Treat them as entry points, exactly like controllers. The job schedules and triggers, the application layer does the work. Here is the structure, the scoped-service wiring that trips everyone up, and complete examples with BackgroundService and Quartz.

    • aspnetcore
    • background-jobs
    • clean-architecture
    Read the guide →
  • Clean Architecture

    Clean Architecture With Minimal APIs in .NET

    Minimal API endpoints and Clean Architecture are a natural fit: the endpoint receives HTTP, dispatches a command, and maps the result back. No business logic, no controllers, no ceremony. Here is how to organize endpoints by feature, validate with endpoint filters, and return consistent Problem Details.

    • aspnetcore
    • clean-architecture
    • dotnet
    Read the guide →
  • Clean Architecture

    Dependency Rule in Clean Architecture Explained

    Source code dependencies must only point inward. That one sentence decides your project references, where your interfaces live, and why the DI container sits at the edge. Here is how the Dependency Rule works, how control can flow outward while dependencies point inward, and how to enforce it with the compiler and architecture tests.

    • clean-architecture
    • dotnet
    • software-architecture
    Read the guide →
  • Clean Architecture

    Domain Events vs Integration Events in .NET

    A domain event is handled in-process, inside the same transaction. An integration event crosses service boundaries through a message broker and needs the outbox pattern to survive a crash. Confusing the two leads to lost events and accidental coupling. Here is where the line sits, with implementation patterns for both sides.

    • clean-architecture
    • ddd
    • distributed-systems
    Read the guide →
  • Clean Architecture

    Exception Handling Strategy in Clean Architecture

    Expected failures are not exceptional, so stop throwing them. A clear strategy gives each layer one job: the domain throws on invariant violations, the application returns typed Results, and a single global handler maps everything else to Problem Details. Here is how the pieces fit together in a .NET Clean Architecture.

    • clean-architecture
    • dotnet
    • software-architecture
    Read the guide →
  • Clean Architecture

    How to Organize Use Cases in Clean Architecture

    A folder structure that works at 5 use cases falls apart at 200. Group by feature, keep one use case per folder, and name with verb-noun domain language, and your Application layer reads like a list of things the system can do. Here are the three layouts you will encounter, and why only one of them scales.

    • clean-architecture
    • dotnet
    • software-architecture
    Read the guide →
  • Clean Architecture

    Logging Strategy in Clean Architecture

    One pipeline behavior can log every use case with timing and failures, so handlers stay clean and the domain never sees an ILogger. Here is a layer-by-layer logging strategy for Clean Architecture: domain events instead of logs in the domain, behaviors in the application, direct logging in infrastructure, and middleware at the edge.

    • clean-architecture
    • dotnet
    • observability
    Read the guide →
  • Clean Architecture

    Mapping Between Layers in Clean Architecture

    Request to command, command to entity, entity to response: a single operation can pass through three mappings, and most of them are ceremony. EF Core projections eliminate the read-side mapping entirely, and simple extension methods handle the rest. Here is when mapping between layers earns its keep, and why you rarely need AutoMapper.

    • clean-architecture
    • design-patterns
    • dotnet
    Read the guide →
  • Clean Architecture

    The Application Layer in Clean Architecture

    The Application layer is where your use cases live: commands, queries, and the handlers that orchestrate your domain objects. A good handler reads like a table of contents (load, act, save). Here is how to structure the layer in .NET and keep business logic from leaking into it.

    • clean-architecture
    • cqrs
    • dotnet
    Read the guide →
  • Clean Architecture

    The Domain Layer in Clean Architecture

    Every business rule in your system should have exactly one home: the Domain layer. That means entities that guard their invariants, value objects instead of raw primitives, and domain events for side effects. Here is what belongs in the Domain layer, what does not, and how to keep it at zero external dependencies.

    • clean-architecture
    • ddd
    • dotnet
    Read the guide →
  • Clean Architecture

    The Infrastructure Layer in Clean Architecture

    Databases, message brokers, email providers, caches: everything that talks to the outside world lives in the Infrastructure layer. It implements the interfaces your inner layers define, and it is the only place EF Core should ever appear. Here is how to structure it in .NET, from repositories and the DbContext to a clean DI registration module.

    • clean-architecture
    • dotnet
    • ef-core
    Read the guide →
  • Clean Architecture

    When to Use Clean Architecture (And When Not To)

    A five-endpoint CRUD API with four projects, domain events, and a CQRS pipeline is over-engineering, not discipline. Clean Architecture pays off on complex domains, long-lived codebases, and multi-team projects. Here is a decision framework for spotting which one you have, and a migration path for when you guess wrong.

    • clean-architecture
    • dotnet
    • software-architecture
    Read the guide →
  • Clean Architecture

    Where Does Caching Belong in Clean Architecture?

    Caching is infrastructure, but the decision to cache is application-level. Get that split wrong and cache concerns leak into your use cases, or worse, into your domain. Here are two clean approaches: a decorator over your repositories and a pipeline behavior driven by the use case itself.

    • caching
    • clean-architecture
    • dotnet
    Read the guide →