What is hexagonal architecture (ports and adapters), and what fundamentally separates onion/clean from layered?
Short answer
Hexagonal puts the domain/application in the center and talks to the outside through ports (interfaces the core defines) and adapters (implementations at the edge). Unlike layered, dependencies point inward: the domain knows nothing about the DB or framework.
3 points to say:
- Port = an interface the core defines; adapter = an implementation at the edge (REST controller, Kafka consumer, JPA repository, HTTP client).
- Inbound ports (driving) are the use cases the core offers; outbound ports (driven) are what the core needs (save orders, send mail).
- Dependencies point inward; pure logic in the core, I/O in the shell (functional core, imperative shell).
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.