Help us improve
Share bugs, ideas, or general feedback.
From pm-engineering
Designs microservices decomposition using DDD: bounded contexts, service boundaries, communication patterns, data ownership, and strangler-fig migration plan.
npx claudepluginhub mohitagw15856/pm-claude-skills --plugin pm-engineeringHow this skill is triggered — by the user, by Claude, or both
Slash command
/pm-engineering:microservices-decompositionThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Produce a complete microservices decomposition design for a system — whether decomposing an existing monolith or designing service boundaries for a new system. Ground the decomposition in Domain-Driven Design (DDD) concepts: identify bounded contexts first, then derive service boundaries from them. Include communication pattern decisions (sync vs. async, event vs. RPC), data ownership rules, an...
Designs service boundaries using DDD bounded contexts and functional cohesion. Helps decompose monoliths or design new microservices with appropriate granularity.
Break complex systems into bounded contexts with DDD. Map business capabilities to service boundaries, define ubiquitous language, assess cohesion/coupling. Use when refactoring monoliths or designing new architectures.
Guides microservices and distributed systems architecture: service decomposition, inter-service communication, data isolation, resilience patterns, and observability.
Share bugs, ideas, or general feedback.
Produce a complete microservices decomposition design for a system — whether decomposing an existing monolith or designing service boundaries for a new system. Ground the decomposition in Domain-Driven Design (DDD) concepts: identify bounded contexts first, then derive service boundaries from them. Include communication pattern decisions (sync vs. async, event vs. RPC), data ownership rules, and a pragmatic migration plan if decomposing a monolith. Conway's Law is real — include an organizational alignment section. The deliverable should be specific enough that a team can begin implementation, not an abstract architectural diagram.
Ask for these if not already provided:
If decomposing a monolith, also ask for: approximate codebase size, what is most painful to change today, and where the team experiences the most coupling-related friction.
Author: [Name / Team] Date: [Date] Architecture type: [Monolith decomposition / New system design] Current state: [One sentence describing what exists today] Target state: [One sentence describing the desired end state]
[One paragraph: what is the core domain of this system? What does the business fundamentally do? What gives it competitive differentiation? The core domain gets the most investment and the cleanest service boundaries.]
List every significant subdomain before assigning service boundaries. Classify each subdomain:
| Subdomain | Type | Description | Current Location in Monolith |
|---|---|---|---|
| [Subdomain, e.g., Order Management] | Core | [What it does and why it matters] | [Module/package name or "new"] |
| [Subdomain, e.g., Inventory] | Core | [Description] | [Location] |
| [Subdomain, e.g., Notifications] | Supporting | [Description] | [Location] |
| [Subdomain, e.g., Billing] | Supporting | [Description] | [Location] |
| [Subdomain, e.g., Reporting] | Generic | [Description — candidates for off-the-shelf solutions] | [Location] |
| [Subdomain, e.g., User Auth] | Generic | [Description] | [Location] |
Subdomain types: Core = competitive differentiation, build with care; Supporting = necessary but not differentiating, build pragmatically; Generic = commodity, buy or use open source.
┌─────────────────────────────────────────────────────────────────┐
│ [System Name] │
│ │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ [Context A] │ │ [Context B] │ │
│ │ │─ ─►│ │ │
│ │ [key concepts] │ │ [key concepts] │ │
│ └──────────────────┘ └──────────────────┘ │
│ │ │ │
│ │ event │ sync │
│ ▼ ▼ │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ [Context C] │ │ [Context D] │ │
│ │ │ │ │ │
│ │ [key concepts] │ │ [key concepts] │ │
│ └──────────────────┘ └──────────────────┘ │
│ │ │
│ ┌────────┘ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ [Context E] │ │
│ │ [key concepts] │ │
│ └──────────────────┘ │
│ │
│ External: [Third-party system] ──► [Context that owns it] │
└─────────────────────────────────────────────────────────────────┘
Legend: ──► sync call - -► async event ═══ shared kernel
Render this map using the actual bounded contexts derived from the domain analysis. Place contexts that communicate frequently closer together. Label relationship types on arrows.
| Upstream Context | Downstream Context | Relationship Type | Integration Pattern |
|---|---|---|---|
| [Context A] | [Context B] | Customer-Supplier | REST API call |
| [Context B] | [Context C] | Published Language | Domain events via message bus |
| [Context X] | [Context Y] | Conformist | [Downstream conforms to upstream's model] |
| [Context X] | [Context Y] | Anti-Corruption Layer | [ACL translates upstream model to local model] |
| Service Name | Bounded Context | Core Responsibility | Team Owner | Tech Stack | Priority |
|---|---|---|---|---|---|
| [service-name] | [Context] | [One sentence: what this service owns and does] | [Team] | [Language/framework] | [P1/P2/P3] |
| [service-name] | [Context] | [Responsibility] | [Team] | [Stack] | [Priority] |
| [service-name] | [Context] | [Responsibility] | [Team] | [Stack] | [Priority] |
| [service-name] | [Context] | [Responsibility] | [Team] | [Stack] | [Priority] |
| [service-name] | [Context] | [Responsibility] | [Team] | [Stack] | [Priority] |
Service count: [N proposed services] for [M bounded contexts]. [Note if any context maps to multiple services and why — e.g., "the Orders context splits into order-intake and order-fulfillment because they have different scalability requirements."]
| Communication Need | Recommended Pattern | Rationale |
|---|---|---|
| Query another service's current state | Synchronous REST / gRPC | Low latency required; caller needs immediate response |
| Notify other services of a state change | Async domain event | Decouples services; multiple consumers; sender doesn't care when it's processed |
| Long-running workflow spanning services | Async saga (choreography or orchestration) | No single service owns the full workflow; rollback needed if steps fail |
| Read-heavy cross-service aggregation | CQRS read model / materialized view | Avoid chatty sync calls at read time; build purpose-fit read models |
| Real-time push to clients | WebSocket gateway service | Centralizes connection management; services emit events, gateway pushes |
| Service | Calls (sync) | Publishes (events) | Subscribes to (events) |
|---|---|---|---|
| [service-name] | [service-name (endpoint)] | [EventName] | [EventName] |
| [service-name] | — | [EventName], [EventName] | [EventName] |
| [service-name] | [service-name (endpoint)] | — | [EventName] |
| Event Name | Producer | Consumers | Payload (key fields) | Trigger |
|---|---|---|---|---|
| [OrderPlaced] | [order-service] | [inventory-service, notification-service] | orderId, customerId, lineItems, totalAmount | Customer submits order |
| [InventoryReserved] | [inventory-service] | [order-service] | orderId, reservationId, items | Inventory successfully reserved |
| [PaymentProcessed] | [payment-service] | [order-service, notification-service] | orderId, paymentId, amount, status | Payment confirmed |
Each piece of data has exactly one owning service. Other services may cache or project a read model, but they do not write to the owner's database.
| Data Entity | Owner Service | Authoritative Store | Consumers | Access Pattern |
|---|---|---|---|---|
| [Order] | [order-service] | [PostgreSQL] | [fulfillment-service, reporting-service] | Event subscription + read API |
| [Customer] | [customer-service] | [PostgreSQL] | [order-service, notification-service] | Sync API call |
| [Product Catalog] | [catalog-service] | [PostgreSQL] | [order-service, inventory-service] | Sync API + cached local copy |
| [Inventory Level] | [inventory-service] | [Redis + PostgreSQL] | [catalog-service (read only)] | Event subscription |
| [Payment Record] | [payment-service] | [PostgreSQL] | [order-service] | Event subscription |
| Data Entity | Current Location | Target Service | Migration Approach | Data Volume | Risk |
|---|---|---|---|---|---|
| [Entity] | [monolith.orders table] | [order-service] | Dual-write then cut over | [X rows] | [High/Med/Low] |
| [Entity] | [monolith.users table] | [customer-service] | Extract and sync via CDC | [X rows] | [High/Med/Low] |
Define the surface area for each service. Full OpenAPI specs are written separately; this section establishes the contract boundaries.
Base path: /api/v1/[resource]
Owner team: [Team]
SLA: [p99 latency target, availability target]
| Endpoint | Method | Description | Auth Required | Rate Limit |
|---|---|---|---|---|
/[resources] | GET | List [resources] with pagination | Yes | [X req/min] |
/[resources]/{id} | GET | Get single [resource] by ID | Yes | [X req/min] |
/[resources] | POST | Create new [resource] | Yes | [X req/min] |
/[resources]/{id} | PUT | Update [resource] | Yes | [X req/min] |
/[resources]/{id} | DELETE | Soft-delete [resource] | Yes — elevated | [X req/min] |
[Repeat for each service.]
Use the strangler fig pattern: extract services incrementally, route traffic through a facade, and retire monolith modules one at a time.
Phase 1: Foundation (Weeks 1–[N])
- Deploy service infrastructure (CI/CD, observability, service mesh)
- Extract lowest-risk, highest-value service first
- Monolith continues to serve all traffic
Phase 2: First Extractions (Weeks [N]–[M])
- Extract P1 services
- API gateway routes selected traffic to new services
- Monolith handles remaining traffic via facade pattern
- Both paths write to shared DB during transition (dual-write)
Phase 3: Core Domain Services (Weeks [M]–[P])
- Extract P1 core domain services
- Data migration for extracted services
- Remove dual-write paths for completed migrations
Phase 4: Monolith Retirement (Weeks [P]–[Q])
- Extract remaining services
- Monolith serves no production traffic
- Decommission monolith infrastructure
| Phase | Service to Extract | Migration Approach | Team | Duration | Dependencies | Success Criteria |
|---|---|---|---|---|---|---|
| 1 | [service-name] | [Strangler facade / Branch by abstraction / Event interception] | [Team] | [X weeks] | [Infra ready, CI/CD pipeline] | [Traffic fully on new service, zero errors for 2 weeks] |
| 2 | [service-name] | [Approach] | [Team] | [X weeks] | [Phase 1 complete] | [Success metric] |
| 3 | [service-name] | [Approach] | [Team] | [X weeks] | [Phase 2 complete] | [Success metric] |
For each migration phase, define the rollback trigger and mechanism:
Conway's Law: the architecture of a system mirrors the communication structure of the organization that builds it. Design service ownership to match team boundaries — or change the team boundaries.
| Service | Proposed Owner Team | Current Team Assignment | Change Required |
|---|---|---|---|
| [service-name] | [Team A] | [Same / Different] | [No change / Transfer to Team A / New team needed] |
| [service-name] | [Team B] | [Team A currently] | [Transfer ownership] |
Misalignments identified:
Team topology recommendation: [Describe the recommended team structure — stream-aligned teams, platform team, enabling team — and how it maps to the proposed services.]
| Risk | Likelihood | Impact | Mitigation | Owner |
|---|---|---|---|---|
| Data consistency across services during migration | High | High | Dual-write with reconciliation job; event sourcing for critical domains | [Name] |
| Distributed transaction complexity (sagas) | Medium | High | Start with choreography; add orchestration only when choreography becomes unmanageable | [Name] |
| Service mesh operational overhead | Medium | Medium | Start without a mesh; add after 5+ services deployed | [Name] |
| Network latency replacing in-process calls | Medium | Medium | Cache aggressively; design read models to avoid chatty sync calls | [Name] |
| Conway's Law friction during transition | High | Medium | Align team structure before starting extraction, not after | [Name] |
| Over-decomposition (nanoservices) | Medium | High | Enforce minimum service size rule: a service must justify its own team/deployment overhead | [Name] |
| Observability gaps during migration | High | High | Deploy distributed tracing before first extraction; establish correlation IDs | [Name] |
| [Context-specific risk] | [Level] | [Level] | [Mitigation] | [Owner] |
Questions about this design: [Slack channel or contact]