Skip to content
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN DE
Let's talk

Hexagonal Architecture — Ports and Adapters

14. 07. 2025 1 min read advanced

Architecture Intermediate

Hexagonal Architecture — Ports and Adapters

HexagonalPorts & AdaptersClean Code 3 min read

Separating business logic from infrastructure. Ports, adapters, and testable code.

Principle

Business logic does not depend on the database, framework, or UI. Ports = interfaces. Adapters = concrete implementations.

Structure

src/
├── domain/                    # Core — no dependencies!
│   ├── model/Order.ts
│   ├── ports/OrderRepository.ts  # Interface
│   └── services/OrderService.ts
├── application/
│   └── CreateOrderUseCase.ts
└── infrastructure/            # Adapters
    ├── persistence/PostgresOrderRepo.ts
    ├── payment/StripeGateway.ts
    └── web/OrderController.ts

Testability

Domain logic is tested with mock adapters — no database, no HTTP.

const mockRepo = { save: jest.fn() };
const service = new OrderService(mockRepo, mockPayment);
test('creates order', async () => {
    const order = await service.createOrder('cust-1', items);
    expect(order.status).toBe('CREATED');
    expect(mockRepo.save).toHaveBeenCalled();
});

Summary

Hexagonal architecture is an investment in maintainability. It pays off for projects with a longer lifespan.

Need Help with Implementation?

Our team has experience designing and implementing modern architectures. We’re happy to help.

Free Consultation

Share:

CORE SYSTEMS team

We build core systems and AI agents that keep operations running. 15 years of experience with enterprise IT.