Vertical slice architecture
Organizing code by feature, with everything one use case needs (API, logic, data access and often UI) together, instead of by technical layer.
A layered codebase has folders for controllers, services and repositories, so adding one feature touches every layer and every layer is shared by everyone. A vertical slice keeps one use case, such as “book a visit” or “cancel a visit”, in one place, from the request handler to the query. Jimmy Bogard popularized the term: minimize coupling between slices, maximize it inside a slice.
Slices make ownership and migration easier: a team can own a set of slices, and a migration can move one slice at a time from a monolith into a new codebase, API and web front end together. Shared code still exists, but it has to earn its place. The approach fits a modular monolith, where slices are grouped by bounded context.
Sources
- Jimmy Bogard: Vertical Slice Architecture jimmybogard.com
Related terms
- Modular monolith: One deployable application split inside into modules with clear boundaries, each owning its data and using the others only through defined interfaces.
- Hexagonal architecture (ports and adapters): Business logic in the middle defines interfaces (ports); databases, APIs and user interfaces plug in from outside as adapters.
- Code ownership (CODEOWNERS): Every part of a codebase has a named team responsible for it, often enforced by a CODEOWNERS file that requests that team’s review on every change.
- Bounded context: A part of a system where each business term has one meaning and one model, with explicit translation at its edges.
