All glossary terms
Design

Ports and adapters

Ports and adapters (also called hexagonal architecture) is the design pattern that surrounds a core domain model with a layer of ports (interfaces describing what the core needs) and adapters (concrete implementations of those interfaces for specific external systems). The core never depends on adapters; adapters implement the ports the core defines.

The pattern was named by Alistair Cockburn around 2005. The benefit is testability and external-system replaceability: the core domain logic is tested with in-memory adapters; switching from one database to another or one message broker to another is an adapter swap, not a core rewrite. The trade-off is layer proliferation — small applications don't benefit, but applications with many external integrations (databases, message brokers, APIs, file systems) benefit substantially. Hexagonal is sometimes confused with clean architecture and onion architecture; the three are variations on the same dependency-inversion idea with slightly different emphases.

Related terms