Architecture patterns, in practice.
Reference cards for the patterns I actually reach for — and the ones I avoid. Each card spells out when it earns its keep, what it costs you, and the failure mode nobody mentions until it bites in production.
BFF (Backend for Frontend)
A dedicated backend per frontend (web, iOS, Android, partner) that composes and trims responses to what that client actually needs, instead of forcing every client through a shared general-purpose API. The frontend team usually owns it — that's the point.
Circuit Breaker
A wrapper around a remote call that tracks failures and, once they cross a threshold, "opens" and fails fast without trying — letting the downstream recover. After a cooldown it tentatively half-opens to test the waters.
CQRS
Command Query Responsibility Segregation — separate the model that mutates state from the model that reads it, often with separate datastores. Writes go through a domain model with invariants; reads come from a denormalised projection shaped to fit the screen.
Event Sourcing
Persist every state change as an immutable event and derive current state by folding the log, instead of storing the current state. The log is the system of record; everything else — read models, snapshots — is a cache you can rebuild.
Outbox
Insert the message into an "outbox" table in the same local transaction as the business write, then a separate relay ships it to the broker. Trades a little latency for a real exactly-business-event-once guarantee.
Saga
A long-running business transaction split across services, coordinated by a sequence of local transactions and explicit compensations when a later step fails. You trade atomic rollback for the ability to commit each step locally.
Sidecar
A helper process deployed alongside your application — same pod, same lifecycle — that handles cross-cutting concerns like TLS, telemetry, secrets or service-to-service auth without your app knowing how. The classic example is an Envoy proxy in a service mesh.
Strangler Fig
An incremental migration where a new system grows around the legacy — capability by capability, route by route — until the legacy does nothing and can be removed. Named after the fig that grows on a host tree and eventually replaces it.