EMZETT.
Login

Hexagonal architecture

In short: In hexagonal architecture (ports and adapters) the business logic sits at the core. Database, web interface and external services attach through replaceable adapters.

In more detail: The core only knows interfaces (ports). Concrete technology (HTTP, SQL, queue) is implemented in adapters. Dependencies always point inward. That way the core can be tested without a database and technology is easily swapped.

In Depth

  • Inbound ports: What the application offers (use cases).
  • Outbound ports: What it needs (repository, mail sending).
  • Adapters: REST controller, SQL repository, test doubles.
  • Dependency inversion: The core defines interfaces, the outside implements them.
  • Related: Clean architecture, onion architecture.
  • Price: More interfaces and code. Worthwhile for long-lived business logic.

See also: Domain-driven design, Strangler fig pattern and migration