Design Patterns (GoF) (50 Qs)•Part 2: Behavioral Patterns & Communication (11 - 24)
What is Hexagonal Architecture (Ports and Adapters)?
senior LevelSystem DesignBehavioral
In Simple Words: Created by Alistair Cockburn:
- The core application resides inside a hexagon, isolated from the outside world:
- Ports: Inward-facing application interfaces (e.g.
OrderRepositoryPort,PaymentProcessorPort). - Adapters: Outward-facing concrete implementations that plug into ports:
- Driving Adapters: Initiate calls to the app (REST API controller, CLI, GraphQL resolver).
- Driven Adapters: Invoked by the app (PostgresOrderAdapter, StripePaymentAdapter).
- Ports: Inward-facing application interfaces (e.g.
- Allows running the entire application with mock in-memory adapters for instant unit testing!