Skip to main content

Command Palette

Search for a command to run...

Vertical Slice Architecture vs Clean Architecture in .NET: Which Should Your Team Use in 2026?

Updated
โ€ข11 min read
Vertical Slice Architecture vs Clean Architecture in .NET: Which Should Your Team Use in 2026?

Every .NET team hits this inflection point eventually: the codebase is growing, new developers are joining, and the architecture that felt clean six months ago is starting to feel like a maze. Two approaches dominate the discussion in 2026 โ€” Vertical Slice Architecture and Clean Architecture โ€” and they represent genuinely different philosophies about how production .NET systems should be organised. If you are evaluating them for a new project or a refactor, the patterns explored here go deeper on Patreon โ€” with annotated, production-ready source code that maps directly to what enterprise teams actually ship.

Clean Architecture, popularised by Robert Martin, organises code by technical concerns: a domain layer, an application layer, an infrastructure layer, and an API layer. Dependencies flow inward, the domain has zero infrastructure dependencies, and the result is a codebase that is deliberately insulated from framework and data access details. Understanding how these layers fit together inside a complete production API โ€” including where validation, caching, and background jobs sit โ€” is exactly what Chapter 11 of the Zero to Production course covers, with a real codebase you can run from day one.

Vertical Slice Architecture takes the opposite view. Instead of organising by technical layer, it organises by feature. Every operation โ€” a command, a query, an endpoint โ€” lives in its own self-contained slice that owns its handler, its data access, its validation, and its response type. There is no shared Application layer bridging all features; each slice handles its own concerns.

How Does Clean Architecture Structure a .NET Solution?

Clean Architecture divides a .NET solution into four concentric rings. The innermost ring โ€” the Domain project โ€” contains entities, domain events, value objects, and repository interfaces. No NuGet packages, no Entity Framework references, nothing but pure C#. The Application project orchestrates use cases using commands and queries (typically with MediatR), calls repository interfaces, and defines service contracts. Infrastructure implements those contracts: EF Core DbContexts, external HTTP clients, storage providers. The API project wires everything together and exposes HTTP endpoints.

The key rule is the dependency constraint: outer layers may depend on inner layers, never the reverse. Infrastructure depends on Application and Domain. Application depends on Domain. Domain depends on nothing.

This produces a codebase that is easy to reason about at scale. A developer new to the team can open the Application project and understand every use case the system supports just by looking at the command and query classes. Testing is straightforward: handlers are pure classes with injected abstractions, making unit tests fast and focused.

The cost is ceremony. A single feature โ€” say, creating a product โ€” requires a command class, a validator, a handler, a repository interface, an EF Core repository implementation, and a controller or endpoint. For teams shipping CRUD-heavy APIs or moving fast on greenfield products, this overhead can feel disproportionate.

How Does Vertical Slice Architecture Structure a .NET Solution?

Vertical Slice Architecture collapses those four layers into a flat Features folder. Each feature gets its own subdirectory โ€” Features/Products/CreateProduct, for example โ€” and everything needed for that operation lives there: the request type, the handler, the EF Core query, the response type, and the FluentValidation validator.

Features share nothing by default. If two features need the same database query, they each write their own. If they need the same response shape, they each define their own DTO. The philosophy is that duplication is preferable to premature abstraction: shared code creates hidden coupling that becomes a liability when requirements diverge.

Cross-cutting concerns โ€” logging, validation, exception handling, authentication โ€” are handled at the infrastructure and middleware level, not through shared service classes. MediatR pipeline behaviours handle validation and logging uniformly across all handlers. The slice itself focuses purely on the business logic.

Side-by-Side Comparison

Dimension Clean Architecture Vertical Slice Architecture
Primary organising principle Technical layer (Domain / App / Infra / API) Feature / use case
Coupling Low coupling via abstractions and interfaces Low coupling via slice isolation
Code sharing Encouraged through Application layer Actively discouraged between slices
Ceremony per feature High โ€” multiple classes across multiple projects Low โ€” all classes in one folder
Navigability Easy to find all use cases in Application layer Easy to find all logic for one feature
Testing Unit tests on handlers; integration tests on API Same โ€” handlers are still testable in isolation
Scaling to large teams Structured layers reduce merge conflicts across concerns Feature ownership boundaries reduce merge conflicts between teams
Framework coupling Domain and Application explicitly avoid framework dependencies Slices may reference EF Core and ASP.NET Core directly
Onboarding Familiar pattern with strong community documentation Less familiar; requires deliberate team conventions
Best fit Domain-rich systems, long-lived enterprise products Feature-driven products, CRUD-heavy APIs, fast-moving teams

When Should Your Team Use Clean Architecture?

Clean Architecture earns its overhead when the domain is complex and long-lived. If your application contains non-trivial business rules โ€” pricing engines, workflow state machines, compliance logic โ€” separating that logic from infrastructure dependencies is worth the ceremony. When the domain model changes, you want those changes contained inside the Domain and Application layers, not scattered across infrastructure and endpoint code.

Clean Architecture also shines when the team is large and multiple developers work on different features simultaneously. Because the structure is standardised, every developer knows exactly where to look and where to add new code. The pattern is also better documented: the community around it is deep, templates are mature, and new hires familiar with .NET are likely to recognise the structure immediately.

Choose Clean Architecture when:

  • Your domain contains complex business rules that need protection from infrastructure details
  • You expect the application to live for five or more years with evolving requirements
  • You need to swap infrastructure concerns (databases, message brokers, external APIs) without touching business logic
  • Team size is large enough that consistent structure outweighs individual productivity overhead
  • You want strong testability guarantees at the unit level without mocking infrastructure

When Should Your Team Use Vertical Slice Architecture?

Vertical Slice Architecture delivers its value when speed and feature autonomy matter more than structural purity. In SaaS products where features ship weekly and requirements change before the domain model is stable, the overhead of Clean Architecture layers creates friction without proportional benefit. A team that can own a feature end-to-end โ€” from handler to database query โ€” without navigating four projects ships faster.

The architecture also maps well to team topology. When one developer owns the Orders feature and another owns the Products feature, slice isolation prevents accidental coupling. Their work lives in different folders, changes rarely conflict, and the boundaries are clear without requiring a formal domain layer to enforce them.

Where Vertical Slice Architecture struggles is on shared business logic. If a rule โ€” say, that a product cannot be archived while it has open orders โ€” must be enforced consistently across multiple features, a slice-first approach has no canonical home for that rule. Teams typically solve this with a Shared or Common folder, but that folder can accumulate responsibilities quickly and begin to resemble an informal Application layer. At that point, Clean Architecture's explicit structure becomes attractive again.

Choose Vertical Slice Architecture when:

  • The application is feature-driven and CRUD-heavy with limited cross-feature business rules
  • The team moves fast and feature ownership is clearly divided
  • You want minimal abstraction overhead for junior developers to stay productive
  • The application is small-to-medium in scope and not expected to have a complex domain
  • You are building microservices where each service is small enough that full Clean Architecture layers would be disproportionate

Is There a Middle Ground?

Yes โ€” and most experienced .NET teams land here. Clean Architecture and Vertical Slice Architecture are not mutually exclusive. A pragmatic pattern is to use Clean Architecture's layer boundaries for the outer scaffolding (API, Infrastructure, Application, Domain projects) while organising the Application layer by feature using a Features folder structure that mirrors vertical slices. Commands and queries live in feature folders inside the Application layer. The Domain layer still contains rich domain logic. Infrastructure still implements interfaces.

This hybrid approach gives you:

  • Feature-based navigability inside the Application layer
  • Proper domain isolation without coupling business logic to EF Core
  • Predictable structure for large teams
  • The flexibility to write different features differently when the requirements call for it

The Zero to Production course demonstrates this hybrid approach in practice โ€” the Application layer is organised by feature, the Domain layer enforces the core rules, and the API layer stays thin.

The Recommendation

For most enterprise .NET teams in 2026: start with Clean Architecture if your domain is non-trivial and the team is more than three developers. The structure pays off quickly in onboarding, testability, and long-term maintainability. Use Vertical Slice Architecture for greenfield microservices, small internal tools, or when the product is genuinely feature-driven with a shallow domain.

If you are mid-project and suffering from both extremes โ€” Clean Architecture with too much ceremony, or a growing slice codebase where the Shared folder has become a second application layer โ€” consider a hybrid. Reorganise the Application layer by feature folder, keep the Domain layer clean, and resist the temptation to add more layers for their own sake.

The goal of architecture is not to follow a pattern. It is to make the system easier to understand, change, and test than it would be without it. Both approaches can achieve that goal; the difference is in which constraints your system genuinely needs.

โ˜• Prefer a one-time tip? Buy us a coffee โ€” every bit helps keep the content coming!

Frequently Asked Questions

What is the main difference between Vertical Slice Architecture and Clean Architecture in .NET?

Clean Architecture organises code by technical concern โ€” Domain, Application, Infrastructure, API layers with inward dependency flow. Vertical Slice Architecture organises code by feature, where each operation owns its handler, data access, and validation in one folder. Clean Architecture prioritises layer isolation; Vertical Slice prioritises feature autonomy.

Can I use MediatR with Vertical Slice Architecture?

Yes, MediatR is one of the most common tools paired with Vertical Slice Architecture in .NET. Each feature's command or query becomes a MediatR request, and the handler for that request lives in the same feature folder. Pipeline behaviours handle cross-cutting concerns like validation and logging uniformly without each slice needing to implement them individually.

Does Vertical Slice Architecture cause code duplication?

It can, by design. The philosophy is that duplication between slices is preferable to creating shared abstractions too early. In practice, teams draw the line differently: pure infrastructure concerns (logging, authentication, exception handling) are always shared, while business logic and data access queries are intentionally duplicated per slice unless a genuine reuse case emerges.

Which architecture is better for large enterprise .NET systems?

Clean Architecture is generally better for large enterprise systems with complex domains, long lifespans, and teams larger than five developers. Its explicit layer boundaries enforce separation of concerns at scale and provide a shared vocabulary that survives team changes and re-platforming. Vertical Slice Architecture works well within bounded contexts of a larger system, particularly in microservices where each service is deliberately small.

How does Vertical Slice Architecture handle cross-cutting concerns like validation and error handling?

Cross-cutting concerns in Vertical Slice Architecture are handled at the infrastructure level rather than within slices. In practice, MediatR pipeline behaviours apply validation (via FluentValidation) and logging uniformly to all handlers. Global exception handling middleware catches and maps exceptions to Problem Details responses. Authentication and authorisation are enforced at the middleware and endpoint level. Individual slices stay focused on business logic only.

Should I migrate an existing Clean Architecture project to Vertical Slice Architecture?

Rarely โ€” migration cost is high and the benefit depends on what problem you are actually solving. If the issue is too much ceremony, reorganise the Application layer by feature folder without changing the project structure. If the issue is that Clean Architecture layers feel artificial because the domain is shallow, consider a simpler layered approach rather than a full migration. A full migration makes most sense for microservices being extracted from a monolith where a fresh start is practical.

How does Vertical Slice Architecture interact with EF Core in ASP.NET Core?

In Vertical Slice Architecture, each slice can access the EF Core DbContext directly through the injected context. Because slices are isolated, there is no shared repository layer. Some teams add a lightweight generic repository or query helper to reduce DbContext verbosity, but the key principle is that each slice owns its data access logic. This is a deliberate departure from the repository pattern that Clean Architecture typically uses.

More from this blog

C

Coding Droplets

170 posts