Authentication is infrastructure and authorization is a business rule. Mixing the two up pulls ASP.NET Core into your domain. Here is where JWT validation, the ICurrentUserService abstraction, permission checks, and ownership rules each live, and how to keep them enforced beyond HTTP endpoints.
- clean-architecture
- dotnet
- security
Background jobs in Clean Architecture are entry points, exactly like controllers. The job only 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
Setting up a Clean Architecture project from scratch takes time. Here is a .NET solution template with the project structure, references, and configuration already in place.
- clean-architecture
- dotnet
- software-architecture
Clean Architecture, Onion Architecture, and Hexagonal Architecture all solve the same problem: decoupling business logic from infrastructure. They differ in structure, naming, and emphasis. Here is a practical comparison to help you choose.
- clean-architecture
- dotnet
- software-architecture
Minimal API endpoints and Clean Architecture are a natural fit: the endpoint receives HTTP, dispatches a command, and maps the result back, with no business logic of its own. Here is how to organize endpoints by feature, validate with endpoint filters, and return consistent Problem Details.
- aspnetcore
- clean-architecture
- dotnet
Source code dependencies must only point inward. That rule determines your project references, where you define interfaces, and why the DI container is configured in the outermost project. 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
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
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
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
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
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
MediatR pipeline behaviors let you handle logging, validation, caching, and transactions without touching your handlers. Here is a practical IPipelineBehavior implementation for each one.
- clean-architecture
- csharp
- dotnet
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
Every business rule in your system belongs in the Domain layer and nowhere else. 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
Databases, message brokers, email providers, caches: everything that talks to the outside world belongs 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 DI registration.
- clean-architecture
- dotnet
- ef-core
A five-endpoint CRUD API with four projects, domain events, and a CQRS pipeline is over-engineering. 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
The use case defines what must succeed or fail together, so the transaction boundary belongs to the application layer. Here are three ways to implement that in .NET, ranked: a single SaveChanges as the implicit boundary, an explicit transaction abstraction, and a transaction pipeline behavior.
- clean-architecture
- dotnet
- ef-core
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
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.
- clean-architecture
- dotnet
- software-architecture
Clean Architecture is easy to get wrong. Here are the most common anti-patterns and mistakes I see in .NET projects, and how to fix them.
- clean-architecture
- dotnet
- software-architecture