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
- High cohesion within a feature. Everything needed to change
Orderis in one folder. - Low coupling between features.
Orderdoesn't know aboutPayment's internals. - Independent evolution. Two teams own different slices; merge conflicts are rare.
- Onboarding-friendly. "Where is order placement code?" -> one folder.
- Cheap deletion. Removing a feature is
rm -rf order/, not archaeology.
The concept notes
- Vertical Slice — what lives inside one slice.
- Slice Boundaries — coupling between slices, shared code rules.
- VSA vs Layered Architecture — side-by-side comparison.
- VSA + DDD — slice often equals bounded context.
When VSA shines
- Medium-to-large codebases with multiple independent features.
- Multiple teams or contributors working on different parts.
- You expect features to come and go.
When VSA is overkill
- Single-developer CRUD app.
- Codebase under ~10 features. Layered is fine — and faster to set up.
- Features overlap so heavily that "slice" boundaries are arbitrary.
What VSA is not
- Not a microservices architecture. Slices can ship in one monolith (modular monolith).
- Not feature-flag-driven development. Slices are physical code structure; flags are runtime.
- Not anti-DRY. Shared code lives in a small
shared/kernel. The trade-off is conscious.
Two failure modes
- Slices that import each other's domain. VSA in folder shape only; layered coupling underneath.
- Layered slice. A slice folder with
entities/,services/,repositories/inside — that's nested layered architecture.
A practical starting point
- Identify your bounded contexts (often: 3-10 in a non-trivial system).
- Make each one a slice.
- Inside each slice, use hexagonal layering (domain / application / infrastructure / presentation).
- Communication between slices: events for reactions, IDs for references.
- Small shared kernel for true cross-cutting types (Money, IDs, Clock).