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
InMemoryReadRepositorysatisfiesReadOnlyRepositoryPortwith a dictionary. - An
InMemoryWriteRepositorysatisfiesWriteOnlyRepositoryPortwith a dictionary. - An
InMemoryRepositorycombines read and write contracts for full CRUD access. - An
InMemoryEventBussatisfiesEventBusPortwith 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¶
- Persistence — Repositories, Unit of Work.
- Messaging & Events — Message Buses, Event Stores, Event Buses.
- Technical Adapters — Logging, HTTP, File System, Caching, Serialization.
- Errors — Repository error types.
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.