Vertical Slice Architecture
ELI5 — The Vibe Check
Vertical slice architecture organizes code by feature, not by layer. Instead of all controllers in one folder and all services in another, each feature (like 'CreateOrder') has its own slice with everything it needs. It's like organizing by project, not by skill.
Real Talk
An architectural approach where code is organized around features/use cases rather than technical layers. Each 'slice' contains all the code needed for a specific operation — from the API endpoint through business logic to data access. This minimizes coupling between features while maximizing cohesion within each slice.
Show Me The Code
// Vertical slice: everything for one feature together
// features/create-order/
// create-order.controller.ts
// create-order.handler.ts
// create-order.validator.ts
// create-order.repository.ts
// create-order.test.ts
When You'll Hear This
"Vertical slice architecture means you can add a new feature without touching any existing code." / "Organizing by feature slice makes it easy to understand and modify one feature in isolation."
Related Terms
Clean Architecture
Clean Architecture is like an onion with strict rules: the inner layers (your core business logic) have absolutely no idea the outer layers (databases, API...
CQRS
CQRS says: the way you write data and the way you read data should be separate systems. Writing (commands) goes to one model optimized for transactions.
Feature Flag
A Feature Flag is an on/off switch for a feature in your app, controlled without redeploying. You ship the code but keep the feature hidden behind a flag.
Screaming Architecture
Screaming architecture means your folder structure screams what the app DOES, not what framework it uses.