Service Decomposition and DDD
1. Executive Summary
Service decomposition is the act of partitioning a system into independently deployable services aligned with business capability boundaries. Domain-Driven Design (DDD) provides the strategic vocabulary—bounded contexts, ubiquitous language, aggregates, and domain events—to make those boundaries durable rather than arbitrary.
Poor decomposition creates distributed monoliths: services that must deploy together, share databases, and fail in correlated ways. Strong decomposition maps organizational ownership, data autonomy, and evolution velocity to context boundaries. The goal is not "more services" but independent lifecycles with explicit integration contracts.
This chapter covers decomposition heuristics, DDD tactical patterns in microservice form, context mapping, data ownership, team topology (Conway's Law), migration from monoliths, and principal-level tradeoffs between granularity, consistency, and operational cost.
2. Why This Topic Matters
Microservice interviews at principal level rarely ask "what is a microservice." They ask:
- How would you decompose this monolith without creating a distributed ball of mud?
- Where do you draw transaction boundaries when data spans services?
- How do bounded contexts differ from REST resource groupings?
- What is the cost of the wrong cut—latency, consistency, team friction?
- How do you evolve boundaries as the business changes?
Candidates who answer with technology ("use Kubernetes") miss the organizational and domain reasoning that distinguishes staff/principal architects from senior engineers.
3. Problems Being Solved
| Problem | Decomposition + DDD response |
|---|---|
| Monolith scaling bottlenecks | Isolate hot subdomains for independent scale |
| Coupled release trains | Services with separate CI/CD per bounded context |
| Unclear ownership | Context maps assign team accountability |
| Semantic drift ("Customer" means different things) | Ubiquitous language per context |
| Big-bang rewrites | Strangler fig migration along seams |
| Shared mutable databases | Database-per-service with explicit integration |
Decomposition does not solve: inherent distributed-systems complexity, cross-context reporting without eventual consistency, or automatic team autonomy without governance.
4. Assumptions and System Model
| Assumption | Implication |
|---|---|
| Business domain has natural seams | Not all domains decompose cleanly—some remain modular monoliths |
| Teams own services long-term | Conway's Law: architecture mirrors communication structure |
| Network is unreliable | Cross-service calls are partial failure paths |
| Consistency is expensive across boundaries | Sagas, outbox, eventual consistency by default |
| Not Byzantine | Trust internal services with mTLS and policy; zero-trust at edge |
System model: Each service is a deployable unit with its own persistence, exposing APIs or publishing events at context boundaries. Integration is synchronous (query/command) or asynchronous (domain events)—never shared tables.
5. Essential Terminology
| Term | Definition |
|---|---|
| Bounded context | Explicit boundary where a domain model is consistent and terms have one meaning |
| Ubiquitous language | Shared vocabulary between developers and domain experts within a context |
| Aggregate | Cluster of entities treated as a consistency unit; one root entity |
| Domain event | Record of something meaningful that happened in the domain |
| Context map | Diagram of relationships between bounded contexts (upstream/downstream) |
| Anti-corruption layer (ACL) | Translation layer protecting a context from foreign models |
| Shared kernel | Small shared model between two contexts—use sparingly |
| Conway's Law | System design reflects organizational communication structure |
| Database per service | Each service owns its schema; no cross-service SQL joins in production |
| Strangler fig | Incrementally replace monolith by routing traffic to new services |
6. Core Mechanism
Bounded context to service mapping
Figure 1: Teams align to bounded contexts; services encapsulate context models; integration crosses explicit boundaries.
Decomposition decision flow
Figure 2: Decomposition heuristics—language, velocity, and scale drive cuts; consistency constraints validate them.
Context relationship patterns
Figure 3: Downstream contexts translate upstream models through ACLs rather than leaking foreign concepts.
Aggregate boundaries and consistency
Within a bounded context, aggregates define transaction boundaries:
- Order aggregate (root:
Order): includesLineItems; invariants like "total matches sum of lines" enforced inside aggregate. - Inventory aggregate (root:
StockItem): reservation logic stays local; cross-aggregate rules use domain events or sagas.
Rule: One transaction modifies one aggregate instance. Cross-service invariants require sagas or eventual consistency with compensating actions.
7. Step-by-Step Walkthrough
Scenario: E-commerce monolith decomposed into Order, Inventory, and Payment contexts.
| Step | Action | Mechanism |
|---|---|---|
| 1 | Domain workshop | Identify bounded contexts with domain experts |
| 2 | Context map | Mark Order as upstream to Fulfillment; Payment as separate |
| 3 | Extract Inventory first | High change velocity; clear data boundary |
| 4 | Database per service | Inventory gets inventory_db; no shared tables |
| 5 | Publish StockReserved events | Order service subscribes via message broker |
| 6 | Strangler routing | API gateway routes /inventory/* to new service |
| 7 | Extract Payment | PCI scope isolation drives boundary |
| 8 | Saga for checkout | Order → reserve stock → charge payment → confirm |
Checkout saga (choreography):
| Step | Service | Event / action |
|---|---|---|
| 1 | Order | OrderCreated |
| 2 | Inventory | Reserve stock → StockReserved or StockRejected |
| 3 | Payment | Charge → PaymentCaptured or PaymentFailed |
| 4 | Order | Confirm or compensate (release stock, cancel order) |
Event storming facilitation (principal-level practice):
Principal architects often lead 4-hour domain workshops with sticky notes on a wall:
| Hour | Activity | Output |
|---|---|---|
| 1 | Domain events (orange) | Timeline of business occurrences |
| 2 | Commands and actors (blue) | Who triggers what |
| 3 | Aggregates and policies (yellow) | Consistency boundaries emerge |
| 4 | Draw context lines | Candidate bounded contexts |
Extraction decision checklist—extract a service only when three or more apply:
- Distinct ubiquitous language from neighbors
- Eventual consistency tolerable with dependencies
- Team ready for on-call ownership
- Different scale or release cadence
- Regulatory scope benefit (PCI, HIPAA isolation)
Cross-context data patterns:
| Pattern | Consistency | Use when |
|---|---|---|
| Synchronous API | Strong read of remote | Simple query; few hops |
| Domain events | Eventual | Decoupled workflows |
| CDC (Debezium) | Eventual | Legacy DB during strangler |
| CQRS read model | Eventual | Cross-context reporting |
Avoid 2PC across contexts—use sagas and Transactional Outbox instead.
Monolith extraction order heuristic:
| Priority | Candidate | Rationale |
|---|---|---|
| 1 | High-change, clear boundary | Inventory, notifications |
| 2 | Regulatory isolation | Payment, PII profile |
| 3 | Scale hotspot | Search indexing, media processing |
| 4 | Stable core | Keep order management longer if boundary unclear |
8. Invariants and Guarantees
| Property | Type | Statement |
|---|---|---|
| Context model consistency | Safety | Terms have single meaning within bounded context |
| Aggregate invariant | Safety | Invariants hold within one aggregate per transaction |
| Cross-context consistency | Eventual | Not atomic without distributed transaction (avoid 2PC) |
| Service autonomy | Liveness | Service deploys without coordinating peer schema migrations |
| Idempotent consumers | Safety | Event handlers tolerate duplicate delivery |
9. Failure Scenarios
Scenario 1: Shared database anti-pattern
Setup: Three services read/write orders table directly.
Effect: Schema changes require coordinated deploys; cascading failures; unclear ownership.
Mitigation: Database per service; APIs/events only; read models via CDC if needed.
Scenario 2: Chatty synchronous mesh
Setup: Checkout calls 12 services synchronously per request.
Effect: Latency multiplies; partial failure probability compounds; brittle deploys.
Mitigation: Orchestrated saga or choreography with async events; aggregate read models.
Scenario 3: Wrong bounded context cut
Setup: "Customer" split across Profile and Billing with different definitions.
Effect: Integration bugs; duplicate customer IDs; support confusion.
Mitigation: Context map workshop; ACL; canonical identity service as upstream.
Scenario 4: Distributed monolith
Setup: Services share library, database, and release train.
Effect: Microservice operational cost without autonomy benefits.
Mitigation: Enforce independent deploy tests; separate repos or strict module boundaries.
Scenario 5: Event schema breaking change
Setup: OrderPlaced v2 removes field consumers require.
Effect: Downstream processing stalls; silent data corruption.
Mitigation: Schema registry; backward-compatible evolution; consumer-driven contracts.
Scenario 6: Premature extraction during peak season
Setup: Team extracts Payment service two weeks before Black Friday without load testing cross-service checkout.
Effect: Latency regression; saga timeouts; revenue impact during highest-traffic period.
Mitigation: Freeze structural changes before peak; load test extracted path at 2× expected traffic; feature flag rollback to monolith path.
10. Performance Characteristics
| Factor | Impact |
|---|---|
| Cross-service sync calls | Add network RTT per hop; prefer batch or async |
| Event-driven integration | Higher latency to consistency; better peak throughput |
| Database per service | No cross-join; CQRS read models for queries |
| Service count | Operational overhead grows superlinearly without platform team |
| Caching at boundaries | Reduce fan-out; watch invalidation complexity |
Rule of thumb: Each synchronous hop adds ~1–10ms LAN / 50–200ms cross-region—verify with your topology. Design for one sync hop on critical paths where possible.
11. Scalability Limits
- Team cognitive load: Amazon "two-pizza team" heuristic—roughly 6–10 engineers per service cluster.
- Service count: Hundreds of services require strong platform engineering (discovery, observability, deployment).
- Event throughput: Bounded by broker partition design and consumer parallelism.
- Context granularity: Too fine → integration explosion; too coarse → monolith reborn.
12. Operational Considerations
- Service catalog with ownership, SLOs, and on-call rotation per context.
- Contract testing (Pact, consumer-driven) at context boundaries.
- Deprecation policy for APIs and events with sunset timelines.
- Runbooks per service including upstream/downstream dependencies.
- Feature flags for strangler migrations and dark launches.
- Architecture decision records (ADRs) documenting boundary choices.
Ongoing boundary governance:
After initial decomposition, teams must prevent boundary erosion:
| Review cadence | Activity | Owner |
|---|---|---|
| Weekly | New cross-service dependency PR review | Tech lead |
| Monthly | Context map update in architecture wiki | Principal architect |
| Quarterly | Coupling metrics review (deploy correlation) | Platform + product |
| Per major feature | Event storming for new subdomain | Domain + engineering |
Service catalog minimum fields: service name, bounded context, owning team, tier (1–3), on-call rotation, SLO link, upstream/downstream dependencies, data stores owned, API/event contracts (links to OpenAPI/proto), last game day date.
13. Security Considerations
- Least privilege per service identity (IAM, SPIFFE).
- PCI/HIPAA scope reduction by isolating regulated data in dedicated contexts.
- mTLS between services; no implicit trust by network zone alone.
- PII minimization at integration boundaries—pass IDs not full profiles.
- Audit trails on domain events for compliance reconstruction.
14. Cost Considerations
- Each service adds: CI/CD pipelines, monitoring, on-call, compute baseline.
- Over-decomposition increases cloud spend (more pods, more cross-AZ traffic).
- Under-decomposition increases opportunity cost (slow releases, scaling inefficiency).
- FinOps should tag costs by bounded context / team for accountability.
15. Production Implementations
Amazon
Service-oriented architecture with "two-pizza teams"; strict API ownership; eventual consistency across domains—implementation choice documented in public talks.
Netflix
Domain-aligned microservices with robust platform (Spinnaker, Eureka); chaos testing validates boundary resilience.
Uber
Domain-oriented microservice architecture (DOMA); emphasis on layered gateways and standard tooling.
Modular monolith (Shopify-style evolution)
Some organizations retain modular monoliths with clear module boundaries—valid when decomposition cost exceeds benefit.
16. Alternatives and Tradeoffs
| Approach | Strength | Weakness |
|---|---|---|
| Modular monolith | Simple ops, ACID transactions | Scaling and team autonomy limits |
| Microservices + DDD | Autonomy, independent scale | Distributed complexity |
| Cell-based architecture | Blast radius isolation | Higher baseline infrastructure |
| Monorepo + many services | Shared tooling | Requires discipline to avoid coupling |
Choose microservices when organizational scale and independent deployment justify distributed-systems tax.
17. Common Misconceptions
| Misconception | Reality |
|---|---|
| "One entity = one service" | Aggregates and contexts drive cuts, not ER diagrams |
| "DDD is only for big companies" | Strategic DDD pays off at any scale with complex domains |
| "Events eliminate consistency problems" | They shift to eventual consistency and ordering challenges |
| "Microservices are always more scalable" | Network chatter can underperform well-designed monolith |
| "Decompose first, fix later" | Wrong boundaries are expensive to move |
18. Principal Architect Perspective
- Start with context map, not technology—Conway's Law will enforce your org chart anyway.
- Optimize for change frequency—stable subdomains can share infrastructure longer.
- Data ownership is non-negotiable—shared databases are the leading cause of distributed monoliths.
- Plan migration as strangler, not big-bang—business continuity dominates.
- Measure coupling—deploy frequency correlation between services signals bad cuts.
Organizational implication: Platform teams provide golden paths; product teams own bounded contexts. Architects facilitate context mapping workshops, not just draw boxes.
Measuring decomposition health (ongoing):
| Metric | Healthy signal | Unhealthy signal |
|---|---|---|
| Deploy frequency per service | Independent, frequent | Correlated multi-service deploys |
| Cross-service sync call depth | ≤2 on critical path | Deep synchronous chains |
| Incident blast radius | Single context | Cascading multi-service outages |
| Schema migration coupling | Independent per DB | Coordinated cross-schema changes |
| Team ownership clarity | One team per context | Shared "everyone owns" services |
Review these quarterly after decomposition milestones—not only at initial design time.
Principal architects should treat service boundaries as living artifacts that evolve with the business—not one-time workshop outputs frozen in an initial microservices migration plan.
19. Architecture Review Exercise
Scenario: 200-engineer org splits monolith into 40 services in six months. Shared PostgreSQL with schema per "service." Synchronous REST mesh for all reads. No event bus.
Review prompts:
- Are services independently deployable?
- Where are transaction boundaries?
- What happens when Inventory schema migrates?
- Latency budget for product page (calls 8 services)?
Expected findings: Shared DB prevents autonomy; sync mesh needs caching/BFF; missing events for cross-context workflows; recommend pause and context map reset.
20. Whiteboard Explanation
90-second version:
"I decompose by bounded context—where business language and rules are consistent—not by technical layers. Each context becomes a service with its own database. Aggregates define local transactions; cross-context workflows use sagas or events. I map upstream/downstream relationships and use anti-corruption layers when models differ. Conway's Law means team boundaries matter as much as API boundaries. I'd strangler-migrate high-value seams first—usually inventory or payments for PCI—not random package splits. Wrong cuts cost more than staying monolithic longer, so I validate with change-velocity data and coupling metrics before extracting."
21. Interview Questions
-
What is a bounded context?
- Signals: Consistent model boundary; ubiquitous language; not just a microservice.
-
How do aggregates relate to microservices?
- Signals: Aggregate = transaction boundary inside context; service may host multiple aggregates.
-
When would you NOT split a service?
- Signals: No language split, need strong consistency, team too small, premature optimization.
-
Explain anti-corruption layer.
- Signals: Translation at downstream boundary; protects internal model.
-
Database per service—how do you query across domains?
- Signals: API composition, CQRS read models, CDC, not cross-DB joins.
-
Conway's Law implications?
- Signals: Align teams to contexts; reorg may require rearchitecture.
-
Strangler fig pattern?
- Signals: Incremental routing; coexist monolith and services.
-
Saga vs 2PC for checkout?
- Signals: Saga with compensation; 2PC fragile at scale.
-
Signs of distributed monolith?
- Signals: Coordinated deploys, shared DB, cyclic sync dependencies.
-
How to decompose a monolith—first steps?
- Signals: Event storming, context map, identify seams by change frequency.
-
Ubiquitous language example?
- Signals: Same term different meaning across contexts (e.g., "Product").
-
Context mapping relationship types?
- Signals: Partnership, customer-supplier, conformist, ACL, shared kernel.
Scoring rubric:
| Dimension | Strong | Weak |
|---|---|---|
| Domain reasoning | Contexts, aggregates, events | "Split by REST resources" |
| Data ownership | DB per service, sagas | "Shared DB with views" |
| Migration | Strangler, risk ordering | "Rewrite everything" |
| Org awareness | Conway, team topology | Technology-only answer |
22. Interview Follow-Ups
-
How do you handle reporting across contexts?
- Signals: Data warehouse, event sourcing, CDC, not synchronous fan-out.
-
Shared kernel when acceptable?
- Signals: Small, stable, two contexts only; versioning discipline.
-
Monolith vs microservices for 10-person startup?
- Signals: Modular monolith; defer until team/org pain justifies cost.
22A. Production Low-Level Design (Interview + Game Day)
Strangler-fig migration LLD for billing monolith → bounded-context services. Production LLD and Game Day Standard.
Control plane vs data plane
| Plane | Components | Role |
|---|---|---|
| Control | API gateway routing rules, feature flags, schema registry | Strangler traffic shift; contract governance |
| Data | Per-context databases, outbox, event bus | Autonomous persistence; async integration |
Bounded context service table
| Context | Service | Owns | Integration |
|---|---|---|---|
| Subscription | subscription-service | Plans, renewals | Publishes SubscriptionRenewed |
| Invoicing | invoicing-service | Invoices, line items | Subscribes to subscription events |
| Payment | payment-service | Charges, PCI scope | ACL to PSP; idempotent capture |
| Tax | tax-service | Jurisdiction rules | High change velocity; isolated deploy |
Strangler routing LLD
Step-by-step flow:
| Step | Action | Failure / idempotency |
|---|---|---|
| 1 | Client calls /v1/subscriptions | Gateway attaches trace + idempotency key |
| 2 | Gateway evaluates strangler rule (tenant % or SKU) | Misroute → rollback flag; no dual-write |
| 3a | Legacy monolith path unchanged | Monolith DB still source for unmigrated tenants |
| 3b | New service owns write | Single aggregate transaction per request |
| 4 | Outbox publishes domain event | Consumer idempotent on event_id |
| 5 | CDC feeds reporting | Eventual; not on checkout critical path |
Checkout saga sequence (numbered)
Step-by-step flow:
| Step | Invariant |
|---|---|
| 1–2 | One aggregate per service call; no cross-DB transaction |
| 3 | Same idempotency key on retry after timeout |
| 5 | Compensating events are idempotent; saga state in order DB |
One multi-region / DR sentence
Tier-1 payment context uses warm standby in a second region (RTO 15 min, RPO 1 min async replication); other contexts stay single-region until BIA demands more—see Disaster Recovery and Multi-Region.
One SLO
Subscription API availability 99.9% / 30d measured at gateway for strangler-routed traffic; alert on cross-context saga compensation rate > baseline.
22B. Game Day Playbooks
| # | Drill | Inject | Detect | Mitigate | Verify |
|---|---|---|---|---|---|
| GD-1 | Strangler misroute | Wrong gateway weight | 4xx spike on new path | Roll flag to 0% | Monolith path healthy |
| GD-2 | Event schema break | Deploy incompatible SubscriptionRenewed | Consumer lag / DLQ | Roll producer; replay | Invoicing catches up |
| GD-3 | Saga step-3 failure | Payment 503 during checkout | Saga stuck / compensations | Run compensation runbook | No orphaned reservations |
| GD-4 | Shared DB regression | Simulated cross-schema join attempt | CI contract test fail | Block deploy | DB-per-service enforced |
GD-3 — Saga compensation under payment failure
23. Strong Answer Example
Question: "How would you decompose our billing monolith?"
Answer this as a 45-minute greenfield design using the PRACTICE framework. Below is how a strong student sounds aloud—start with bounded contexts, not Kubernetes.
Student interview script (PRACTICE)
P — Problem framing
"We're decomposing a billing monolith without creating a distributed monolith. The goal is independent deploy velocity per business capability—especially tax and subscription rules—not 'more microservices.'
Non-goals for v1: rewriting every module, active-active multi-region billing, or eliminating the data warehouse. I'll use strangler fig so revenue keeps flowing during migration."
R — Requirements
| Type | Requirement |
|---|---|
| FR | Subscriptions, invoicing, payment capture, tax calculation, merchant webhooks |
| NFR | Independent deploy per context; PCI isolation for payment; audit trail |
| Consistency | Strong inside aggregate; eventual across contexts via events/sagas |
| Ops | Service catalog with ownership; contract tests at boundaries |
"I'll ask: which modules change most often? Is payment in-scope for PCI today? Are renewals batch or real-time? I'll assume Subscription + Invoicing + Payment + Tax contexts and event-driven renewal with sync capture at checkout."
A — Assumptions (state aloud)
| Assumption | Why it matters |
|---|---|
| Domain experts available for event storming | Boundaries follow language, not packages |
| Event bus + schema registry exists (or will) | Safe cross-context evolution |
| Monolith stays authoritative for unmigrated paths | Strangler, not big-bang |
| Teams can own on-call per context | Conway's Law—boundary without team fails |
| Reporting tolerates eventual consistency | Warehouse/CDC, not sync fan-out |
C — Capacity (back-of-envelope)
Renewal events peak → 500/sec (say)
Invoice generation → async, 2× peak with buffer
Payment capture sync → p99 < 800ms budget; 1 sync hop max on hot path
Services extracted v1 → 3 (Tax, Subscription, Payment)—not 12
Gateway routing rules → tenant % rollout; instant rollback via flag
"Each extra synchronous hop on renewal adds tail latency and partial-failure probability—I keep checkout to one sync call per context where possible, events elsewhere."
T — Topology (draw this)
Pattern choice: Strangler fig along bounded contexts; database per service; choreography saga for renewal.
| Context | Why extract order |
|---|---|
| Tax | Regulatory change velocity; clear language boundary |
| Payment | PCI scope reduction |
| Subscription | Product iteration; upstream to invoicing |
I — Invariants (safety)
"Non-negotiable:
- No shared mutable tables across services after cutover.
- One transaction = one aggregate inside a context.
- Idempotent event consumers—at-least-once delivery assumed.
- Anti-corruption layer at payment PSP boundary—don't leak PSP model inward.
- Strangler flag can route 100% back to monolith without data fork."
C — Constraints (second C)
| Constraint | Design response |
|---|---|
| Team size | Extract 3 contexts first—not 40 services in six months |
| Reporting | CDC → warehouse; no synchronous 8-service product page |
| Peak season | Freeze structural extraction 4 weeks before peak |
| Schema drift | Consumer-driven contracts + registry |
| Wrong cut cost | Event storming + extraction checklist (≥3 signals) before extract |
E — Evolution (phased strangler)
| Phase | Deliverable |
|---|---|
| M1 | Context map + service catalog fields |
| M2 | Extract Tax; strangler route /tax/* |
| M3 | Payment service + PCI boundary; sync capture API |
| M4 | Subscription + SubscriptionRenewed events |
| M5 | Decommission monolith modules; game day saga failure drill |
Observability: deploy correlation metric (do services still deploy together?), saga compensation rate, event consumer lag per context.
Closing line (interview)
"So: event storming → context map → strangler routes → database per service → events/sagas across boundaries, extracting tax and payment first for velocity and PCI, measuring success by independent deploy frequency—not service count. Wrong boundaries cost more than staying monolithic longer, so I validate with coupling metrics before each extract."
Scoring signals
| Strong | Weak / red flag |
|---|---|
| Bounded contexts + ubiquitous language | "Split by REST resources" |
| Strangler + DB ownership | Big-bang rewrite |
| Saga/compensation for cross-context | 2PC across services |
| Conway + team ownership | "Use Kubernetes" as the answer |
| Game day for saga failure | No migration rollback plan |
Compact outline (if time-boxed to 2 minutes)
"Event storming finds Subscription, Invoicing, Payment, Tax contexts. Strangler gateway routes new subscription types first. DB per service;
SubscriptionReneweddrives invoicing async. Payment isolated for PCI. Tax extracted early for regulatory velocity. CDC to warehouse for reporting. Measure independent deploys—not microservice count."
24. Weak Answer Example
Question: "How would you decompose our billing monolith?"
"Split it into microservices, use Kubernetes, and add an API gateway."
Why weak: No domain analysis, data boundaries, migration plan, or consistency model.
25. Hands-On Exercise
- Run a mini event-storming session on a fictional order domain (sticky notes: commands, events, aggregates).
- Draw a context map with 3–4 contexts and relationship types.
- Identify one aggregate per context with invariants listed.
- Design checkout as choreography saga with compensating events.
- List what stays in monolith vs extracts first with justification.
- Write an ADR for one boundary decision including rejected alternatives.
- Map existing monolith modules to candidate contexts; score each on extraction readiness (1–5).
- Simulate saga failure at step 3; document compensating events and idempotency requirements for each handler.
- Present context map to mock principal panel; defend one controversial boundary choice with tradeoff analysis.
26. Knowledge Check
- What defines a bounded context? (Consistent domain model and language.)
- One transaction modifies how many aggregates? (One aggregate instance.)
- ACL purpose? (Protect downstream model from upstream concepts.)
- Shared database symptom? (Coordinated deploys, coupling.)
- Strangler fig goal? (Incremental replacement without big-bang.)
27. Flashcards
| # | Front | Back |
|---|---|---|
| 1 | Bounded context | Domain boundary with consistent model and language. |
| 2 | Aggregate | Consistency cluster with single root entity. |
| 3 | Domain event | Record of meaningful business occurrence. |
| 4 | Ubiquitous language | Shared domain vocabulary in a context. |
| 5 | Context map | Diagram of inter-context relationships. |
| 6 | Anti-corruption layer | Translation shield at context boundary. |
| 7 | Database per service | Each service owns its persistence exclusively. |
| 8 | Strangler fig | Incremental monolith replacement pattern. |
| 9 | Conway's Law | Architecture mirrors org communication. |
| 10 | Saga | Multi-step cross-service workflow with compensation. |
28. Cheat Sheet
DECOMPOSE WHEN
Different ubiquitous language
Different change velocity / scale
Regulatory or scope isolation (PCI)
Team ownership ready
KEEP TOGETHER WHEN
Strong cross-aggregate ACID needed
No organizational split
Integration cost > monolith pain
BOUNDARIES
Context → Service (often 1:1)
Aggregate → Transaction unit
Integration → API + events (not shared DB)
MIGRATION
Context map → strangler → DB split → event contracts
RED FLAGS
Shared database
Cyclic sync calls
Coordinated multi-service deploys
29. Related Concepts
- Event-Driven Architecture — domain events across contexts
- Sagas — cross-service workflows
- Transactional Outbox — reliable event publishing
- System Design Methodology — decomposition in design interviews
- Architecture Decision Records — documenting boundary choices
- Resilience Patterns — handling partial failure across services
30. References
Primary sources
- Evans, E. (2003). Domain-Driven Design: Tackling Complexity in the Heart of Software. Addison-Wesley.
- Newman, S. (2021). Building Microservices, 2nd ed. O'Reilly — decomposition patterns and migration.
- Vernon, V. (2016). Domain-Driven Design Distilled. Addison-Wesley — strategic DDD summary.
Engineering blogs
- Martin Fowler, "BoundedContext" and "StranglerFigApplication" — martinfowler.com.
- Thoughtworks Technology Radar — microservice and monolith guidance (verify current edition).
Distinction
| Claim type | Source |
|---|---|
| Bounded context, aggregate definitions | Evans, Vernon |
| Strangler fig, database per service | Newman; Fowler |
| Conway's Law | Melvin Conway (1968); Brooks, Mythical Man-Month |
| Company implementations | Public engineering talks—implementation choices |