Untitled Lesson
Skill Matrix
UNLOCK NODES BY LEARNING NEW TAGS.
What is the distinction between a "driving" port and a "driven" port in Hexagonal Architecture?
💻 Code Challenge | +75 XP
Define a PaymentGateway port interface with a charge() method, implement two adapters (a real StripeAdapter and a FakeAdapter for testing), and show a use case that accepts either interchangeably.
A team wants to test their order-creation use case without needing a real Postgres database running in CI. Reorder the steps to enable this using hexagonal architecture.
Task: Reorder the blocks in logical sequence to solve the problem.
A.D.A. Interface
Adaptive Didactic Assistant

Pascual Vila
Frontend Instructor // Code Syllabus
The Error //
Defining a port interface but having the core import a concrete adapter directly instead of depending on the abstraction
// Wrong: core still coupled to a specific adapter
import { StripeAdapter } from "./adapters/stripe";
class CheckoutUseCase { constructor() { this.gateway = new StripeAdapter(); } }
// Correct: depends on the abstraction, injected from outside
class CheckoutUseCase { constructor(gateway) { this.gateway = gateway; } }The Solution //
If the core imports StripeAdapter directly rather than the PaymentGateway interface it implements, the core is still coupled to Stripe specifically — defeating the purpose of defining the port at all. The core should only ever reference the port interface; the concrete adapter is injected from outside.
The Error //
Applying hexagonal architecture to an entire existing large service in one big-bang restructure
// Risky: restructuring everything at once
// Better: start with one complex, high-value bounded area
// e.g. src/core/payments/ + src/adapters/{stripe,paypal}/The Solution //
A full-codebase restructure is high-risk and slow to deliver value — a more pragmatic approach applies the pattern to one bounded, genuinely complex area first (like payment processing needing multiple provider implementations), proving the value before deciding whether wider adoption is worth the effort.