Skip to content
HexagonalPortsAdapters

Hexagonal Architecture

Ports and adapters are a rule about the direction of dependencies. The domain does not know HTTP, SQL, or the message broker.

Personal experience

At Armirene the documented choice was clean architecture for an ecommerce platform. Hexagonal architecture is the same dependency rule under a different name: domain in the center, infrastructure at the rim.

Technical perspective

A port is an interface the domain owns. An adapter is an implementation the infrastructure owns. If the domain imports Eloquent, Laravel, Redis, or HTTP types, there is no hexagon. There is a framework application with a folder named domain.

The payoff appears at the edges: a payment provider, a new storefront, a worker that consumes the same use case as a controller. Without ports, each edge copies the use case. With ports, the use case stays put.

The cost is indirection. For a three-table admin tool, it is not worth it. For an ecommerce platform that will outlive its first payment provider, it is.

Architecture

Domain in the center

HTTP adapter

Worker adapter

Use cases

Domain

Persistence adapter

Payment adapter

Technical perspective, aligned with clean architecture used on the Armirene ecommerce platform.