system-design-integration-patterns
Installation
SKILL.md
Integration Patterns
Priority: P1 (HIGH)
Each pattern buys one guarantee and charges operational complexity. Adopt on evidence, not on architecture fashion.
Selection Table
| Constraint observed | Pattern | Cost accepted |
|---|---|---|
| A write must update the database and publish an event atomically | Transactional outbox | A relay (poller or CDC) to run and monitor |
| Read shape and write shape have diverged and one model serves neither | CQRS | Two models, sync lag, doubled tests |
| The sequence of changes is itself the product (audit, replay, temporal queries) | Event sourcing | Projections, event versioning, no easy delete |
| A business transaction spans services and cannot hold a lock | Saga with compensations | Compensating action per step; no isolation |
| Exactly one instance may run a job or own a resource | Leader election (lease-based) | Fencing tokens; split-brain handling |
| Cross-cutting concerns repeated in every service | Sidecar or ambassador | Another process per pod to operate |
| A legacy or third-party model would infect the domain | Anti-corruption layer | A translation layer to maintain |
| Each client surface needs a different aggregate shape | Backends-for-frontends | One backend per surface, owned by that team |
| A monolith must be replaced without a rewrite freeze | Strangler fig | Dual routing and a live seam until the last slice moves |