Skip to content
StackDecode
System Design
3. Client-Server ArchitectureAnimated

Onion Architecture

Domain at the centre with layers wrapped around it.

The idea

Like clean architecture: domain model in the middle, then domain services, application services, and infrastructure outside.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

InfrastructureApplication ser…Domain servicesDomain model
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Layers wrap the domain model like an onion.

step:
1/4
at:
Domain model
1/9

The green dot is a request moving through the system.

Step by step

  1. 1Place the domain model in the core
  2. 2Wrap it in domain and application services
  3. 3Keep infrastructure on the outside
  4. 4Depend only inward

Where it is used

Domain-heavy systems.

Watch out for

Needs discipline to keep infrastructure out of the core.

Related