All glossary terms
Design

Hexagonal architecture

Hexagonal architecture (also called ports and adapters), introduced by Alistair Cockburn in 2005, structures an application so the core domain logic depends only on abstract 'ports' — and concrete adapters (web framework, database, message bus) plug into those ports from outside. The result: the core can be tested without infrastructure, and adapters can be swapped without touching the core.

The metaphor is a hexagon (any number of sides works; six was a drawing convenience) with ports on each side: inbound ports for receiving requests (HTTP, CLI, message queue), outbound ports for invoking dependencies (database, external API, file system). The benefit isn't theoretical — it shows up the day someone wants to add a CLI to a web-only service, or migrate from one database to another, and discovers it's a week's work instead of a quarter's. Hexagonal, clean, and onion architectures are siblings — same principle (domain core depends on nothing infrastructural), slightly different vocabularies.

Related terms