Legacy System Modernization Engine
Complete methodology for assessing, planning, and executing legacy system modernization — from monolith decomposition to cloud migration. Works for any tech stack, any scale.
Phase 1: System Assessment
Modernization Brief
system_name: "[Name]"
age_years: 0
primary_language: ""
framework: ""
database: ""
deployment: "on-prem | VM | container | serverless"
lines_of_code: 0
team_size: 0
monthly_users: 0
annual_revenue_supported: "$0"
compliance_requirements: []
known_pain_points: []
business_driver: "cost | speed | talent | risk | compliance | scale"
timeline_pressure: "low | medium | high | critical"
budget_range: "$0-$0"
sponsor: ""
Technical Debt Inventory
Score each dimension 1-5 (1=critical, 5=healthy):
| Dimension |
Score |
Evidence |
| Code quality — test coverage, complexity, duplication |
|
|
| Architecture — coupling, modularity, clear boundaries |
|
|
| Infrastructure — deployment automation, monitoring, scaling |
|
|
| Dependencies — outdated libraries, EOL frameworks, security vulns |
|
|
| Data — schema quality, migration history, backup/recovery |
|
|
| Documentation — accuracy, coverage, onboarding effectiveness |
|
|
| Operations — deployment frequency, MTTR, incident rate |
|
|
| Security — auth patterns, encryption, audit trail, compliance gaps |
|
|
| Developer experience — build time, local setup, debugging tools |
|
|
| Business logic clarity — documented rules, test coverage of logic |
|
|
Total: /50
- 40-50: Healthy — incremental improvement
- 30-39: Aging — targeted modernization
- 20-29: Legacy — systematic modernization needed
- 10-19: Critical — modernize or replace
Dependency Risk Matrix
For each major dependency:
dependency: ""
current_version: ""
latest_version: ""
eol_date: "" # End of life
security_vulns: 0 # Known CVEs
upgrade_difficulty: "trivial | moderate | hard | rewrite"
business_risk: "low | medium | high | critical"
alternatives: []
Priority rules:
- EOL within 12 months → P0
- Known unpatched CVEs → P0
- 3+ major versions behind → P1
- No active maintainer → P1
- Everything else → P2
Phase 2: Strategy Selection
Modernization Strategy Decision Matrix
| Strategy |
When to Use |
Risk |
Cost |
Speed |
Disruption |
| Rehost (lift & shift) |
Datacenter exit, minimal change |
Low |
Low |
Fast |
Low |
| Replatform (lift & optimize) |
Cloud benefits without rewrite |
Low-Med |
Medium |
Medium |
Low-Med |
| Refactor (restructure) |
Good code, bad architecture |
Medium |
Medium |
Medium |
Medium |
| Re-architect (rebuild patterns) |
Monolith→services, new patterns |
High |
High |
Slow |
High |
| Rebuild (rewrite) |
Small system, clear requirements |
Very High |
Very High |
Very Slow |
Very High |
| Replace (buy/SaaS) |
Commodity functionality |
Medium |
Variable |
Fast |
High |
| Retire |
No longer needed |
None |
Negative |
Instant |
Low |
| Retain (do nothing) |
Working fine, other priorities |
None |
Ongoing |
N/A |
None |
Strategy Selection Decision Tree
Is the system still needed?
├─ No → RETIRE
├─ Yes → Is it a commodity (CRM, email, etc.)?
│ ├─ Yes → REPLACE (buy SaaS)
│ └─ No → Is the code maintainable?
│ ├─ Yes → Is the architecture the problem?
│ │ ├─ Yes → RE-ARCHITECT (strangler fig)
│ │ └─ No → Is the infrastructure the problem?
│ │ ├─ Yes → REPLATFORM
│ │ └─ No → REFACTOR incrementally
│ └─ No → Is the system small (<50K LOC)?
│ ├─ Yes → Can requirements be clearly defined?
│ │ ├─ Yes → REBUILD
│ │ └─ No → REFACTOR + RE-ARCHITECT
│ └─ No → STRANGLER FIG (never big-bang rewrite)
The Big Rewrite Anti-Pattern
NEVER do a full rewrite of a large system. It fails 70%+ of the time because:
- The old system keeps getting features — moving target
- Hidden business rules only exist in code — they get lost
- Timeline always 2-3x longer than estimated
- Two systems to maintain during transition
- Team burns out before completion
Always use Strangler Fig instead. Replace piece by piece.
Phase 3: Strangler Fig Pattern
How It Works
- Identify a boundary — a feature, page, or API endpoint
- Build the replacement — new stack, new patterns
- Route traffic — proxy/facade sends requests to new or old
- Verify parity — same behavior, same data
- Cut over — remove the proxy, retire the old code
- Repeat — next boundary
Strangler Facade YAML
facade_name: "[API Gateway / Reverse Proxy / BFF]"
routing_rules:
- path: "/api/users/*"
target: "new-service"
status: "migrated"
migrated_date: "2025-01-15"
- path: "/api/orders/*"
target: "legacy"
status: "planned"
target_date: "2025-Q2"
- path: "/api/reports/*"
target: "legacy"
status: "not-planned"
notes: "Low priority, rarely used"
Migration Sequence Rules
- Start with the easiest, most isolated module — build confidence
- Then the highest-value business capability — prove ROI early
- Leave the hardest, most coupled parts for last — team learns patterns first
- Never migrate auth/identity early — it touches everything
- Migrate data access layer before business logic — clean data = clean migration
- Always keep the old system as fallback until new is proven
Dual-Write / Data Sync Patterns
| Pattern |
When |
Complexity |
Risk |
| Dual write |
Both systems write simultaneously |
High |
Data inconsistency |
| CDC (Change Data Capture) |
Stream changes from old→new DB |
Medium |
Lag, ordering |
| ETL batch sync |
Periodic bulk sync |
Low |
Stale data |
| Event sourcing bridge |
Events from old, replay in new |
High |
Schema mapping |
| Read from new, write to old |
Transition period |
Medium |
Routing complexity |
Golden rule: Pick ONE source of truth. Never let both systems own the same data simultaneously.
Phase 4: Monolith Decomposition
Domain Discovery
Before splitting a monolith, identify bounded contexts:
- Event Storming (preferred) — sticky notes for domain events, commands, aggregates
- Code analysis — find clusters of related classes/tables
- Team analysis — which teams own which features?
- Data coupling analysis — which tables are joined together?
Bounded Context YAML
context_name: ""
description: ""
team: ""
entities: []
commands: []
events_published: []
events_consumed: []
database_tables: []
external_integrations: []
coupling_score: 0 # 0=independent, 10=deeply coupled
extraction_difficulty: "easy | moderate | hard | very-hard"
business_value: "low | medium | high | critical"
Extraction Priority Matrix
Plot contexts on: Business Value (Y) × Extraction Difficulty (X)
|
Easy |
Moderate |
Hard |
| High value |
🟢 Do first |
🟡 Do second |
🟠 Plan carefully |
| Medium value |
🟢 Quick win |
🟡 Evaluate ROI |
🔴 Probably not worth it |
| Low value |
🟡 If easy, why not |
🔴 Skip |
🔴 Definitely skip |
Service Extraction Checklist
For each service being extracted:
Phase 5: Database Modernization
Database Migration Strategies
| Strategy |
Description |
Downtime |
Risk |
| Parallel run |
New DB alongside old, sync both |
Zero |
High complexity |
| Blue-green |
Full copy, switch DNS |
Minutes |
Medium |
| Rolling |
Migrate table by table |
Zero per table |
Medium |
| Big bang |
Stop, migrate, start |
Hours |
High |
Schema Evolution Rules
- Always additive — add columns/tables, never remove in the same release
- Two-phase removal — Release 1: stop writing. Release 2: drop column (after backfill verified)
- Default values always — every new column gets a default
- Backward compatible — old code must work with new schema during rollout
- Index concurrently — never lock production tables
- Test with production-scale data — 100 rows ≠ 100M rows
Data Quality Gates
Before migrating data:
table: ""
row_count_source: 0
row_count_target: 0
count_match: false
checksum_match: false
null_analysis: "pass | fail"
referential_integrity: "pass | fail"
business_rule_validation: "pass | fail"
sample_manual_review: "pass | fail"
performance_benchmark: "pass | fail"
rollback_tested: false
Rule: All gates must pass before cutover. No exceptions.
Phase 6: Cloud Migration
Cloud Readiness Assessment
Score each workload:
| Factor |
Score (1-5) |
Notes |
| Stateless design |
|
|
| Configuration externalized |
|
|
| Logging to stdout |
|
|
| Health check endpoint |
|
|
| Graceful shutdown |
|
|
| Horizontal scalability |
|
|
| Secret management |
|
|
| 12-factor compliance |
|
|
35-40: Cloud-native ready
25-34: Minor modifications needed
15-24: Significant refactoring
8-14: Major redesign required
Cloud Migration Checklist
Cost Optimization from Day 1
- Right-size instances — start small, scale up with data
- Reserved/committed use — only after 3 months of usage data
- Spot/preemptible — for batch jobs, CI/CD, dev/test
- Auto-scaling — scale down at night, weekends
- Storage tiers — hot/warm/cold/archive based on access patterns
- Tag everything — cost allocation by team, service, environment
- Monthly review — unused resources, oversized instances
Phase 7: API Modernization
API Wrapping Pattern
For legacy systems without APIs:
- Screen scraping adapter — parse HTML/mainframe screens
- Database tap — read directly from legacy DB (read-only!)
- File-based integration — watch folders, parse files
- Message queue bridge — legacy writes to queue, new reads
- RPC wrapper — expose existing functions via REST/gRPC
API Contract-First Migration
endpoint: "/api/v2/orders"
legacy_source: "stored_procedure: sp_GetOrders"
new_implementation: "orders-service"
migration_status: "legacy | dual-run | new-only"
contract_changes:
- field: "order_date"
old_format: "MM/DD/YYYY string"
new_format: "ISO 8601"
adapter: "date_format_adapter"
- field: "status"
old_values: ["A", "C", "P"]
new_values: ["active", "completed", "pending"]
adapter: "status_code_mapper"
parity_tests: 47
parity_passing: 47
Phase 8: Testing Strategy
Migration Testing Pyramid
/ Smoke Tests \ ← Whole system alive?
/ Parity Tests \ ← Same behavior old vs new?
/ Integration Tests \ ← Services work together?
/ Contract Tests \ ← API contracts honored?
/ Performance Tests \ ← Not slower than before?
/ Data Validation Tests \ ← Data migrated correctly?
/ Unit Tests \ ← New code works?
Parity Testing Framework
For EVERY migrated feature:
feature: ""
test_type: "api_parity | ui_parity | data_parity"
method: "shadow traffic | replay | parallel run"
sample_size: 0
match_rate: "0%" # Target: 99.9%+
mismatches_investigated: 0
mismatches_accepted: 0 # Known intentional differences
mismatches_bugs: 0
sign_off: false
Shadow traffic — copy production requests to new system, compare responses (don't serve new responses to users yet).
Performance Regression Rules
- P95 latency must not increase >10% vs legacy
- Throughput must meet or exceed legacy under same load
- Database query count must not increase per request
- Memory usage must not increase >20%
- If ANY metric regresses → investigate before proceeding
Phase 9: Team & Process
Modernization Team Structure
| Role |
Responsibility |
When Needed |
| Modernization Lead |
Strategy, sequencing, blockers |
Full-time |
| Legacy Expert |
Knows where the bodies are buried |
Part-time, on-call |
| New Platform Engineer |
Builds target architecture |
Full-time |
| Data Engineer |
Migration, sync, validation |
Phase-dependent |
| QA/Test Engineer |
Parity testing, automation |
Full-time |
| DevOps/Platform |
CI/CD, infrastructure |
Part-time |
| Product Owner |
Business priority, acceptance |
Part-time |
Knowledge Mining from Legacy
The most dangerous part of modernization is losing undocumented business rules.
- Code archaeology — git blame, find oldest unchanged code, understand why
- Interview stakeholders — "What would break if we changed X?"
- Production log analysis — what edge cases actually occur?
- Error handling review — each catch block is a documented business rule
- Test suite review — tests describe expected behavior
- Configuration review — magic numbers, feature flags, overrides
Communication Plan
| Audience |
Frequency |
Content |
| Executive sponsor |
Bi-weekly |
Progress, risks, budget, timeline |
| Engineering team |
Weekly |
Sprint goals, technical decisions, blockers |
| Dependent teams |
Monthly |
Upcoming changes, migration dates, API changes |
| End users |
Per migration |
What's changing, when, how it affects them |
Phase 10: Risk Management
Top 10 Modernization Risks (Pre-Built)
| # |
Risk |
Likelihood |
Impact |
Mitigation |
| 1 |
Undocumented business rules lost |
High |
Critical |
Code archaeology + stakeholder interviews + parity tests |
| 2 |
Timeline underestimation |
Very High |
High |
2x initial estimate, phase-gated checkpoints |
| 3 |
Data migration corruption |
Medium |
Critical |
Checksums, parallel runs, rollback plans |
| 4 |
Feature parity gaps |
High |
High |
Shadow traffic testing, user acceptance testing |
| 5 |
Team knowledge loss (people leave) |
Medium |
High |
Document everything, pair programming, knowledge sharing |
| 6 |
Legacy system changes during migration |
High |
Medium |
Feature freeze or dual-write contract |
| 7 |
Performance regression |
Medium |
High |
Load testing at every phase, performance budgets |
| 8 |
Scope creep (improve while migrating) |
Very High |
Medium |
Strict "migrate, don't improve" rule for Phase 1 |
| 9 |
Integration failures |
Medium |
High |
Contract testing, circuit breakers, fallback routing |
| 10 |
Stakeholder fatigue |
High |
Medium |
Quick wins early, visible progress dashboard |
Kill Criteria
Stop the modernization if:
- Budget exceeds 2x initial estimate with <50% complete
- Key business rules can't be verified after migration
- Team attrition >30% during project
- Legacy system stability degrades due to migration work
- Business context changes (M&A, pivot, sunset)
If kill criteria triggered: Stabilize what's done, document learnings, reassess in 6 months.
Phase 11: Patterns & Playbooks
Language/Framework Migration Patterns
Java → Modern Java (8→17+)
- Records, sealed classes, pattern matching
- Virtual threads (Project Loom) for thread-per-request
- Migrate build: Maven→Gradle or update Maven plugins
- Spring Boot 2→3: javax→jakarta namespace
Python 2→3
- Use
2to3 tool for automated conversion
- Fix: print(), division, unicode, dict methods
- Upgrade dependencies (check py3 compat)
jQuery→React/Vue
- Extract components from page sections
- State management replaces DOM manipulation
- Event handlers become component methods
- Ajax calls become API service layer
Monolith→Microservices
- Strangler fig (see Phase 3)
- Start with read models (reporting, search)
- Extract stateless services first
- Shared database → database-per-service last
On-Prem→Cloud
- Rehost first (lift & shift)
- Then replatform (managed services)
- Then re-architect (cloud-native patterns)
- Never skip steps — each proves value
COBOL/Mainframe Modernization
- API wrapping — expose CICS/IMS transactions as REST APIs
- Screen scraping — automate 3270 terminal interactions
- Gradual extraction — one transaction at a time
- Data replication — DB2/VSAM → PostgreSQL/cloud DB
- Rule extraction — COBOL paragraphs → business rule engine
- Never rewrite all at once — decades of business logic = decades of edge cases
Microservices Anti-Patterns to Avoid
| Anti-Pattern |
Symptom |
Fix |
| Distributed monolith |
Services must deploy together |
Identify and break coupling |
| Shared database |
Multiple services write same tables |
Database-per-service |
| Synchronous chains |
A calls B calls C calls D |
Async events, choreography |
| Nano-services |
Hundreds of tiny services |
Merge related services |
| Shared libraries for business logic |
Library update breaks consumers |
Duplicate code > shared coupling |
| No API versioning |
Breaking changes cascade |
Semantic versioning, deprecation policy |
Phase 12: Metrics & Reporting
Modernization Health Dashboard
project: ""
assessment_date: ""
overall_health: "green | yellow | red"
progress:
modules_total: 0
modules_migrated: 0
modules_in_progress: 0
percent_complete: "0%"
velocity:
modules_per_sprint: 0
estimated_completion: ""
on_track: true
quality:
parity_test_pass_rate: "0%"
production_incidents_from_migration: 0
rollbacks: 0
risk:
open_risks: 0
p0_risks: 0
blocked_items: 0
cost:
budget_total: "$0"
budget_spent: "$0"
budget_remaining: "$0"
burn_rate_monthly: "$0"
100-Point Modernization Quality Rubric
| Dimension |
Weight |
Score (0-10) |
Weighted |
| Strategy clarity |
15% |
|
|
| Risk management |
15% |
|
|
| Testing rigor |
15% |
|
|
| Data integrity |
15% |
|
|
| Architecture quality |
10% |
|
|
| Team capability |
10% |
|
|
| Stakeholder alignment |
10% |
|
|
| Documentation |
10% |
|
|
| Total |
100% |
|
/100 |
90-100: Exemplary — reference project
70-89: Strong — minor improvements
50-69: Adequate — address gaps
Below 50: At risk — pause and reassess
Weekly Status Template
## Modernization Status — Week of [DATE]
### Progress
- Modules migrated this week: [N]
- Total migrated: [N]/[TOTAL] ([X]%)
- On track for [TARGET DATE]: [Yes/No]
### Completed
- [What shipped this week]
### In Progress
- [What's being worked on]
### Blockers
- [What's stuck and what's needed]
### Risks
- [New or changed risks]
### Next Week
- [Plan for next sprint]
Edge Cases
"We need to modernize but can't stop adding features"
- Strangler fig — modernize around new features
- Feature freeze on legacy module ONLY when that module is being migrated
- New features build in new stack from day 1
"We don't know what the system does"
- Start with observability: instrument logging, tracing, metrics
- Run for 2-4 weeks to understand actual usage patterns
- Code coverage analysis shows what code is actually executed
- Interview longest-tenured team members
"Multiple systems need modernizing simultaneously"
- Sequence by dependency order — downstream first
- Shared services (auth, data) get modernized once, reused
- Never parallelize more than 2 modernization streams
"The original developers are gone"
- Treat code as the documentation
- Invest 2-4 weeks in code archaeology before any migration work
- Pair new developers with business stakeholders
- Write tests for existing behavior before changing anything
"We're being acquired / merging systems"
- Map overlapping functionality first
- Pick "winner" system per domain — don't merge codebases
- API integration layer between systems
- 18-month realistic timeline for full consolidation
"Compliance requires the old system"
- Maintain compliance evidence chain during migration
- Dual-audit period with both systems
- Get compliance team involved in migration planning from Day 1
- Document control mapping: old control → new implementation
Natural Language Commands
| Command |
Action |
| "Assess this system for modernization" |
Run full Technical Debt Inventory |
| "Which modernization strategy should we use?" |
Walk through Strategy Decision Tree |
| "Plan a strangler fig migration" |
Generate Strangler Facade YAML + sequence |
| "Decompose this monolith" |
Domain discovery + Bounded Context mapping |
| "Migrate this database" |
Data Quality Gates + migration strategy |
| "Check cloud readiness" |
Run Cloud Readiness Assessment |
| "Create a migration testing plan" |
Build Testing Pyramid with parity tests |
| "What are the risks?" |
Generate Top 10 risk register |
| "How do we migrate from [X] to [Y]?" |
Pattern-specific playbook |
| "Status update for modernization" |
Generate Weekly Status Template |
| "Score this modernization project" |
Run 100-Point Quality Rubric |
| "Should we kill this modernization?" |
Evaluate Kill Criteria |
1---
2name: legacy-system-modernization-engine
3description: Complete methodology for assessing, planning, and executing legacy
4 system modernization — from monolith decomposition to cloud migration. Works
5 for any tech stack, any scale.
6metadata:
7 source: https://skillmd.com/skills/modbender/legacy-system-modernization-engine
8---
9
10# Legacy System Modernization Engine
11
12Complete methodology for assessing, planning, and executing legacy system modernization — from monolith decomposition to cloud migration. Works for any tech stack, any scale.
13
14---
15
16## Phase 1: System Assessment
17
18### Modernization Brief
19
20```yaml
21system_name: "[Name]"
22age_years: 0
23primary_language: ""
24framework: ""
25database: ""
26deployment: "on-prem | VM | container | serverless"
27lines_of_code: 0
28team_size: 0
29monthly_users: 0
30annual_revenue_supported: "$0"
31compliance_requirements: []
32known_pain_points: []
33business_driver: "cost | speed | talent | risk | compliance | scale"
34timeline_pressure: "low | medium | high | critical"
35budget_range: "$0-$0"
36sponsor: ""
37```
38
39### Technical Debt Inventory
40
41Score each dimension 1-5 (1=critical, 5=healthy):
42
43| Dimension | Score | Evidence |
44|-----------|-------|----------|
45| **Code quality** — test coverage, complexity, duplication | | |
46| **Architecture** — coupling, modularity, clear boundaries | | |
47| **Infrastructure** — deployment automation, monitoring, scaling | | |
48| **Dependencies** — outdated libraries, EOL frameworks, security vulns | | |
49| **Data** — schema quality, migration history, backup/recovery | | |
50| **Documentation** — accuracy, coverage, onboarding effectiveness | | |
51| **Operations** — deployment frequency, MTTR, incident rate | | |
52| **Security** — auth patterns, encryption, audit trail, compliance gaps | | |
53| **Developer experience** — build time, local setup, debugging tools | | |
54| **Business logic clarity** — documented rules, test coverage of logic | | |
55
56**Total: /50**
57
58- **40-50**: Healthy — incremental improvement
59- **30-39**: Aging — targeted modernization
60- **20-29**: Legacy — systematic modernization needed
61- **10-19**: Critical — modernize or replace
62
63### Dependency Risk Matrix
64
65For each major dependency:
66
67```yaml
68dependency: ""
69current_version: ""
70latest_version: ""
71eol_date: "" # End of life
72security_vulns: 0 # Known CVEs
73upgrade_difficulty: "trivial | moderate | hard | rewrite"
74business_risk: "low | medium | high | critical"
75alternatives: []
76```
77
78**Priority rules:**
79- EOL within 12 months → P0
80- Known unpatched CVEs → P0
81- 3+ major versions behind → P1
82- No active maintainer → P1
83- Everything else → P2
84
85---
86
87## Phase 2: Strategy Selection
88
89### Modernization Strategy Decision Matrix
90
91| Strategy | When to Use | Risk | Cost | Speed | Disruption |
92|----------|-------------|------|------|-------|------------|
93| **Rehost** (lift & shift) | Datacenter exit, minimal change | Low | Low | Fast | Low |
94| **Replatform** (lift & optimize) | Cloud benefits without rewrite | Low-Med | Medium | Medium | Low-Med |
95| **Refactor** (restructure) | Good code, bad architecture | Medium | Medium | Medium | Medium |
96| **Re-architect** (rebuild patterns) | Monolith→services, new patterns | High | High | Slow | High |
97| **Rebuild** (rewrite) | Small system, clear requirements | Very High | Very High | Very Slow | Very High |
98| **Replace** (buy/SaaS) | Commodity functionality | Medium | Variable | Fast | High |
99| **Retire** | No longer needed | None | Negative | Instant | Low |
100| **Retain** (do nothing) | Working fine, other priorities | None | Ongoing | N/A | None |
101
102### Strategy Selection Decision Tree
103
104```
105Is the system still needed?
106├─ No → RETIRE
107├─ Yes → Is it a commodity (CRM, email, etc.)?
108│ ├─ Yes → REPLACE (buy SaaS)
109│ └─ No → Is the code maintainable?
110│ ├─ Yes → Is the architecture the problem?
111│ │ ├─ Yes → RE-ARCHITECT (strangler fig)
112│ │ └─ No → Is the infrastructure the problem?
113│ │ ├─ Yes → REPLATFORM
114│ │ └─ No → REFACTOR incrementally
115│ └─ No → Is the system small (<50K LOC)?
116│ ├─ Yes → Can requirements be clearly defined?
117│ │ ├─ Yes → REBUILD
118│ │ └─ No → REFACTOR + RE-ARCHITECT
119│ └─ No → STRANGLER FIG (never big-bang rewrite)
120```
121
122### The Big Rewrite Anti-Pattern
123
124**NEVER do a full rewrite of a large system.** It fails 70%+ of the time because:
1251. The old system keeps getting features — moving target
1262. Hidden business rules only exist in code — they get lost
1273. Timeline always 2-3x longer than estimated
1284. Two systems to maintain during transition
1295. Team burns out before completion
130
131**Always use Strangler Fig instead.** Replace piece by piece.
132
133---
134
135## Phase 3: Strangler Fig Pattern
136
137### How It Works
138
1391. **Identify a boundary** — a feature, page, or API endpoint
1402. **Build the replacement** — new stack, new patterns
1413. **Route traffic** — proxy/facade sends requests to new or old
1424. **Verify parity** — same behavior, same data
1435. **Cut over** — remove the proxy, retire the old code
1446. **Repeat** — next boundary
145
146### Strangler Facade YAML
147
148```yaml
149facade_name: "[API Gateway / Reverse Proxy / BFF]"
150routing_rules:
151 - path: "/api/users/*"
152 target: "new-service"
153 status: "migrated"
154 migrated_date: "2025-01-15"
155 - path: "/api/orders/*"
156 target: "legacy"
157 status: "planned"
158 target_date: "2025-Q2"
159 - path: "/api/reports/*"
160 target: "legacy"
161 status: "not-planned"
162 notes: "Low priority, rarely used"
163```
164
165### Migration Sequence Rules
166
1671. **Start with the easiest, most isolated module** — build confidence
1682. **Then the highest-value business capability** — prove ROI early
1693. **Leave the hardest, most coupled parts for last** — team learns patterns first
1704. **Never migrate auth/identity early** — it touches everything
1715. **Migrate data access layer before business logic** — clean data = clean migration
1726. **Always keep the old system as fallback** until new is proven
173
174### Dual-Write / Data Sync Patterns
175
176| Pattern | When | Complexity | Risk |
177|---------|------|-----------|------|
178| **Dual write** | Both systems write simultaneously | High | Data inconsistency |
179| **CDC (Change Data Capture)** | Stream changes from old→new DB | Medium | Lag, ordering |
180| **ETL batch sync** | Periodic bulk sync | Low | Stale data |
181| **Event sourcing bridge** | Events from old, replay in new | High | Schema mapping |
182| **Read from new, write to old** | Transition period | Medium | Routing complexity |
183
184**Golden rule:** Pick ONE source of truth. Never let both systems own the same data simultaneously.
185
186---
187
188## Phase 4: Monolith Decomposition
189
190### Domain Discovery
191
192Before splitting a monolith, identify bounded contexts:
193
1941. **Event Storming** (preferred) — sticky notes for domain events, commands, aggregates
1952. **Code analysis** — find clusters of related classes/tables
1963. **Team analysis** — which teams own which features?
1974. **Data coupling analysis** — which tables are joined together?
198
199### Bounded Context YAML
200
201```yaml
202context_name: ""
203description: ""
204team: ""
205entities: []
206commands: []
207events_published: []
208events_consumed: []
209database_tables: []
210external_integrations: []
211coupling_score: 0 # 0=independent, 10=deeply coupled
212extraction_difficulty: "easy | moderate | hard | very-hard"
213business_value: "low | medium | high | critical"
214```
215
216### Extraction Priority Matrix
217
218Plot contexts on: **Business Value** (Y) × **Extraction Difficulty** (X)
219
220| | Easy | Moderate | Hard |
221|---|---|---|---|
222| **High value** | 🟢 Do first | 🟡 Do second | 🟠 Plan carefully |
223| **Medium value** | 🟢 Quick win | 🟡 Evaluate ROI | 🔴 Probably not worth it |
224| **Low value** | 🟡 If easy, why not | 🔴 Skip | 🔴 Definitely skip |
225
226### Service Extraction Checklist
227
228For each service being extracted:
229
230- [ ] Bounded context clearly defined
231- [ ] API contract designed (OpenAPI spec)
232- [ ] Database separated (no shared tables)
233- [ ] Authentication/authorization integrated
234- [ ] Event publishing for cross-service communication
235- [ ] Circuit breaker for calls back to monolith
236- [ ] Monitoring and alerting configured
237- [ ] Deployment pipeline independent
238- [ ] Feature flag for traffic routing
239- [ ] Rollback plan documented
240- [ ] Performance baseline captured (before/after)
241- [ ] Data migration script tested
242- [ ] Integration tests with monolith passing
243- [ ] Runbook for on-call written
244
245---
246
247## Phase 5: Database Modernization
248
249### Database Migration Strategies
250
251| Strategy | Description | Downtime | Risk |
252|----------|-------------|----------|------|
253| **Parallel run** | New DB alongside old, sync both | Zero | High complexity |
254| **Blue-green** | Full copy, switch DNS | Minutes | Medium |
255| **Rolling** | Migrate table by table | Zero per table | Medium |
256| **Big bang** | Stop, migrate, start | Hours | High |
257
258### Schema Evolution Rules
259
2601. **Always additive** — add columns/tables, never remove in the same release
2612. **Two-phase removal** — Release 1: stop writing. Release 2: drop column (after backfill verified)
2623. **Default values always** — every new column gets a default
2634. **Backward compatible** — old code must work with new schema during rollout
2645. **Index concurrently** — never lock production tables
2656. **Test with production-scale data** — 100 rows ≠ 100M rows
266
267### Data Quality Gates
268
269Before migrating data:
270
271```yaml
272table: ""
273row_count_source: 0
274row_count_target: 0
275count_match: false
276checksum_match: false
277null_analysis: "pass | fail"
278referential_integrity: "pass | fail"
279business_rule_validation: "pass | fail"
280sample_manual_review: "pass | fail"
281performance_benchmark: "pass | fail"
282rollback_tested: false
283```
284
285**Rule: All gates must pass before cutover.** No exceptions.
286
287---
288
289## Phase 6: Cloud Migration
290
291### Cloud Readiness Assessment
292
293Score each workload:
294
295| Factor | Score (1-5) | Notes |
296|--------|-------------|-------|
297| Stateless design | | |
298| Configuration externalized | | |
299| Logging to stdout | | |
300| Health check endpoint | | |
301| Graceful shutdown | | |
302| Horizontal scalability | | |
303| Secret management | | |
304| 12-factor compliance | | |
305
306**35-40**: Cloud-native ready
307**25-34**: Minor modifications needed
308**15-24**: Significant refactoring
309**8-14**: Major redesign required
310
311### Cloud Migration Checklist
312
313- [ ] Network architecture designed (VPC, subnets, security groups)
314- [ ] Identity and access management configured
315- [ ] Data residency requirements verified
316- [ ] Compliance mapping (cloud controls ↔ requirements)
317- [ ] Cost estimation completed (TCO comparison)
318- [ ] Disaster recovery plan updated
319- [ ] Monitoring and alerting migrated
320- [ ] DNS and certificate management planned
321- [ ] CDN configuration
322- [ ] Load testing in cloud environment
323- [ ] Security scanning pipeline
324- [ ] Backup and restore verified
325- [ ] Runbooks updated for cloud operations
326- [ ] Team trained on cloud platform
327- [ ] Vendor lock-in assessment
328
329### Cost Optimization from Day 1
330
331- **Right-size instances** — start small, scale up with data
332- **Reserved/committed use** — only after 3 months of usage data
333- **Spot/preemptible** — for batch jobs, CI/CD, dev/test
334- **Auto-scaling** — scale down at night, weekends
335- **Storage tiers** — hot/warm/cold/archive based on access patterns
336- **Tag everything** — cost allocation by team, service, environment
337- **Monthly review** — unused resources, oversized instances
338
339---
340
341## Phase 7: API Modernization
342
343### API Wrapping Pattern
344
345For legacy systems without APIs:
346
3471. **Screen scraping adapter** — parse HTML/mainframe screens
3482. **Database tap** — read directly from legacy DB (read-only!)
3493. **File-based integration** — watch folders, parse files
3504. **Message queue bridge** — legacy writes to queue, new reads
3515. **RPC wrapper** — expose existing functions via REST/gRPC
352
353### API Contract-First Migration
354
355```yaml
356endpoint: "/api/v2/orders"
357legacy_source: "stored_procedure: sp_GetOrders"
358new_implementation: "orders-service"
359migration_status: "legacy | dual-run | new-only"
360contract_changes:
361 - field: "order_date"
362 old_format: "MM/DD/YYYY string"
363 new_format: "ISO 8601"
364 adapter: "date_format_adapter"
365 - field: "status"
366 old_values: ["A", "C", "P"]
367 new_values: ["active", "completed", "pending"]
368 adapter: "status_code_mapper"
369parity_tests: 47
370parity_passing: 47
371```
372
373---
374
375## Phase 8: Testing Strategy
376
377### Migration Testing Pyramid
378
379```
380 / Smoke Tests \ ← Whole system alive?
381 / Parity Tests \ ← Same behavior old vs new?
382 / Integration Tests \ ← Services work together?
383 / Contract Tests \ ← API contracts honored?
384 / Performance Tests \ ← Not slower than before?
385 / Data Validation Tests \ ← Data migrated correctly?
386 / Unit Tests \ ← New code works?
387```
388
389### Parity Testing Framework
390
391For EVERY migrated feature:
392
393```yaml
394feature: ""
395test_type: "api_parity | ui_parity | data_parity"
396method: "shadow traffic | replay | parallel run"
397sample_size: 0
398match_rate: "0%" # Target: 99.9%+
399mismatches_investigated: 0
400mismatches_accepted: 0 # Known intentional differences
401mismatches_bugs: 0
402sign_off: false
403```
404
405**Shadow traffic** — copy production requests to new system, compare responses (don't serve new responses to users yet).
406
407### Performance Regression Rules
408
409- P95 latency must not increase >10% vs legacy
410- Throughput must meet or exceed legacy under same load
411- Database query count must not increase per request
412- Memory usage must not increase >20%
413- If ANY metric regresses → investigate before proceeding
414
415---
416
417## Phase 9: Team & Process
418
419### Modernization Team Structure
420
421| Role | Responsibility | When Needed |
422|------|---------------|-------------|
423| **Modernization Lead** | Strategy, sequencing, blockers | Full-time |
424| **Legacy Expert** | Knows where the bodies are buried | Part-time, on-call |
425| **New Platform Engineer** | Builds target architecture | Full-time |
426| **Data Engineer** | Migration, sync, validation | Phase-dependent |
427| **QA/Test Engineer** | Parity testing, automation | Full-time |
428| **DevOps/Platform** | CI/CD, infrastructure | Part-time |
429| **Product Owner** | Business priority, acceptance | Part-time |
430
431### Knowledge Mining from Legacy
432
433The most dangerous part of modernization is **losing undocumented business rules**.
434
4351. **Code archaeology** — git blame, find oldest unchanged code, understand why
4362. **Interview stakeholders** — "What would break if we changed X?"
4373. **Production log analysis** — what edge cases actually occur?
4384. **Error handling review** — each catch block is a documented business rule
4395. **Test suite review** — tests describe expected behavior
4406. **Configuration review** — magic numbers, feature flags, overrides
441
442### Communication Plan
443
444| Audience | Frequency | Content |
445|----------|-----------|---------|
446| Executive sponsor | Bi-weekly | Progress, risks, budget, timeline |
447| Engineering team | Weekly | Sprint goals, technical decisions, blockers |
448| Dependent teams | Monthly | Upcoming changes, migration dates, API changes |
449| End users | Per migration | What's changing, when, how it affects them |
450
451---
452
453## Phase 10: Risk Management
454
455### Top 10 Modernization Risks (Pre-Built)
456
457| # | Risk | Likelihood | Impact | Mitigation |
458|---|------|-----------|--------|------------|
459| 1 | Undocumented business rules lost | High | Critical | Code archaeology + stakeholder interviews + parity tests |
460| 2 | Timeline underestimation | Very High | High | 2x initial estimate, phase-gated checkpoints |
461| 3 | Data migration corruption | Medium | Critical | Checksums, parallel runs, rollback plans |
462| 4 | Feature parity gaps | High | High | Shadow traffic testing, user acceptance testing |
463| 5 | Team knowledge loss (people leave) | Medium | High | Document everything, pair programming, knowledge sharing |
464| 6 | Legacy system changes during migration | High | Medium | Feature freeze or dual-write contract |
465| 7 | Performance regression | Medium | High | Load testing at every phase, performance budgets |
466| 8 | Scope creep (improve while migrating) | Very High | Medium | Strict "migrate, don't improve" rule for Phase 1 |
467| 9 | Integration failures | Medium | High | Contract testing, circuit breakers, fallback routing |
468| 10 | Stakeholder fatigue | High | Medium | Quick wins early, visible progress dashboard |
469
470### Kill Criteria
471
472Stop the modernization if:
473- Budget exceeds 2x initial estimate with <50% complete
474- Key business rules can't be verified after migration
475- Team attrition >30% during project
476- Legacy system stability degrades due to migration work
477- Business context changes (M&A, pivot, sunset)
478
479**If kill criteria triggered:** Stabilize what's done, document learnings, reassess in 6 months.
480
481---
482
483## Phase 11: Patterns & Playbooks
484
485### Language/Framework Migration Patterns
486
487**Java → Modern Java (8→17+)**
488- Records, sealed classes, pattern matching
489- Virtual threads (Project Loom) for thread-per-request
490- Migrate build: Maven→Gradle or update Maven plugins
491- Spring Boot 2→3: javax→jakarta namespace
492
493**Python 2→3**
494- Use `2to3` tool for automated conversion
495- Fix: print(), division, unicode, dict methods
496- Upgrade dependencies (check py3 compat)
497
498**jQuery→React/Vue**
499- Extract components from page sections
500- State management replaces DOM manipulation
501- Event handlers become component methods
502- Ajax calls become API service layer
503
504**Monolith→Microservices**
505- Strangler fig (see Phase 3)
506- Start with read models (reporting, search)
507- Extract stateless services first
508- Shared database → database-per-service last
509
510**On-Prem→Cloud**
511- Rehost first (lift & shift)
512- Then replatform (managed services)
513- Then re-architect (cloud-native patterns)
514- Never skip steps — each proves value
515
516### COBOL/Mainframe Modernization
517
5181. **API wrapping** — expose CICS/IMS transactions as REST APIs
5192. **Screen scraping** — automate 3270 terminal interactions
5203. **Gradual extraction** — one transaction at a time
5214. **Data replication** — DB2/VSAM → PostgreSQL/cloud DB
5225. **Rule extraction** — COBOL paragraphs → business rule engine
5236. **Never rewrite all at once** — decades of business logic = decades of edge cases
524
525### Microservices Anti-Patterns to Avoid
526
527| Anti-Pattern | Symptom | Fix |
528|-------------|---------|-----|
529| Distributed monolith | Services must deploy together | Identify and break coupling |
530| Shared database | Multiple services write same tables | Database-per-service |
531| Synchronous chains | A calls B calls C calls D | Async events, choreography |
532| Nano-services | Hundreds of tiny services | Merge related services |
533| Shared libraries for business logic | Library update breaks consumers | Duplicate code > shared coupling |
534| No API versioning | Breaking changes cascade | Semantic versioning, deprecation policy |
535
536---
537
538## Phase 12: Metrics & Reporting
539
540### Modernization Health Dashboard
541
542```yaml
543project: ""
544assessment_date: ""
545overall_health: "green | yellow | red"
546
547progress:
548 modules_total: 0
549 modules_migrated: 0
550 modules_in_progress: 0
551 percent_complete: "0%"
552
553velocity:
554 modules_per_sprint: 0
555 estimated_completion: ""
556 on_track: true
557
558quality:
559 parity_test_pass_rate: "0%"
560 production_incidents_from_migration: 0
561 rollbacks: 0
562
563risk:
564 open_risks: 0
565 p0_risks: 0
566 blocked_items: 0
567
568cost:
569 budget_total: "$0"
570 budget_spent: "$0"
571 budget_remaining: "$0"
572 burn_rate_monthly: "$0"
573```
574
575### 100-Point Modernization Quality Rubric
576
577| Dimension | Weight | Score (0-10) | Weighted |
578|-----------|--------|-------------|----------|
579| Strategy clarity | 15% | | |
580| Risk management | 15% | | |
581| Testing rigor | 15% | | |
582| Data integrity | 15% | | |
583| Architecture quality | 10% | | |
584| Team capability | 10% | | |
585| Stakeholder alignment | 10% | | |
586| Documentation | 10% | | |
587| **Total** | **100%** | | **/100** |
588
589**90-100**: Exemplary — reference project
590**70-89**: Strong — minor improvements
591**50-69**: Adequate — address gaps
592**Below 50**: At risk — pause and reassess
593
594### Weekly Status Template
595
596```markdown
597## Modernization Status — Week of [DATE]
598
599### Progress
600- Modules migrated this week: [N]
601- Total migrated: [N]/[TOTAL] ([X]%)
602- On track for [TARGET DATE]: [Yes/No]
603
604### Completed
605- [What shipped this week]
606
607### In Progress
608- [What's being worked on]
609
610### Blockers
611- [What's stuck and what's needed]
612
613### Risks
614- [New or changed risks]
615
616### Next Week
617- [Plan for next sprint]
618```
619
620---
621
622## Edge Cases
623
624### "We need to modernize but can't stop adding features"
625- **Strangler fig** — modernize around new features
626- Feature freeze on legacy module ONLY when that module is being migrated
627- New features build in new stack from day 1
628
629### "We don't know what the system does"
630- Start with observability: instrument logging, tracing, metrics
631- Run for 2-4 weeks to understand actual usage patterns
632- Code coverage analysis shows what code is actually executed
633- Interview longest-tenured team members
634
635### "Multiple systems need modernizing simultaneously"
636- Sequence by dependency order — downstream first
637- Shared services (auth, data) get modernized once, reused
638- Never parallelize more than 2 modernization streams
639
640### "The original developers are gone"
641- Treat code as the documentation
642- Invest 2-4 weeks in code archaeology before any migration work
643- Pair new developers with business stakeholders
644- Write tests for existing behavior before changing anything
645
646### "We're being acquired / merging systems"
647- Map overlapping functionality first
648- Pick "winner" system per domain — don't merge codebases
649- API integration layer between systems
650- 18-month realistic timeline for full consolidation
651
652### "Compliance requires the old system"
653- Maintain compliance evidence chain during migration
654- Dual-audit period with both systems
655- Get compliance team involved in migration planning from Day 1
656- Document control mapping: old control → new implementation
657
658---
659
660## Natural Language Commands
661
662| Command | Action |
663|---------|--------|
664| "Assess this system for modernization" | Run full Technical Debt Inventory |
665| "Which modernization strategy should we use?" | Walk through Strategy Decision Tree |
666| "Plan a strangler fig migration" | Generate Strangler Facade YAML + sequence |
667| "Decompose this monolith" | Domain discovery + Bounded Context mapping |
668| "Migrate this database" | Data Quality Gates + migration strategy |
669| "Check cloud readiness" | Run Cloud Readiness Assessment |
670| "Create a migration testing plan" | Build Testing Pyramid with parity tests |
671| "What are the risks?" | Generate Top 10 risk register |
672| "How do we migrate from [X] to [Y]?" | Pattern-specific playbook |
673| "Status update for modernization" | Generate Weekly Status Template |
674| "Score this modernization project" | Run 100-Point Quality Rubric |
675| "Should we kill this modernization?" | Evaluate Kill Criteria |