Architecturefeature foldersfeature slicesshared kernel

Vertical slice architecture

Definition

Vertical slice architecture groups all code for one request or feature into a single slice, maximising coupling within a slice and minimising it between slices.

In practice

Feature changes are the most common kind, and in a slice they stay inside one folder instead of touching shared controller, service and repository classes. Each slice can choose its own data access, an ORM for commands and raw SQL for a heavy query, which pairs naturally with CQRS.

Shared domain rules and infrastructure still need a deliberate home, often a small shared kernel; otherwise rules get duplicated and drift. Slices calling other slices recreate hidden coupling. Some duplication between slices is acceptable and cheaper than the wrong abstraction.

Example

Features/CancelOrder/ holds CancelOrderEndpoint, CancelOrderRequest, CancelOrderValidator and CancelOrderHandler; changing cancellation rules touches only that folder.