Hexagonal architecture
Hexagonal architecture is a software architecture pattern that isolates an application's core logic behind ports and connects external systems through adapters.
Clean Applications with Hexagonal Architecture
An application design pattern that isolates the application core behind ports and connects external technologies through adapters.
- How it is used
- Contains infrastructure coupling and change propagation in applications with evolving interfaces, persistence, or integrations.
- How deep it goes
- Traces request flow through core-owned ports and adapters, then details incremental migration, boundary testing, and trade-offs.
- Examples
- Uses an article-creation handler, REST and Kafka adapters, repository implementations, and a layered-to-hexagonal migration.
- What you can do after
- Build a framework-free core, connect adapters, and enforce its boundaries with architectural tests.
Read how Clean Applications with Hexagonal Architecture explains hexagonal architecture →
Grokking Software Architecture
An architectural pattern that isolates the application core from external systems through ports and adapters.
- How it is used
- Uses the pattern to protect business logic from changing external technologies and support isolated testing.
- How deep it goes
- Explains core, ports, adapters, dependency direction, implementation, and tradeoffs with a worked monitoring example.
- Examples
- Contrasts a Twilio-coupled server monitor with swappable alert adapters and a fake used in a unit test.
- What you can do after
- Apply it to define core-facing ports, connect adapters, and test business logic without external infrastructure.
Read how Grokking Software Architecture explains hexagonal architecture →
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 domain logic from API formatting, data access, and a gRPC client in service designs.
- How deep it goes
- Works through domain types, response conversion, and a client wrapper, while keeping domain logic in the handlers package for a small service.
- Examples
- Uses game creation and status responses alongside a habits client that lists habits and retrieves weekly status.
- What you can do after
- Apply the pattern to separate service responsibilities and test adapters using domain values and 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 →
Acing the Frontend Interview
Hexagonal Architecture isolates domain logic behind inbound and outbound ports that are connected to external systems through adapters.
- How it is used
- Applies separation of concerns during monolith refactoring and service-integration design.
- How deep it goes
- Explains boundaries, interfaces, testability, and migration rationale, but does not detail port implementations.
- Examples
- Uses monolith refactoring, a user-management domain diagram, feature flags, routing fallbacks, and independently tested layers.
- What you can do after
- Apply it during monolith refactoring by defining interfaces, isolating business logic, and replacing infrastructure adapters safely.
Read how Acing the Frontend Interview explains hexagonal architecture →
Microservices Patterns, Second Edition
Hexagonal architecture is an architectural pattern that isolates application and domain logic from external systems through ports and adapters.
- How it is used
- Structures application logic so adapters connect it to user interfaces, infrastructure, and external systems.
- How deep it goes
- Defines inbound and outbound ports and adapters, their responsibilities, and the direction of dependency.
- Examples
- Uses FTGO food ordering, web and REST interfaces, database access, and payment and messaging services.
- What you can do after
- Understand how to assign responsibilities to ports and adapters and keep business logic independent of adapters.
Read how Microservices Patterns, Second Edition 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
- Uses domain ports and infrastructure adapters to organize a multi-module RSS application around stable boundaries.
- How deep it goes
- Explains dependency direction and works through an RSS adapter’s type conversion and compile-time interface check.
- Examples
- Uses a Fetcher interface, an RSSReader backed by gofeed, and a mock fetcher returning predetermined data.
- What you can do after
- Apply it by defining domain interfaces, implementing adapters, and checking Go interface satisfaction at compile time.
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 →
Effective Behavior-Driven Development
Hexagonal architecture is a software architecture pattern that isolates core application logic from external systems through ports and adapters.
- How it is used
- Structures BDD automation applications to keep core business logic distinct from external dependencies and support multiple interfaces.
- How deep it goes
- Defines ports, adapters, inbound and outbound connections, and stub-based testing, while leaving detailed treatment aside.
- Examples
- Uses a payment port with a Stripe adapter, UI and message-broker inputs, database and web-service dependencies, and test stubs.
- What you can do after
- Apply it by defining ports for core needs, mapping adapters to external services, and replacing service adapters with stubs in tests.
Read how Effective Behavior-Driven Development explains hexagonal architecture →
Also covered in
- Grokking Simplicity
- 100 Go Mistakes and How to Avoid Them
- The Art of Code
- Secure APIs
- F# in Action: A Revised Edition of Get Programming with F#
What to know first
- business logicBusiness logic is the domain-specific rules, computations, and decisions that determine how a software system processes operations and behaves.
- contractA contract is an agreed specification of the conditions, expectations, rights, or obligations that govern behavior or interactions between parties or software components.
- interfaceAn interface is a contract or boundary that specifies the operations, members, or data shape a type or component exposes, without prescribing its complete implementation.
- adapterAn adapter is a software component that translates between interfaces or representations so otherwise incompatible components can work together.
Related concepts
- layered architecturecontrasts with · Layered architecture is a software organization pattern that separates responsibilities into ordered layers with defined roles and constrained dependencies, typically from higher-level layers to lower-level ones.
- functional programmingincludes · 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 point of connection through which a system or component communicates with another system, service, or component.
- adapterhas part · An adapter is a software component that translates between interfaces or representations so otherwise incompatible components can work together.
- domain layerhas part · A domain layer is the architectural part of an application that contains its domain concepts, business rules, and behavior, distinct from infrastructure and delivery concerns.
- architectural stylekind of · An architectural pattern is a reusable high-level organization of software components, interactions, and constraints for addressing recurring system-design concerns.
Questions about hexagonal architecture
What is hexagonal architecture?
Hexagonal architecture is a software architecture pattern that isolates an application's core logic behind ports and connects external systems through adapters.
Which Manning books explain hexagonal architecture?
Clean Applications with Hexagonal Architecture, Grokking Software Architecture, AI-Powered Developer: Build software with ChatGPT and Copilot, Learn Go with Pocket-Sized Projects, Unit Testing Principles, Practices, and Patterns, Acing the Frontend Interview, Microservices Patterns, Second Edition, Go in Action, Second Edition and 3 more.
What should I know before learning hexagonal architecture?
Manning books that teach hexagonal architecture usually introduce business logic, contract, interface and adapter first.
What is the difference between hexagonal architecture and layered architecture?
Hexagonal architecture is a software architecture pattern that isolates an application's core logic behind ports and connects external systems through adapters. Layered architecture is a software organization pattern that separates responsibilities into ordered layers with defined roles and constrained dependencies, typically from higher-level layers to lower-level ones.
What kinds of hexagonal architecture are there?
Kinds of hexagonal architecture include functional programming.
What is hexagonal architecture a kind of?
Hexagonal architecture is a kind of architectural style. An architectural pattern is a reusable high-level organization of software components, interactions, and constraints for addressing recurring system-design concerns.
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.










