Tutorials Clean Architecture & DDD Mastery

Hexagonal Architecture (Ports and Adapters)

On this page

Ports and Adapters

Alistair Cockburn's Hexagonal Architecture teaches us that our application is a 'Hexagon' with many sides, each interacting with the outside world via Ports.

1. Ports (The Interfaces)

A Port is a hole in the Hexagon. It's an interface that defines "I need to send an email" or "I need to save a record". The Hexagon doesn't care who is on the other side.

2. Adapters (The Implementations)

An Adapter plugs into a Port. You can have a SendGridAdapter for production and a MockEmailAdapter for testing. You can have a RestApiAdapter for users and a CliAdapter for developers. The internal logic (the Hexagon) stays exactly the same.

3. Architect Insight

Q: "Is Hexagonal different from Clean Architecture?"

Architect Answer: "They are 90% the same. They both share the same goal: Decoupling. Clean Architecture is slightly more prescriptive about the internal 'layers', while Hexagonal focuses more on the 'Boundary' between the app and the outside world. If you understand one, you understand the other."

Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

Clean Architecture & DDD Mastery
Course syllabus
1. Architectural Patterns
2. Domain-Driven Design (DDD) Foundations
3. Advanced DDD Patterns
4. Implementing the Clean Layers
5. Patterns for Data & Logic
6. Enterprise Domain Challenges
7. Testing Clean Architecture
8. Real-World Case Study
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details