Ports and adapters, drawn as the shape the pattern is named after.
Hexagonal architecture, or ports and adapters, puts domain logic at the centre and pushes every external dependency to an adapter at the edge. The diagram is worth drawing because the pattern's whole claim is about which direction dependencies point, and that is exactly what prose obscures.
When to use these
Showing that domain logic has no dependency on infrastructure.
Onboarding onto a codebase organised this way, where the folder structure alone will not explain it.
Arguing for or against a dependency that wants to reach into the core.
When not to
A service that is genuinely a thin CRUD wrapper. The ceremony costs more than it returns.
Common mistakes
The usual failure is an adapter that has leaked domain logic into it, or a port defined in terms of the technology behind it rather than what the domain needs. If your port is called `UserRepository` and has a `findBySqlQuery` method, the dependency is pointing the wrong way.
Every template here ships in Gnomon and renders on your machine, with no account and nothing sent to a server. The browser editor is free and needs no install.