Hexagonal architecture
The hexagonal architecture, also known as the ports and adapters architecture, aims to address the problem of coupling between the core business logic and external dependencies, such as databases, UIs, and external systems.
The hexagonal architecture was introduced by Alistair Cockburn in his paper, Hexagonal Architecture, published in 2005.
The two fundamental concepts of this architectural style are ports and adapters. Ports define the interactions between the internal and the external worlds, and adapters provide the implementation details of these interactions.
The concept of hexagonal architecture is visualized in Figure 7.3 as a hexagon. It is worth noting that this architecture allows as many sides as possible, not limited to only six as the name hexagon suggests.
Figure 7.3 – An example of the hexagonal architecture
We will cover each element of the hexagonal architecture in the following sections.