Onion architecture
Onion architecture organises code in concentric layers from the domain model at the centre outward through application services, domain services, and infrastructure at the edge. Dependencies point inward only — infrastructure depends on application; application depends on domain; domain depends on nothing. The pattern enforces dependency inversion through structure.
Jeffrey Palermo introduced onion architecture around 2008. It's closely related to hexagonal and clean architecture — all three enforce inward dependency through the same mechanism. The differences are presentational: onion emphasises the concentric-circle visualisation; hexagonal emphasises ports and adapters; clean emphasises layers explicitly. In practice teams pick one vocabulary and stick with it. The benefit is uniformity: a new engineer can find the domain logic (centre), the application services (next ring), and the database code (outer ring) by structure alone, without reading every file.
Related terms
- Clean architecture
Clean architecture, presented by Robert C.
- Hexagonal architecture
Hexagonal architecture (also called ports and adapters), introduced by Alistair Cockburn in 2005, structures an application so the core domain logic depends only on abstract 'ports' — and concrete adapters (web framework, database, message bus) plug into those ports from outside.
- Ports and adapters
Ports and adapters (also called hexagonal architecture) is the design pattern that surrounds a core domain model with a layer of ports (interfaces describing what the core needs) and adapters (concrete implementations of those interfaces for specific external systems).