VSA Overview

VSA Overview

Vertical Slice Architecture (VSA) organises code by business capability, not by technical layer. Each feature lives in its own folder containing everything it needs: domain, application, infrastructure, presentation.

Adding a feature = adding a slice

src/
  order/              <- slice
    domain/
    application/
    infrastructure/
    presentation/

  payment/            <- another slice
    domain/
    application/
    infrastructure/
    presentation/

  shipping/           <- another slice
    ...

Compare to a layered structure where adding Order means touching domain/orders/, services/orders/, repositories/orders/, controllers/orders/ — five folders for one feature.

Why slice vertically

The concept notes

When VSA shines

When VSA is overkill

What VSA is not

Two failure modes

  1. Slices that import each other's domain. VSA in folder shape only; layered coupling underneath.
  2. Layered slice. A slice folder with entities/, services/, repositories/ inside — that's nested layered architecture.

A practical starting point

  1. Identify your bounded contexts (often: 3-10 in a non-trivial system).
  2. Make each one a slice.
  3. Inside each slice, use hexagonal layering (domain / application / infrastructure / presentation).
  4. Communication between slices: events for reactions, IDs for references.
  5. Small shared kernel for true cross-cutting types (Money, IDs, Clock).