What's Hexagonal Architecture?

Luis Soares
4 min readApr 25, 2023

The Hexagonal Architecture, also known as Ports and Adapters or the Onion Architecture, was introduced by Alistair Cockburn in the early 2000s as an architectural pattern to create maintainable, adaptable, and easily testable applications.

It is a layered approach that helps decouple an application's core business logic from its dependencies and external concerns.

Components of the Hexagonal Architecture

The Hexagonal Architecture revolves around three primary components:

Domain Model

At the centre of the architecture is the Domain Model, which represents the application's core business logic and entities. It is responsible for implementing the main functionality and rules that the application is built around. The Domain Model should be independent of external concerns such as databases, UI frameworks, or other dependencies.

Ports

Ports are the interfaces that define the communication points between the application's core logic and the external world. They can be divided into two categories:

  • Primary or Driving Ports: These ports define the operations that the application exposes to external actors. They represent the use cases or application services that external systems or users initiate—for example, an API…

--

--

Luis Soares

Lead Software Engineer | Blockchain & ZKP Protocol Engineer | 🦀 Rust | Web3 | Solidity | Golang | Cryptography | Author