---
published: true
id: ports-and-adapters
title: Ports and Adapters
description: Knowledge captured in João Lopes' learning graph.
tags:
- architecture
- hexagonal
- ddd
- functional
locale: en
resource: https://joaolopes.dev.br/knowledge/concepts/en/ports-and-adapters/
created: '2026-03-24'
---

# Ports and Adapters
An architecture where the domain core defines abstract boundaries (ports) and all external dependencies plug in through concrete implementations (adapters), also known as Hexagonal Architecture.

## Definition
In Ports and Adapters, the domain core is pure — data in, data out, no I/O. A port is the boundary where certainty ends and uncertainty begins: filesystem, HTTP, database, time. Adapters implement ports with real infrastructure. The domain never imports an adapter; the adapter always imports the domain. This dependency direction is the constraint that matters most — when it holds, the domain is testable without mocks and portable across infrastructure. Enforcement is the hard part: tools like eslint-plugin-boundaries and clj-depend can check it mechanically.

## Source
- [Hexagonal Architecture — Alistair Cockburn](https://alistair.cockburn.us/hexagonal-architecture)
- [Hexagonal Architecture (Software) — Wikipedia](https://en.wikipedia.org/wiki/Hexagonal_architecture_(software))

## Related
- [Linter](/concepts/en/linter.md)
