Hexagonal architecture
Hexagonal architecture is a software architecture pattern that isolates an application’s core logic from external systems through ports and adapters.
AI-Powered Developer: Build software with ChatGPT and Copilot
Hexagonal architecture is an architectural pattern that isolates an application’s core business logic from external systems through ports and adapters.
- How it is used
- Separates an IT asset management domain from REST and persistence integrations while documenting the resulting design.
- How deep it goes
- Defines domain models, primary and secondary ports, and adapters, then applies them in a Python project layout without implementation internals.
- Examples
- Uses an IT asset management system with Hardware, FastAPI, SQLAlchemy, Mermaid class diagrams, package structure, and tests.
- What you can do after
- Evaluate/understand how ports and adapters let external databases, screens, and services change without changing core business logic.
Learn Go with Pocket-Sized Projects
Hexagonal architecture is a software architecture pattern that isolates core application logic from external systems through defined interfaces.
- How it is used
- Separates service logic from HTTP, storage, and gRPC concerns through domain types and adapter boundaries.
- How deep it goes
- Works through package boundaries and conversions, but leaves the small game service short of fully independent layers.
- Examples
- Uses a game service’s session-to-HTTP conversion and a habits service’s protobuf-to-domain client wrapper.
- What you can do after
- Apply it in Go by defining domain-facing types, isolating transport conversions, and testing adapters with mocks.
Read how Learn Go with Pocket-Sized Projects explains hexagonal architecture →
Unit Testing Principles, Practices, and Patterns
An architectural pattern that separates domain logic from application services and connects external applications through ports or common interfaces.
- How it is used
- Structures applications so domain logic stays central while application services orchestrate use cases and external communication.
- How deep it goes
- Defines two layers, dependency direction, and interface boundaries, then demonstrates them through a purchase orchestration example.
- Examples
- Uses user renaming, customer purchasing, repositories, a store interface, and an email gateway as concrete artifacts.
- What you can do after
- Evaluate application boundaries and diagnose fragile tests by distinguishing external behavior from internal communication.
Read how Unit Testing Principles, Practices, and Patterns explains hexagonal architecture →
Go in Action, Second Edition
Ports and Adapters is an architectural pattern that isolates core application logic behind interfaces and connects those interfaces to external implementations.
- How it is used
- Separates a news application's domain logic from RSS, storage, and service infrastructure.
- How deep it goes
- Defines ports and adapters, then works through an RSS adapter's type conversion and compile-time interface check.
- Examples
- Illustrates a gofeed-backed RSS reader, domain feed and article types, and a worker that fetches and stores articles.
- What you can do after
- Build it from scratch by defining domain ports, implementing an RSS adapter, and wiring a worker through interfaces.
Read how Go in Action, Second Edition explains hexagonal architecture →
gRPC Microservices in Go
Hexagonal architecture is an architectural pattern that isolates application business logic behind ports and connects external actors and dependencies through adapters.
- How it is used
- Structures Go microservices around an isolated business-logic core connected to callers and dependencies through ports and adapters.
- How deep it goes
- Defines the pattern and its components, then works through project folders and a Go application core with an injected database port.
- Examples
- Uses a Go order service whose PlaceOrder method saves an Order through DBPort, alongside gRPC adapter and project-folder examples.
- What you can do after
- Build it from scratch by defining the application core and port contracts, then injecting concrete adapters into outer layers.
Read how gRPC Microservices in Go explains hexagonal architecture →
The Art of Unit Testing 3e
An architectural pattern that isolates application logic behind ports and connects it to external systems through replaceable adapters.
- How it is used
- Protects application code and tests from breaking changes in third-party dependencies by routing them through controlled abstractions.
- How deep it goes
- Explains the dependency-boundary rationale and demonstrates injection, but stops short of a broader architectural implementation.
- Examples
- Uses moment.js around password verification and Winston logging as concrete cases for adapters and dependency isolation.
- What you can do after
- Build it from scratch by placing replaceable dependencies behind small internal APIs and injecting fakes at test boundaries.
Read how The Art of Unit Testing 3e explains hexagonal architecture →
Related concepts
- functional, stateless philosophyincludes · Functional programming is a programming paradigm that expresses computation through the evaluation and composition of functions, typically favoring immutable data and minimizing mutable state and side effects.
- portuses · A port is a defined interface or endpoint through which a system communicates with another component, service, or external capability.
- adapteruses · The adapter pattern is a structural design pattern in which a component translates between interfaces or representations so otherwise incompatible components can work together.
- domain layerhas part · A domain layer is an architectural part of an application that contains its domain concepts, rules, and behavior.
- model architecturekind of · The structural organization of a computational system’s components, relationships, and operations that determines how it processes information or behaves.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.





