SteelReed

Search

Search posts, questions…

OOP & DesignQuestion 36 / 42

Middle

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.

implementsREST controllerdriving adapterInbound port: use caseDomain, applicationOutbound port: interfaceJPA, Kafka adapter

3 points to say:

  1. Port = an interface the core defines; adapter = an implementation at the edge (REST controller, Kafka consumer, JPA repository, HTTP client).
  2. Inbound ports (driving) are the use cases the core offers; outbound ports (driven) are what the core needs (save orders, send mail).
  3. 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.