Combining Vertical Slices With CQRS in .NET
CQRS and Vertical Slice Architecture are a natural pair. Commands and queries are already separate, so putting each in its own slice makes them independent and easy to optimize.
11 practical guides
Organize .NET code around the features it delivers. Start with the complete guide, then explore feature folders, CQRS, and the REPR pattern. Learn how validation, testing, and shared concerns fit into a project as its feature count grows.
Start here
Vertical Slice Architecture organizes code around behavior. Learn slice boundaries, validation, testing, and how VSA works with CQRS and Clean Architecture.
Read the complete guide →CQRS and Vertical Slice Architecture are a natural pair. Commands and queries are already separate, so putting each in its own slice makes them independent and easy to optimize.
One criticism of Vertical Slice Architecture is code duplication across slices. Here is how to handle cross-cutting concerns like validation, logging, and caching without breaking feature isolation.
Feature folders organize code by feature instead of by technical concern (Controllers, Services, Models), so everything related to placing an order lives in one folder. Here is how to implement them in .NET.
Vertical slices change the shape of your tests. Instead of repository, service, and controller tests held together by mocks, you test one feature at a time: validators in microseconds, handlers in isolation, and the full slice from HTTP to database with WebApplicationFactory and Testcontainers.
In Vertical Slice Architecture, validation belongs in the slice. Co-locate validators with features and use a pipeline behavior to run them automatically.
A concrete folder and solution layout for Vertical Slice Architecture in .NET, and how it evolves as you grow from 5 features to 50+.
Clean Architecture manages complexity through layer discipline. Vertical Slice Architecture manages it through feature isolation. Rich shared domain logic points to Clean Architecture, and features that vary widely in complexity point to vertical slices. Here is how the two compare, and the hybrid most real projects land on.
Carter turns Minimal API endpoints into self-registering modules: each feature defines its routes, and app.MapCarter() wires them up at startup. Combined with Vertical Slice Architecture, every feature owns its endpoint, handler, and validator in one folder. Here is the full setup, from installation to integration tests.
In a layered architecture, a query that returns one object touches seven types across four layers. That structure pays off when many features share business logic, and it is overhead when they do not. Here are the concrete signals that tell you when Vertical Slice Architecture is the better fit for your .NET project, and when layers still win.
Vertical Slice Architecture organizes code around behavior. Learn slice boundaries, validation, testing, and how VSA works with CQRS and Clean Architecture.
The REPR pattern (Request-Endpoint-Response) replaces bloated controllers with focused, single-purpose endpoints. Here is how to implement it in ASP.NET Core with Minimal APIs.