Hexagonal Architecture Guide
March 18, 2026 · View on GitHub
Hexagonal Architecture (also known as Ports & Adapters) organizes code so that business logic is at the center, isolated from all external concerns. The core application communicates with the outside world only through well-defined interfaces (ports), and concrete implementations (adapters) plug into those interfaces.
Table of Contents
- Core Principles
- Directory Structure
- The Domain Layer
- Ports — Defining Contracts
- Adapters — Implementing Contracts
- The Application Layer (Use Cases)
- Handlers — Primary Adapters
- Dependency Injection & Wiring
- Cross-Cutting Concerns with the Decorator Pattern
- Error Handling Strategy
- Configuration Management
- Testing Strategy
- Dependency Flow Rules