_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
Let's talk

Hexagonal Architecture — porty a adaptéry

14. 07. 2025 1 min read advanced

Architecture Intermediate

Hexagonal Architecture — porty a adaptéry

HexagonalPorts & AdaptersClean Code 3 min read

Oddělení byznys logiky od infrastruktury. Porty, adaptéry a testovatelný kód.

Principle

Byznys logika nezávisí na databázi, frameworku ani UI. Porty = rozhraní. Adaptéry = konkrétní implementace.

Structure

src/
├── domain/                    # Jádro — žádné závislosti!
│   ├── model/Order.ts
│   ├── ports/OrderRepository.ts  # Interface
│   └── services/OrderService.ts
├── application/
│   └── CreateOrderUseCase.ts
└── infrastructure/            # Adaptéry
    ├── persistence/PostgresOrderRepo.ts
    ├── payment/StripeGateway.ts
    └── web/OrderController.ts

Testovatelnost

Doménovou logiku testujete s mock adaptéry — bez databáze, bez 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

Hexagonální architektura je investice do udržitelnosti. Vyplatí se u projektů s delší životností.

Need Help with Implementation?

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

Free Consultation

Share:

CORE SYSTEMS tým

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.