Onion Architecture
ELI5 — The Vibe Check
Onion architecture arranges code in concentric layers like an onion. The core (domain) has no dependencies. Each outer layer depends inward, never outward. Your business logic never knows about databases or web frameworks — like the inner layers of an onion never see sunlight.
Real Talk
An architectural pattern (by Jeffrey Palermo) where the domain model is at the center, surrounded by domain services, application services, and infrastructure layers. Dependencies always point inward — outer layers depend on inner layers, never the reverse. This ensures the domain remains independent of infrastructure concerns.
When You'll Hear This
"In onion architecture, the domain layer has zero dependency on Entity Framework or any ORM." / "The infrastructure ring at the outside implements interfaces defined in the inner rings."
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...
Dependency Inversion
Dependency Inversion says high-level code shouldn't depend on low-level code — both should depend on abstractions.
Hexagonal Architecture
Hexagonal Architecture (aka Ports and Adapters) treats your app like a USB hub.
Ports and Adapters
Ports and Adapters (aka Hexagonal Architecture) means your app defines 'ports' (interfaces) and the outside world connects through 'adapters.