Skip to main content

Hexagonal layering

Reference shape, taken from auth and repeated in social, feed, expense, media, messaging, and notification:

LayerPackageAllowed to do
APIapi.controller, api.request, api.responseHTTP, Bean Validation, map to a use-case command
Applicationapplication.usecase, application.portTransactions, orchestration, call ports
DomaindomainRules and types. No Spring, no JDBC, no HTTP
InfrastructureinfrastructureJPA, Redis, HTTP adapters that implement ports

Controllers do not call repositories. A use case that needs another service depends on a port interface; the adapter lives in infrastructure.

Communication-service skips a domain package because it is a delivery adapter with little invariant logic. Do not copy that shortcut into a context that owns money or identity rules.

GlobalExceptionHandler in shared-web maps domain errors to the shared error body, including traceId.