Microservices Architecture Migration Planner

Plan a structured migration from a monolithic application to microservices, covering service decomposition, data ownership, API contracts, migration phases, and rollback strategies.

Prompt Template

I need to plan a migration from a monolithic application to a microservices architecture.

**Current stack:** [e.g., Rails monolith, Django, Node.js Express]
**Database:** [e.g., PostgreSQL, MySQL, MongoDB]
**Current pain points:** [e.g., slow deploys, scaling bottlenecks, team coupling]
**Team size:** [number of developers]
**Number of major domains/modules:** [e.g., auth, billing, orders, notifications]
**Current deployment:** [e.g., single server, Kubernetes, Heroku]
**Timeline pressure:** [aggressive / moderate / flexible]
**Key constraints:** [e.g., zero downtime required, limited DevOps experience]

Please provide:
1. **Domain decomposition analysis** — identify candidate microservices from my modules using domain-driven design principles
2. **Dependency map** — show which services depend on each other and identify the riskiest couplings
3. **Recommended extraction order** — which service to extract first and why (strangler fig pattern)
4. **Data migration strategy** — how to split the shared database without breaking referential integrity
5. **API contract design** — communication patterns (sync REST/gRPC vs async events) for each service boundary
6. **Migration phases** — a phased roadmap with milestones and go/no-go criteria
7. **Rollback plan** — how to revert each phase if things go wrong
8. **Infrastructure requirements** — service mesh, API gateway, observability, and CI/CD changes needed

Example Output

🔧 Monolith → Microservices Migration Plan

Stack: Django Monolith → Kubernetes Microservices

1. Domain Decomposition

| Service | Domain | Current Module | Risk Level |

|---------|--------|----------------|------------|

| auth-service | Authentication & Users | | Low |

| billing-service | Payments & Subscriptions | | High |

| order-service | Order Management | | High |

| notification-service | Email, SMS, Push | | Low |

| catalog-service | Product Catalog | | Medium |

2. Dependency Map

**Riskiest coupling:** — tightly coupled through shared model with FK constraints.

3. Extraction Order (Strangler Fig)

**Phase 1: notification-service** (lowest risk, fewest dependencies)

- Extract email/SMS sending behind an event queue

- Monolith publishes events, new service consumes them

- Rollback: re-enable monolith notification module

Phase 2: auth-service

- Extract to standalone service with JWT issuing

- Implement API gateway for token validation

- All other services validate JWTs independently

Phase 3: catalog-service → Phase 4: order-service → Phase 5: billing-service

4. Data Migration Strategy

- **Phase 1-2:** Shared database with schema-level isolation (separate schemas per service)

- **Phase 3+:** Database-per-service with Change Data Capture (Debezium) for sync

- **Cross-service queries:** Replace JOINs with API calls + local caching

- **Eventual consistency:** Accept 2-5 second propagation delay for non-critical reads

Tips for Best Results

  • 💡Start with the least coupled, lowest-risk service — "notifications" is often the best first extraction
  • 💡Use the strangler fig pattern: route traffic gradually to the new service while keeping the monolith as fallback
  • 💡Don't split the database too early — shared database with schema isolation is a valid intermediate step
  • 💡Invest in observability (distributed tracing, centralized logging) before extracting your second service