Legacy Subsystem Deconstruction and Boundary Synthesis Spec
Synthesize monolithic code dependencies, database schemas, and access patterns into an isolated domain service boundary specification.
Use this template when planning to decouple a complex legacy module into a modular service or clean package. It synthesizes static analysis, shared data dependencies, and domain models into an exact technical extraction blueprint.
Role: Principal Enterprise Software Architect specializing in domain-driven design and legacy monolith modernization.
Context
- Monolith Target Subsystem: {{monolith_subsystem_name}}
- Dependency Graph & Code Metrics: {{dependency_graph_summary}}
- Shared Data Access Patterns: {{data_access_patterns}}
- Target Availability & Latency SLAs: {{target_sla_requirements}}
- Responsible Engineering Pod: {{team_ownership_model}}
- Supported Communication Protocols: {{integration_protocols}}
Task
Synthesize coupling data, database access paths, and business domain models to produce a service extraction specification that defines clean interface boundaries, transactional decoupling strategies, and migration phases.
Method
- Analyze {{dependency_graph_summary}} to isolate ingress call sites and shared in-memory object references within {{monolith_subsystem_name}}.
- Evaluate {{data_access_patterns}} to identify shared tables, cross-domain foreign keys, and distributed transaction dependencies.
- Apply Domain-Driven Design principles to establish new bounded context interfaces and entities.
- Design synchronous and asynchronous contracts utilizing {{integration_protocols}} while preserving {{target_sla_requirements}}.
- Define a data decoupling strategy, selecting between event-driven synchronization, dual-writing, or transactional outbox patterns.
- Formulate anti-corruption layers (ACL) to shield new boundary interfaces from legacy monolithic models during the transition.
- Structure a phased migration sequence that minimizes runtime risk and aligns with {{team_ownership_model}} capabilities.
Constraints
- MUST explicit specify data ownership boundaries, prohibiting shared raw SQL queries between domains.
- MUST NOT introduce distributed two-phase commit (2PC) transactions across service boundaries.
- Interface definitions MUST include concrete schema payload definitions or protobuf structures.
- Total specification length must remain between 800 and 1500 words.
Output format
- Target Bounded Context & Interface Contracts (Protobuf/OpenAPI spec format)
- Data Model Decoupling & Schema Migration Blueprint
- Anti-Corruption Layer Architecture (Mermaid diagram + explanation)
- Phased Rollout & Fallback Matrix (Ordered stages: Shadow -> Dual-Run -> Cutover)
Self-review
- Confirm that no shared database tables remain without a clear single-owner service assigned.
- Ensure latency overhead introduced by {{integration_protocols}} stays within {{target_sla_requirements}}.
- Validate that all migration phases are independently testable and rollback-safe.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.