What is Hexagonal Architecture (Ports & Adapters)?
Hexagonal architecture (also called Ports and Adapters) structures applications so that the core business logic is isolated from external concerns (databases, APIs, UI).
Hexagonal architecture (also called Ports and Adapters) structures applications so that the core business logic is isolated from external concerns (databases, APIs, UI). The core defines "ports" (interfaces) and external concerns implement "adapters" that plug into those ports.
Structure: Core domain (business logic, no dependencies on frameworks or infrastructure), Ports (interfaces defined by the core — what it needs from the outside world), and Adapters (implementations of ports for specific technologies — PostgreSQL adapter, REST adapter, CLI adapter).
Benefits: Testability (test core logic without databases or APIs — just mock the ports), Technology independence (swap databases, APIs, or UI frameworks without changing business logic), and Clear boundaries (forces separation between business rules and infrastructure).
Why It Matters
Hexagonal architecture prevents the most common cause of unmaintainable code: business logic entangled with database queries, API calls, and framework-specific code. Clean boundaries make testing, refactoring, and technology migration dramatically easier.
Frequently Asked Questions
What is hexagonal architecture?
An architecture where core business logic is isolated from external concerns using ports (interfaces) and adapters (implementations). Also called "Ports and Adapters." Enables technology independence.
Hexagonal vs Clean Architecture vs Onion Architecture?
All three are variations of the same core idea: isolate business logic from infrastructure. Hexagonal emphasizes ports/adapters. Clean Architecture adds use cases. Onion Architecture uses concentric layers. The principle is identical.
Related Terms
Need Expert Help?
Richard Ewing is a Product Economist and AI Capital Auditor. He helps companies translate technical complexity into financial clarity.
Book Advisory Call →