Hexagonal architecture diagram is an architectural pattern used in software design aiming at creating loosely coupled application components. It is one of the many forms of DDD (Domain Driven Design Architecture). The hexagonal architecture was invented by Alistair Cockburn in 2005 in an attempt to avoid known structural pitfalls in object-oriented software design, such as undesired dependencies between layers and contamination of user interface code with business logic. This approach is an alternative to the traditional layered architecture.

The hexagonal architecture divides a system into several loosely-coupled interchangeable components by means of exposed ports and adapters and each component is connected to the others through these ports follow a given protocol depending on their purpose. This makes components exchangeable at any level and facilitates test automation.

Hexagonal architecture diagram

Edit this Diagram

As shown in the figure above, an application can be considered as a whole is seen as a hexagon, with the business domain located inside. The application opens specific ports for establishing communication channels to and from the application code. It isolates the domain logic from the infrastructure, such as the database, message bus, mail delivery, and/ or the webserver. It can be extended to support different types of clients easily. Just add a new adapter to it. Thus, the hexagonal architecture is a natural fit for Domain-Driven Design (DDD).

Core

  • The place where the business logic of the application happens is defined
  • It receives data, performs operations on it, and optionally may communicate with other external parties like databases or persistence entities.

Ports

  • It represents the boundaries of the application.

Adapter

  • It can be implemented as interfaces to be used by outside parties.