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

Hexagonal Architecture

The core logic is isolated from the outside by ports and adapters.

The idea

The domain core defines ports (interfaces); adapters connect them to databases, UIs and external systems.

Watch it work

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

Web adapterTest adapterDomain coreRepo adapterMail adapter
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

The domain core has no knowledge of web, database or email.

step:
1/4
at:
Domain core
1/7

The green dot is a request moving through the system.

Step by step

  1. 1Define the core domain logic
  2. 2Declare ports for what it needs
  3. 3Write adapters for web, database and queue
  4. 4Swap adapters in tests

Where it is used

Applications that must be testable and technology-independent.

Watch out for

More files and indirection for small apps.

Related