ARCHITECTURE

Is Clean Architecture Making Your .NET Application More Complicated?

Explore when Clean Architecture adds unnecessary complexity to .NET applications, how to recognize overengineering, and when simpler alternatives work better.

24 min readBurak Emre Kadan
All posts
Clean Architecture in .NET showing how excessive layers can increase software complexity.

The ticket says: add GET /api/products/{id}. Read one product, return it as JSON, return 404 if it doesn't exist. You could explain it to a new hire in one sentence.

Then you open the solution. To follow the conventions, you add an endpoint, a GetProductByIdQuery, a handler, and a validator for a query whose only field is an int. The handler calls an IProductService. The service calls an IProductRepository, which extends IRepository<T>, implemented by Repository<T>, which wraps the DbContext. A mapping profile turns the entity into a ProductDto, another turns that into a ProductResponse, and you register the new pieces in two DependencyInjection.cs files across four projects.

Twelve files for one database read. None of them has a bug. Most of them don't do anything.

To be clear, this is an illustrative example of overengineering, not a requirement of Clean Architecture. Nothing in Robert C. Martin's description of the style asks for MediatR, generic repositories, AutoMapper, or a project per layer. But the shape is common enough that many developers treat "Clean Architecture .NET" and "twelve files per endpoint" as the same thing.

So: is Clean Architecture helping us build maintainable .NET applications, or are we creating complexity in its name? The principles usually pay for themselves. The conventions piled on top often don't. The useful skill is telling them apart.

What Clean Architecture Actually Promises

Clean Architecture keeps the code that changes for business reasons apart from the code that changes for technical reasons. Martin's original article describes concentric circles: entities in the middle, then use cases, interface adapters, and frameworks and drivers on the outside.

The promises are specific. A rule like "an order can't be cancelled after it ships" shouldn't care whether the request came from a Minimal API or a scheduled job. Databases and third-party APIs plug into the core as details, replaceable without rewriting the policies that use them. Rules that don't depend on infrastructure can be tested without it. The payoff is a system that stays cheap to change over years.

The Dependency Rule, stated precisely

The core of the style is one sentence from Martin's article: source code dependencies can only point inwards. Code in an inner circle must not name anything declared in an outer one.

This is about source-code dependencies, not runtime flow. At runtime, a use case may well end up writing to SQL Server or calling a payment provider. It just can't reference them at compile time. The usual technique is dependency inversion: the inner layer declares an interface for what it needs, and the outer layer implements it.

Source-code dependencies (what references what at compile time)

  Api ─────────────────► Application ─────────────► Domain
   │                          ▲
   │ composition root only    │ implements IPaymentGateway
   ▼                          │
  Infrastructure ─────────────┘
  (EF Core, HTTP clients, message brokers)

Runtime call flow for one request (what calls what)

  HTTP ─► Api ─► Application ─► IPaymentGateway ─► Infrastructure ─► payment provider

Control flows outward to the database and the payment provider. Compile-time knowledge flows inward toward the business rules. That asymmetry is the whole trick.

Architecture boundaries are not project boundaries

Martin calls the circles schematic and says you may need more or fewer of them. The style describes logical boundaries. It doesn't say each circle must be a .csproj.

Separate projects let the compiler enforce a boundary, but they add build time, scattered DI registration, and public surface. One project with clear namespaces, internal types, and an architecture test that fails when the domain references EF Core can enforce the same rule. Microsoft's ASP.NET Core architecture guide presents the multi-project layout as a common implementation, not the definition.

With complex business logic, all of this pays off. Trouble starts when machinery built to protect complex rules gets applied to code with no rules to protect.

Where Complexity Starts to Grow

Fred Brooks separated essential complexity, which comes from the problem, from accidental complexity, which we add while solving it. A tax engine with forty jurisdictions is essential complexity. A product lookup through five forwarding layers is accidental. Most of the accidental kind comes from five places.

Too many layers for simple operations

A layer earns its place when it makes a decision: it validates, enforces a rule, coordinates a transaction, or translates between models that really differ. A layer that forwards a call unchanged still costs a file to open, a frame in every stack trace, and a place the next developer must check. The typical sign: a handler calling a service calling a repository, each with one line.

Abstractions without real variability

An interface promises that there could be more than one implementation, or that the caller shouldn't know which one it gets. That's valuable when it's true: a payment gateway you might switch, a clock you control in tests, an LLM provider chosen through configuration (as with IChatClient).

An IProductMapper that mirrors one ProductMapper forever protects nothing. It doubles the files and makes "Go to Definition" land on a signature. Add interfaces at real boundaries, for real variation, or for slow and non-deterministic dependencies you replace in tests. "Every class gets an interface so we can mock it" usually ends in tests that verify mocks.

Generic repositories over EF Core

EF Core already covers much of what Repository and Unit of Work describe: DbSet<T> is a collection-like view of a table, and DbContext tracks changes and commits them with SaveChangesAsync. Microsoft's guide on designing the persistence layer says DbContext implements both patterns, under a heading that reads "Repositories shouldn't be mandatory."

A generic IRepository<T> on top usually hides the useful parts: Include, projections, AsNoTracking. Every non-trivial query then either leaks an IQueryable<T> or adds a method to the "generic" repository.

Specific repositories are different. They're worth it when they enforce aggregate boundaries (an IOrderRepository that only loads whole Order aggregates), encapsulate complex persistence (raw SQL, multiple stores, concurrency handling), keep EF Core out of a domain project, or provide a test seam, which the EF Core docs on testing without your production database call the recommended technique. The real question is whether this repository protects something or just renames DbSet<T>.

CQRS and MediatR everywhere

CQRS is a design approach: separate models for reading and writing, from read-optimized projections at the light end to separate data stores at the heavy end. Martin Fowler's CQRS article warns that for most systems it adds risky complexity.

MediatR is a library that dispatches request objects to in-process handlers. The two are independent. A read endpoint that projects into a DTO and a write endpoint that loads an aggregate already separate reads from writes, no mediator needed. And if GetProductByIdQuery and UpdateProductCommand load the same entity through the same repository, you have MediatR without meaningful CQRS.

The mediator also turns a direct call into a runtime lookup, so "Go to Definition" on sender.Send(query) lands in MediatR, not your handler. Pipeline behaviors can earn that cost, but endpoint filters and middleware cover many of the same concerns. It's also a licensing decision: MediatR moved to a commercial license in 2025, with a free community tier for smaller organizations.

Mapping between too many models

One concept can have a domain entity, a persistence model, an application DTO, and an API contract. Some separation matters: returning an EF Core entity exposes internal fields (PurchaseCost has no place in a public response), couples clients to your schema, and invites over-posting.

But when the DTO and the response have the same five properties, mapping is duplication. Every new field touches three classes, and a missed property doesn't fail at compile time. Keep as many models as there are real differences in shape or audience, not as many as there are layers.

A Realistic .NET Example: The Same Feature, Two Approaches

Here's the product lookup written two ways, with .NET 10, EF Core 10, and Minimal APIs. Both versions were built and exercised against SQLite while preparing this article. The shared model:

public sealed class Product
{
    public int Id { get; private set; }
    public required string Sku { get; init; }
    public required string Name { get; set; }
    public decimal Price { get; private set; }
    public decimal PurchaseCost { get; set; }   // internal data: never part of the public API
    public bool IsActive { get; set; } = true;
    public int CategoryId { get; set; }
    public Category Category { get; set; } = null!;
}

public sealed class CatalogDbContext(DbContextOptions<CatalogDbContext> options) : DbContext(options)
{
    public DbSet<Product> Products => Set<Product>();
    public DbSet<Category> Categories => Set<Category>();
}

Approach A: layered and overengineered

A trimmed version of the twelve-file flow. The comments show where each piece usually lives.

// Api/Endpoints/ProductEndpoints.cs
app.MapGet("/api/products/{id:int}", async (int id, ISender sender, CancellationToken ct) =>
{
    var product = await sender.Send(new GetProductByIdQuery(id), ct);
    return product is null ? Results.NotFound() : Results.Ok(product);
});

// Application/Products/Queries/GetProductById/GetProductByIdQuery.cs
public sealed record GetProductByIdQuery(int Id) : IRequest<ProductResponse?>;

// Application/Products/Queries/GetProductById/GetProductByIdQueryHandler.cs
public sealed class GetProductByIdQueryHandler(IProductService productService)
    : IRequestHandler<GetProductByIdQuery, ProductResponse?>
{
    public Task<ProductResponse?> Handle(GetProductByIdQuery request, CancellationToken cancellationToken)
        => productService.GetByIdAsync(request.Id, cancellationToken);
}

// Application/Products/ProductService.cs (plus IProductService.cs)
public sealed class ProductService(IProductRepository repository, IProductMapper mapper) : IProductService
{
    public async Task<ProductResponse?> GetByIdAsync(int id, CancellationToken cancellationToken)
    {
        var product = await repository.GetByIdAsync(id, cancellationToken);
        return product is null || !product.IsActive ? null : mapper.ToResponse(product);
    }
}

// Application/Common/Interfaces/IRepository.cs + IProductRepository.cs
public interface IRepository<T> where T : class
{
    Task<T?> GetByIdAsync(int id, CancellationToken cancellationToken);
    Task AddAsync(T entity, CancellationToken cancellationToken);
    void Remove(T entity);
}

public interface IProductRepository : IRepository<Product>;

// Infrastructure/Persistence/Repository.cs + ProductRepository.cs
public class Repository<T>(CatalogDbContext db) : IRepository<T> where T : class
{
    protected CatalogDbContext Db { get; } = db;

    public virtual async Task<T?> GetByIdAsync(int id, CancellationToken cancellationToken)
        => await Db.Set<T>().FindAsync([id], cancellationToken);

    public async Task AddAsync(T entity, CancellationToken cancellationToken)
        => await Db.Set<T>().AddAsync(entity, cancellationToken);

    public void Remove(T entity) => Db.Set<T>().Remove(entity);
}

public sealed class ProductRepository(CatalogDbContext db) : Repository<Product>(db), IProductRepository
{
    // FindAsync does not load Category, so the "generic" method gets overridden.
    public override Task<Product?> GetByIdAsync(int id, CancellationToken cancellationToken)
        => Db.Products
            .Include(p => p.Category)
            .SingleOrDefaultAsync(p => p.Id == id, cancellationToken);
}

// Infrastructure/DependencyInjection.cs
services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining<GetProductByIdQuery>());
services.AddScoped<IProductService, ProductService>();
services.AddScoped<IProductRepository, ProductRepository>();
services.AddSingleton<IProductMapper, ProductMapper>();

(ProductResponse, IProductMapper, ProductMapper, and the validator are omitted.)

Nothing here is wrong in isolation, and the cancellation token reaches the database. The problems show up together. Only one line makes a decision: !product.IsActive. The generic repository already failed: the first real query needed Category and had to override the "generic" method. The query loads a full, tracked Product, including PurchaseCost, only to discard most of it in the mapper. And the "query" isn't CQRS; it reads through the same aggregate-loading path a command would.

Approach B: one cohesive feature

The same feature, organized around the feature instead of the layer:

using Catalog.Data;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.EntityFrameworkCore;

namespace Catalog.Features.Products;

public static class GetProduct
{
    public sealed record Response(int Id, string Sku, string Name, decimal Price, string Category);

    public static RouteHandlerBuilder Map(IEndpointRouteBuilder app) =>
        app.MapGet("/{id:int}", Handle).WithName("GetProduct");

    public static async Task<Results<Ok<Response>, NotFound>> Handle(
        int id,
        CatalogDbContext db,
        CancellationToken cancellationToken)
    {
        var product = await db.Products
            .AsNoTracking()
            .Where(p => p.Id == id && p.IsActive)
            .Select(p => new Response(p.Id, p.Sku, p.Name, p.Price, p.Category.Name))
            .SingleOrDefaultAsync(cancellationToken);

        return product is null
            ? TypedResults.NotFound()
            : TypedResults.Ok(product);
    }
}

It's mapped from a route group, with the DbContext registered once:

// Features/Products/ProductEndpoints.cs
public static class ProductEndpoints
{
    public static IEndpointRouteBuilder MapProductEndpoints(this IEndpointRouteBuilder app)
    {
        var products = app.MapGroup("/api/products").WithTags("Products");

        GetProduct.Map(products);
        ChangeProductPrice.Map(products);   // shown later in this article

        return app;
    }
}

// Program.cs
builder.Services.AddDbContext<CatalogDbContext>(options =>
    options.UseSqlite(builder.Configuration.GetConnectionString("Catalog")));

app.MapProductEndpoints();

The details matter. The projection is the mapping: EF Core selects only the columns Response needs, so PurchaseCost never leaves the database. Since the query returns no entity types, it wouldn't be tracked anyway (see tracking vs. no-tracking queries). AsNoTracking is technically redundant, but it marks this as a read path and stays correct if someone later returns the entity. Results<Ok<Response>, NotFound> puts the outcomes in the signature, checked by the compiler and picked up by OpenAPI (Minimal API responses). AddDbContext registers the context as scoped, one per request (more in the post on DbContext lifetimes). And Handle is public, so a test can call it with a real CatalogDbContext.

Is injecting CatalogDbContext into an endpoint "Clean Architecture"? Under a strict reading, no: the delivery mechanism talks directly to a persistence framework. Under a pragmatic reading, this is a read with no business policy beyond a filter, and the domain model still knows nothing about HTTP. The Dependency Rule protects business rules from infrastructure. Where there are no rules, a direct query is a deliberate trade-off. It becomes a problem when the same shortcut is used for operations that do have rules.

How the two requests flow

Approach A
  GET /api/products/42
    └─► endpoint lambda
         └─► ISender.Send(GetProductByIdQuery)       (runtime handler lookup)
              └─► GetProductByIdQueryHandler
                   └─► IProductService ─► ProductService
                        └─► IProductRepository ─► ProductRepository
                             └─► CatalogDbContext   (full, tracked Product + Category)
                        ◄── IProductMapper ─► ProductMapper
    ◄── ProductResponse? ─► Results.Ok / Results.NotFound

Approach B
  GET /api/products/42
    └─► GetProduct.Handle
         └─► CatalogDbContext   (SELECT of the five columns the response needs)
    ◄── Ok<Response> / NotFound

Comparison

Aspect Approach A: layered Approach B: feature-oriented
Conceptual components Endpoint, query, handler, service, repositories, mapper, their interfaces, response, DI One class with a response record and a handler, plus the shared DbContext
Dependency boundaries Compile-time, between projects Logical only; endpoint depends on EF Core
Navigation effort Several files and a runtime mediator lookup One file, top to bottom
Testing approach Unit tests with mocked repository and mapper Integration test with a real database
Change amplification New field touches entity, response, mapper, maybe DTO New field touches the response and the projection
Business rule isolation Strong in principle, but almost no rule to isolate Weak by design; rules move out once they exist
Extensibility Cross-cutting behaviors via mediator pipeline Endpoint filters and middleware; extract a service as logic grows
Main trade-off Pays for structure before it's needed Pays later, and requires noticing when it's needed

For this feature, B is better. A's boundaries start paying off when the feature behind them has rules that change independently of the database.

When Clean Architecture Is Worth the Complexity

Boundaries are worth what they protect. These situations give them something to protect:

  1. Complex business rules and domain invariants. When "an invoice can't be finalized while a line is disputed" must hold for every feature that touches invoices, it belongs in a domain model that can be read and tested without a database.
  2. Long-lived enterprise applications. A system that runs for a decade will outlive its UI framework and database driver. An independent core keeps those migrations local.
  3. Multiple external integrations. Interfaces owned by the application layer keep payment, shipping, and ERP specifics out of business logic, and contain the blast radius of switching vendors.
  4. Multiple delivery mechanisms. A use case triggered by HTTP, a message consumer, and a scheduled job should live in one application service, not three copies.
  5. Large teams with clear ownership. Enforced boundaries turn accidental coupling into a compile error instead of a review comment.
  6. Significant infrastructure changes. Moving databases or adopting messaging is far safer when the changing code sits behind a stable interface.
  7. Domains where isolation and testing are essential. In regulated or high-risk domains, fast, exhaustive tests of business rules justify a lot of indirection.

Team size or lifespan alone isn't on the list for a reason. A large team building a CRUD back office doesn't need aggregate repositories, while a small team building a pricing engine might. What justifies a boundary is what it protects.

When Clean Architecture Becomes Overengineering

The full set of conventions tends to cost more than it returns in small CRUD applications, internal admin tools, early-stage MVPs, simple data APIs, short-lived prototypes, and any application where the "domain layer" would be property bags.

Premature abstractions cost more than typing. They're guesses about future variation, and early guesses are usually wrong. An IRepository<T> designed before the first complex query rarely fits it, and once every feature depends on it, it's expensive to remove. Code with no abstraction is easier to restructure than code with the wrong one.

Starting simple is not the same as starting without structure. It still means features in predictable places, validation at the edge, DTOs instead of entities in responses, and tests for behavior that matters. "Simple" describes the number of moving parts, not the amount of care.

The risks of underengineering

Teams reacting against Clean Architecture can land in the opposite failure: business rules copied between endpoints and drifting apart, a use case split across three SaveChangesAsync calls with no transaction, rules buried in LINQ queries, external calls scattered with no timeout policy, no seams for testing. When the same rule appears in three places, or one feature keeps breaking another, the simple structure has run out. Add the specific boundary that would have prevented that pain, not every layer at once.

Clean Architecture vs Vertical Slice Architecture

Vertical Slice Architecture organizes code around features instead of technical layers. Each slice, such as "get product" or "place order," contains what it needs from endpoint to data access. Jimmy Bogard's article introducing it puts the goal as "Minimize coupling between slices, and maximize coupling in a slice."

The benefits are feature cohesion, locality of change, less navigation, and independent evolution: a simple slice can stay a direct query while a complex one grows a domain model. The costs are real too. Cross-cutting concerns like authorization, validation, and transactions need a consistent home (endpoint filters, middleware) or every slice solves them differently. Shared domain logic must not be copied: when two slices enforce the same invariant, it belongs in the domain model. Testing leans on integration tests per slice, which the EF Core testing guidance supports by recommending tests against your production database system where possible.

The two styles aren't mutually exclusive. Vertical slicing decides how code is organized. The Dependency Rule decides which way dependencies point. You can organize by feature and still keep a domain that knows nothing about EF Core.

Traditional layered organization
  src/
    Catalog.Domain/Entities/Product.cs
    Catalog.Application/Products/Queries/GetProductById/GetProductByIdQuery.cs
    Catalog.Application/Products/Queries/GetProductById/GetProductByIdQueryHandler.cs
    Catalog.Application/Common/Interfaces/IProductRepository.cs
    Catalog.Application/Common/Mappings/ProductMappingProfile.cs
    Catalog.Infrastructure/Persistence/Repositories/ProductRepository.cs
    Catalog.Api/Endpoints/ProductEndpoints.cs

Feature-oriented organization
  src/Catalog.Api/
    Features/Products/GetProduct.cs
    Features/Products/ChangeProductPrice.cs
    Features/Products/ListProducts.cs
    Features/Orders/PlaceOrder.cs
    Data/CatalogDbContext.cs

Hybrid organization
  src/
    Catalog.Domain/                      (no EF Core or ASP.NET Core references)
      Products/Product.cs                (ChangePrice and its invariants)
      Orders/Order.cs                    (aggregate with OrderLines)
    Catalog.Api/
      Features/Products/GetProduct.cs    (direct projection query)
      Features/Products/ChangeProductPrice.cs
      Features/Orders/PlaceOrder/PlaceOrder.cs
      Features/Orders/PlaceOrder/PlaceOrderValidator.cs
      Infrastructure/Persistence/CatalogDbContext.cs
      Infrastructure/Payments/PaymentGatewayClient.cs

Layered organization suits teams that want compile-time enforcement and have domain logic shared by many features. Feature-oriented organization suits applications with mostly independent, simple features. The hybrid fits the common middle: most features are straightforward, a few areas have real rules, and those rules deserve protection without every read going through them.

A Practical Middle Ground for .NET Applications

For most new .NET applications: start with clear boundaries, not maximum abstractions.

Organize by feature. Give each business rule a name and a home, usually a method on the entity that owns the data it protects. When a use case spans several entities or external systems, write a focused service (a CheckoutService, not a thirty-method ProductService). Use dependency injection for infrastructure, lifetimes, and things you replace in tests, not as a reason for every class to have an interface. Query EF Core directly, and add a repository when it enforces an aggregate boundary or hides real persistence complexity. Build a rich domain model only where the domain is rich. Test at the boundary that matches the risk: unit tests for rules, integration tests for slices. In-memory setups like the one in the MCP server testing post are good for fast feedback.

src/
  Catalog.Api/
    Program.cs
    Features/
      Products/
        ProductEndpoints.cs         (route group, maps the slices)
        GetProduct.cs
        ListProducts.cs
        ChangeProductPrice.cs
      Orders/
        PlaceOrder/
          PlaceOrder.cs
          PlaceOrderValidator.cs
          CheckoutService.cs        (spans Order, Inventory, and payment)
    Domain/
      Products/Product.cs           (ChangePrice and its invariants)
      Orders/Order.cs
    Infrastructure/
      Persistence/CatalogDbContext.cs
      Persistence/Configurations/ProductConfiguration.cs
      Payments/IPaymentGateway.cs
      Payments/PaymentGatewayClient.cs
tests/
  Catalog.Domain.Tests/             (fast unit tests for invariants)
  Catalog.Api.Tests/                (integration tests per slice, real database)

The domain is a folder here. If the team later wants the compiler to guarantee it never references EF Core, moving it to its own project is a mechanical change. The option stays open without being paid for on day one.

Extracting business logic as complexity grows

Suppose a new rule arrives: prices must keep at least a 10% margin over purchase cost, and inactive products can't be repriced. The first version often lands in the endpoint:

// Inside a PUT /api/products/{id}/price handler: the rule lives in the endpoint
if (!product.IsActive)
    return TypedResults.ValidationProblem(/* ... */);

if (request.NewPrice < product.PurchaseCost * 1.10m)
    return TypedResults.ValidationProblem(/* ... */);

product.Price = request.NewPrice;
await db.SaveChangesAsync(cancellationToken);

That works until a bulk import, a promotions feature, and an admin screen also change prices, and the rule exists in four places, or only one. The rule protects Product's data, so it belongs on Product:

public sealed class Product
{
    private const decimal MinimumMargin = 0.10m;

    // ...properties as before; Price has a private setter...

    public PriceChangeResult ChangePrice(decimal newPrice)
    {
        if (!IsActive)
            return PriceChangeResult.Rejected("Inactive products cannot be repriced.");

        var minimum = decimal.Round(PurchaseCost * (1 + MinimumMargin), 2);
        if (newPrice < minimum)
            return PriceChangeResult.Rejected($"Price must be at least {minimum} to keep the minimum margin.");

        Price = newPrice;
        return PriceChangeResult.Accepted();
    }
}

public sealed record PriceChangeResult(bool Succeeded, string? Error)
{
    public static PriceChangeResult Accepted() => new(true, null);
    public static PriceChangeResult Rejected(string error) => new(false, error);
}

The endpoint goes back to coordinating: load, ask the domain, translate to HTTP, save.

public static class ChangeProductPrice
{
    public sealed record Request(decimal NewPrice);

    public static RouteHandlerBuilder Map(IEndpointRouteBuilder app) =>
        app.MapPut("/{id:int}/price", Handle);

    public static async Task<Results<NoContent, NotFound, ValidationProblem>> Handle(
        int id,
        Request request,
        CatalogDbContext db,
        CancellationToken cancellationToken)
    {
        var product = await db.Products.SingleOrDefaultAsync(p => p.Id == id, cancellationToken);
        if (product is null)
            return TypedResults.NotFound();

        var result = product.ChangePrice(request.NewPrice);
        if (!result.Succeeded)
            return TypedResults.ValidationProblem(new Dictionary<string, string[]>
            {
                [nameof(Request.NewPrice)] = [result.Error!]
            });

        await db.SaveChangesAsync(cancellationToken);
        return TypedResults.NoContent();
    }
}

With a private setter on Price, no code can bypass the rule, and it can be unit-tested with a plain new Product { ... }. That's the Dependency Rule doing its job in the one place that needed it. If repricing later depends on things outside Product, such as promotions, a competitor price feed, or approvals for large changes, that's when to introduce an application service, and an IPricingPolicy if the policy really varies by market. The boundary arrives with the complexity.

Seven Warning Signs Your Architecture Is Too Complicated

1. A simple feature requires editing many unrelated files. Adding one response field touches the entity, a DTO, a response, two mapping profiles, and a fixture in four projects. Every extra edit slows delivery and is a chance to miss one. It's justified when models really differ, like a separately versioned public contract. Otherwise, collapse same-shaped models and project reads directly into responses.

2. Interfaces exist without meaningful architectural purpose. IFoo/Foo pairs everywhere, never replaced, not even in tests. Navigation lands on signatures, and the code advertises flexibility it doesn't have. Keep interfaces at real boundaries and for real variation. Inline the rest.

3. Services only forward calls to other services. ProductService.GetByIdAsync returns repository.GetByIdAsync. Each pass-through adds reading and debugging cost without a decision. A deliberate seam where logic is expected soon can be fine, if someone checks later whether it arrived. Otherwise, call the next layer directly.

4. Developers struggle to find the actual business logic. Asked where the minimum margin is enforced, the team finds it in a validator, a handler, and a SQL view. Rules that can't be found can't be changed safely, and copies drift. Rules that span services are a rare legitimate case. Give each rule one named home.

5. Simple changes require excessive mapping. Most of a feature is Map calls and mapping tests, and runtime mapping libraries push errors from compile time to runtime. Mapping is justified at real boundaries: public contracts, anti-corruption layers, persistence models that differ from the domain. Elsewhere, use EF Core projections and explicit hand-written mapping.

6. Tests primarily verify mocks and delegation. A handler test mocks a service to return a value, then asserts the handler returned it. Such tests pass when behavior is broken and fail on harmless refactorings. Mocks are justified for external systems, to test how code handles their failures. Unit-test domain rules directly, and integration-test slices against a real database.

7. Architecture rules are followed without understanding their purpose. A validator for GetProductByIdQuery(int Id), or an extra project that exists only to hold DI registrations so Api never references Infrastructure. Rules without reasons can't adapt and turn reviews into compliance debates. Newcomers following conventions before understanding them is normal, as long as someone can explain them. Write down why each rule exists, for example in a short architecture decision record, and treat unjustifiable rules as candidates for removal.

How to Simplify an Existing Clean Architecture Project

Don't delete layers across the codebase in one change. Simplification is a refactoring and needs the same discipline.

  1. Map current execution paths. Trace a few representative requests from endpoint to database and note every type they pass through.
  2. Identify pass-through abstractions. Mark each step as decides (validates, enforces a rule, owns a transaction, translates a real difference) or forwards.
  3. Separate essential boundaries from accidental complexity. An IPaymentGateway around a third-party API is essential even with one implementation. An IProductMapper usually isn't. Ask what would break if the boundary disappeared.
  4. Select one low-risk vertical slice. Read-only features are safest: no transactions, no invariants.
  5. Add characterization tests first. Pin down current behavior at the HTTP level: status codes, response shape, inactive and missing records. Keep the tests even where current behavior looks odd.
  6. Consolidate unnecessary layers. Collapse handler, service, repository, and mapper into one feature handler, keeping the public contract identical so the tests stay green unedited.
  7. Preserve domain invariants and transaction boundaries. If a service wraps three operations in one transaction, or a repository guarantees whole-aggregate loading, that behavior must survive. Move invariants into the domain model rather than dropping them with the layer.
  8. Refactor incrementally. One slice per pull request. Two styles side by side for a while is fine if the direction is documented.
  9. Measure the improvement. Track files touched per typical change, onboarding time for a feature, and tests broken by refactorings that don't change behavior. If those don't improve, rethink before converting more slices.

The goal isn't to remove Clean Architecture. It's to remove the parts that don't pull their weight.

Architecture Decision Checklist

These options overlap: slices can live inside a modular monolith, and pragmatic Clean Architecture is often a hybrid of feature folders and a protected domain. Use the matrix to start a conversation, not as a lookup table.

Factor Simple feature-based Pragmatic Clean Architecture Strict layered Clean Architecture Vertical Slice Architecture Modular monolith
Domain complexity Low Medium to high, in some areas High across the system Varies per slice Varies per module
Team size and ownership One small team One or a few teams Several teams, layer ownership Teams own features Teams own modules
Expected lifetime Short to medium Medium to long Long Medium to long Long
Integration requirements Few Several, behind adapters Many, strictly isolated Per slice Per module, explicit contracts
Change frequency High, independent changes Mixed Lower, deliberate High, feature-local High inside modules, low at contracts
Testability requirements Integration tests suffice Unit tests for domain, integration for slices Extensive isolated unit tests Integration tests per slice Per module plus contract tests
Operational complexity Lowest Low Low to medium Low Medium
Cost of future change Low early, rises if rules spread Moderate, predictable High for small changes, low for infrastructure swaps Low per feature, risk of duplicated rules Low inside modules, high across them

Five questions to ask before adding another abstraction

  1. What specific change will this make easier? Name it. "Flexibility" doesn't count.
  2. Is there a second implementation today, or a concrete reason to expect one?
  3. What business rule or boundary does it protect? "The layer above from the layer below" is a structure, not a reason.
  4. What will a new developer have to read to understand this feature? Is every hop carrying its weight?
  5. How hard is it to add later? If extracting it later is mechanical, there's little reason to pay now.

Final Thoughts

The goal of software architecture is not to maximize the number of layers. It is to make important changes easier and risky changes safer.

Clean Architecture is very good at that when valuable business logic is surrounded by volatile technology. Its central idea, keeping policy independent of delivery and infrastructure, holds up. What often doesn't is the package that grew around it in .NET: a project per layer, an interface per class, a mediator per call, a repository per table, applied the same way to a pricing engine and a product lookup.

Complexity should be justified by something you can name. Boundaries should protect something valuable. Simplicity is an engineering decision, and it takes judgment to maintain. Architecture should evolve with the application, adding boundaries where real complexity appears. Clean Architecture is a tool, not a rulebook.

What's the most unnecessary abstraction you've encountered in a .NET project?

FAQ

Is Clean Architecture overkill for small .NET projects?

The full template often is. The principles still apply: keep business rules out of endpoints and infrastructure at the edges. A single project organized by feature, with a domain folder for the few real rules, gives most of the benefit at a fraction of the cost.

Does Clean Architecture require CQRS and MediatR?

No. Clean Architecture is about dependency direction. CQRS is a separate design approach, and MediatR is an in-process messaging library. You can apply Clean Architecture with plain services and direct calls, and separate reads from writes without a mediator.

Should I use the Repository Pattern with EF Core?

Not by default, and rarely as a generic IRepository<T>, since DbContext and DbSet<T> already provide unit-of-work and repository behavior. Specific repositories are useful when they enforce aggregate boundaries, hide complex persistence, keep EF Core out of a domain project, or give you a database-free test seam.

Is Vertical Slice Architecture better than Clean Architecture?

They answer different questions: vertical slicing is about organizing code by feature, Clean Architecture about which way dependencies point. Many good .NET applications combine them, with feature folders for most code and an infrastructure-free domain model where the rules are complex.

Can I simplify Clean Architecture without losing testability?

Usually you gain it. Removing pass-through layers mostly removes tests that verified delegation to mocks. Real testability comes from business rules in plain classes you can unit-test, plus integration tests that run each slice against a real database.

References

NEWSLETTER

Get the next one in your inbox

Weekly .NET + AI tips, the source code from every video, and early access to the course.

You'll get weekly .NET + AI tips. Unsubscribe anytime.