Skip to content

Infrastructure

Technical adapters

The Infrastructure block provides concrete implementations of outbound ports. It contains all technical details — I/O, serialization, networking, persistence.

Depends on Application (for port definitions), Domain (for aggregate types), and Foundation. Does not depend on Presentation.


How it works

Infrastructure adapters implement the contracts defined by Application outbound ports.

  • An InMemoryReadRepository satisfies ReadOnlyRepositoryPort with a dictionary.
  • An InMemoryWriteRepository satisfies WriteOnlyRepositoryPort with a dictionary.
  • An InMemoryRepository combines read and write contracts for full CRUD access.
  • An InMemoryEventBus satisfies EventBusPort with in-process publish/subscribe.
  • Each adapter encapsulates a technology choice behind a port interface.

How to use

Start with in-memory implementations for fast feedback during development. They require no external services and run in tests. Graduate to real adapters when you need persistence, messaging, or external integration.

Adapters are composable in a consuming application's composition root:

  • A Unit of Work can coordinate registered aggregate event publication.
  • A Message Bus dispatches messages to registered handlers.

Wire them together at startup and pass the resulting graph into the Application layer.


Core abstractions


What it does not do

  • Define business rules or domain logic.
  • Orchestrate workflows.
  • Make architectural decisions about port shape.
  • Depend on Presentation.

Glossary

Repository

Persists and retrieves domain aggregates. Implements RepositoryPort.

Unit of Work

Coordinates registered aggregate event publication and queue draining; database
transaction rollback is adapter-specific.

Message Bus

Dispatches commands, queries, and events to registered handlers.

Event Store

Append-only event storage with optimistic concurrency for event sourcing.