
Ddd Architecture Evaluator
- 14 installs
- 1 repo stars
- Updated July 29, 2026
- full-statck-skills/ddd-skills
Assesses DDD implementation health with a 5-level maturity model, fitness scoring, technical-debt quantification, and an evolution roadmap.
About
Evaluates DDD architecture health via a maturity model, multi-dimension fitness scoring, and technical-debt quantification, then plans architecture evolution. A developer uses it to assess DDD maturity or plan migration from MVC to DDD.
- 5-level DDD maturity checklist
- Weighted fitness scoring across five dimensions
Ddd Architecture Evaluator by the numbers
- 14 all-time installs (skills.sh)
- Ranked #783 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
- Data as of Jul 30, 2026 (Skillselion catalog sync)
npx skills add https://github.com/full-statck-skills/ddd-skills --skill ddd-architecture-evaluatorAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 14 |
|---|---|
| repo stars | ★ 1 |
| Last updated | July 29, 2026 |
| Repository | full-statck-skills/ddd-skills ↗ |
What it does
Assesses DDD implementation health with a 5-level maturity model, fitness scoring, technical-debt quantification, and an evolution roadmap.
Files
DDD Architecture Evaluator
Architecture evaluation & evolution — systematically assess DDD health, quantify technical debt, and plan architecture evolution. Supports any project type (Java/Go/Python/TS/.NET) with a structured, repeatable process.
When to read
打开此文档参考流程时可以开始评估。当用户问及架构评估、DDD 成熟度、技术债务量化或架构演进时参考:
- "帮我评估一下项目架构" → 直接开始 Workflow
- "我们的 DDD 做得怎么样" → 从成熟度评估开始
- "技术债务太高了怎么办" → 从技术债务量化开始
- "需要从 MVC 迁移到 DDD" → 从演进路线图开始
Workflow
Step 1: Assess Maturity
→ Run 5-level DDD maturity checklist (L1 → L5)
→ Identify current level vs target level (L3 is sufficient for most projects)
→ Output: Maturity level + per-level pass/fail + key gaps
Step 2: Evaluate Fitness
→ Score 5 dimensions: Business Alignment (25%), Team Fit (25%),
Technology Fit (20%), Evolution Capability (15%), Delivery Efficiency (15%)
→ Calculate weighted fitness score
→ Output: Dimension scores + total fitness + green/yellow/orange/red rating
Step 3: Quantify Debt
→ Structural debt (P0, weight 0.5) — layer violations, circular deps, anemic entities
→ Design debt (P1, weight 0.3) — oversized aggregates, missing VOs/events
→ Testing debt (P2, weight 0.2) — domain unit test coverage
→ Output: Total debt score + health rating (green/mild/moderate/severe)
Step 4: Plan Evolution
→ 4-phase roadmap: Emergency (1-2w) → Short-term (2-4w) →
Mid-term (1-3m) → Long-term (ongoing)
→ Migration risk assessment with Strangler Fig strategy
→ Output: Phased roadmap + risk matrix + next assessment dateBoundary
✅ 擅长处理
| Area | What It Delivers |
|---|---|
| DDD 成熟度评估 | L1-L5 逐级检查清单 + 得分计算 + 关键差距分析 |
| 架构适配度五维评估 | Business / Team / Technology / Evolution / Delivery 加权评分 |
| 技术债务量化 | 结构/设计/测试三类债务 + 加权分数 + 四档健康评级 |
| 架构演进路线图 | 4 阶段演进计划 + 每阶段时间估算 + 优先级排序 |
| 迁移风险评估 | Strangler Fig 渐进迁移方案 + 风险矩阵 + 回退策略 |
| 周期性架构健康检查 | 结构化评估报告 + 改进项追踪 + 下一次评估时间建议 |
⚠️ 需要条件
1. 项目有代码可审:项目已运行一段时间,有实际代码库(全新项目建议用 ddd-architecture-selector) 2. 团队可提供项目背景:需要参考架构文档、代码结构、团队规模等信息 3. 明确的评估目标:建议指定评估焦点(整体成熟度 / 特定模块评估 / 迁移可行性)
❌ 不适用 / 超出范围
1. 代码级审查 → 使用 ddd-code-reviewer(反模式检测、分层合规检查) 2. 新项目架构选型 → 使用 ddd-architecture-selector(5 种架构对比决策矩阵) 3. DDD 入门学习 → 使用 ddd-architecture-awesome(概念速查、充血vs贫血对比) 4. 架构具体落地实现 → 分别使用 ddd-architecture-layered / onion / hexagonal / clean / cola
Security & 安全说明
本 Skill 是非侵入式分析框架。评估时不访问代码库、不收集项目数据、不上传任何信息。所有评估结果基于用户提供的上下文在当前对话中完成,不存储、不传输至第三方。用户自行决定是否披露项目结构信息。
DDD Maturity 5-Level Model
| Level | Name | Focus | Pass Threshold |
|---|---|---|---|
| L1 | Ad Hoc(初始级) | 3-layer + anemic entities + all logic in Service | ≥ 5/7 |
| L2 | Aware(认知级) | Partial rich model + VOs in use + team awareness | ≥ 3/5 |
| L3 | Applied(实践级) | Aggregate boundaries + Domain zero-deps + rich entities | ≥ 5/7 |
| L4 | Scaled(规模化级) | Multi-BC + CQRS + automated ArchUnit CI | ≥ 5/7 |
| L5 | Optimized(优化级) | Continuous evolution + ES + ADR + debt dashboard | ≥ 5/7 |
完整逐级检查清单见 maturity-levels-detail.md。
Architecture Fitness 5-Dimension Assessment
| Dimension | Weight | Score 1-5 | What to Check |
|---|---|---|---|
| Business Alignment | 25% | 1-5 | Does architecture match business complexity? Over/under-engineered? |
| Team Fit | 25% | 1-5 | Does team understand and follow conventions? Violation rate? |
| Technology Fit | 20% | 1-5 | Does tech stack support the architecture? Friction points? |
| Evolution Capability | 15% | 1-5 | Can new BCs be added? Refactoring cost? Module coupling? |
| Delivery Efficiency | 15% | 1-5 | Feature delivery cycle vs industry baseline? Architecture overhead? |
Total Fitness = BA×0.25 + TF×0.25 + TechF×0.20 + EC×0.15 + DE×0.15
Score interpretation:
≥ 4.0 → 🟢 Excellent
3.0-3.9 → 🟡 Adequate
2.0-2.9 → 🟠 Concerning
< 2.0 → 🔴 CriticalSee fitness-assessment-template.md for full scoring rubrics and assessment prompts.
Technical Debt Quantification
Category Breakdown
| Category (Priority) | Weight | Metrics |
|---|---|---|
| Structural Debt (P0) | 0.5 | Layer violation ratio, circular dependency count, anemic entity %, framework leak % |
| Design Debt (P1) | 0.3 | Oversized aggregate ratio, missing domain event ratio, VO missing rate, cross-aggregate refs |
| Testing Debt (P2) | 0.2 | Domain unit test coverage, aggregate root test coverage, integration test coverage |
Calculation
Total Debt = Structural×0.5 + Design×0.3 + Testing×0.2
| Score | Rating | Action |
|---|---|---|
| ≤ 20 | 🟢 Healthy | 无需干预 |
| 21–40 | 🟡 Mild | 定期偿还 |
| 41–60 | 🟠 Moderate | 本季度制定计划 |
| > 60 | 🔴 Severe | 立即启动重构 |
详细方法论和计算示例见 debt-calculation-guide.md。
4-Phase Evolution Roadmap
Traditional 3-Layer → DDD 4-Layer → DDD + Rich Domain → Hexagonal/Clean → Microservices + DDD| Phase | Duration | Focus | Key Actions |
|---|---|---|---|
| 1. Emergency (止血) | 1-2 weeks | Fix P0 violations | Cut layer violations, remove circular deps, fix cross-aggregate refs |
| 2. Short-term (微重构) | 2-4 weeks | Core domain richness | Rich-fy core aggregates, introduce VOs (Money/Phone/Address), add domain events |
| 3. Mid-term (架构升级) | 1-3 months | Architecture upgrade | Split monolith into BCs, adopt CQRS (L1 start), upgrade pattern as needed |
| 4. Long-term (持续演进) | Ongoing | Continuous evolution | Monthly fitness check, debt dashboard, ADR recording, team DDD training |
Migration Risk Assessment
Pre-Migration Checklist
- ☐ Architecture documented (C4 / ADR)
- ☐ Business complexity assessment done
- ☐ Team DDD knowledge assessed
- ☐ Migration scope defined (full vs incremental)
- ☐ Target architecture agreed (team + stakeholders)
- ☐ Rollback plan established (≤ 4 hours)
Strangler Fig — New features → target arch; old features → keep + gradually replace; core aggregates → migrate first.
Risk Matrix
| Risk Level | Impact | Response |
|---|---|---|
| High | Core business logic | Canary release + automated rollback |
| Medium | Non-core features | Parallel run with traffic mirroring |
| Low | Read-only / queries | Direct switch with performance validation |
See migration-risk-checklist.md for full migration assessment templates.
Gotchas
常见评估陷阱见 references/gotchas.md。
FAQ
| Question | Answer |
|---|---|
| 评估频率? | 推荐季度评估。新功能频繁受阻、债务影响交付、重大业务变更时应触发。 |
| 一次评估要多久? | 小型 1-2h,中型 0.5-1 天,大型 2-3 天。首次较长,后续可复用基线。 |
| 所有项目都需要 Level 5? | 不是。Level 3 对大多数业务系统已足够。Level 4-5 适用于核心金融、交易系统。 |
| 如何度量进步? | 建立基线,每次对比:成熟度变化、债务分数、改进项完成率(目标 ≥ 80%)。 |
| 评估后下一步? | 修复 P0 → 核心域充血 → 架构升级 → 持续演进。每个阶段后快速复审。 |
Keywords
DDD maturity, architecture fitness, technical debt, architecture evolution, migration assessment, Strangler Fig, bounded context, CQRS, Event Sourcing, architecture decision record, ADR, technical debt quantification, 架构评估, 成熟度模型, 技术债务量化, 架构演进, 迁移风险, 架构适配度, 分层合规
References
- maturity/assessment-workflow.md — Maturity assessment preparation, session workflow, and common traps
- maturity/maturity-levels-detail.md — Per-level detailed checklists with scoring
- fitness/scoring-rubric.md — Scoring rubric with context-based calibration
- fitness/fitness-assessment-template.md — 5-dimension scoring rubrics and prompts
- debt/repayment-strategies.md — Debt repayment strategies and prioritization matrix
- debt/debt-calculation-guide.md — Technical debt methodology with examples
- migration/strangler-fig-detailed.md — Detailed Strangler Fig migration planning
- migration/migration-risk-checklist.md — Migration readiness checklist and risk matrix
- evolution-cases.md — Real-world evolution case studies (e-commerce, FinTech, SaaS)
- code-smells-diagnosis.md — Architecture anti-patterns and diagnosis
- migration-path.md — 6-step MVC-to-DDD migration path
- partme-11-ddd-refactoring.md — DDD refactoring case study with enterprise modeling
- gotchas.md — 评估常见陷阱(评分偏差、迁移成本、团队能力等)
Architecture Evaluation Report — Cloud-Native B2B Platform
Date: 2026-05-29 Project: PartMe Connect (Kubernetes + Go microservices, 12 developers) Evaluator: DDD Architecture Evaluator
Maturity Level: 3 (Applied)
| Level | Result | Key Gaps |
|---|---|---|
| L1 Ad Hoc | ✅ Pass | — |
| L2 Aware | ✅ Pass | — |
| L3 Applied | ✅ Pass (5/7) | Bounded contexts defined, domain events in use |
| L4 Scaled | ❌ Fail | One API gateway bundling multiple BCs; no context mapping |
| L5 Optimized | ❌ Fail | No continuous assessment |
Fitness Assessment
| Dimension | Score | Notes |
|---|---|---|
| Business Alignment | 4/5 | Architecture matches multi-tenant needs well |
| Team Fit | 3/5 | Go idiomatic patterns differ from DDD conventions |
| Technology Fit | 4/5 | gRPC + Kafka support event-driven well |
| Evolution Capability | 3/5 | API gateway is bottleneck; BFF pattern needed |
| Delivery Efficiency | 3/5 | Cross-BC features blocked by gateway coupling |
Fitness Score: 3.45/5 🟡 Adequate
Technical Debt: 34.2 🟡 Mild
Recommendations
- Split API gateway per BC (BFF pattern)
- Add explicit context mapping documentation
- Introduce CQRS for the analytics read model
Architecture Evaluation Report — E-Commerce Platform
Date: 2026-05-29 Project: PartMe Shop (Spring Boot + MyBatis, 15 developers) Evaluator: DDD Architecture Evaluator
Maturity Level: 2 (Aware)
| Level | Result | Key Gaps |
|---|---|---|
| L1 Ad Hoc | ✅ Pass | — |
| L2 Aware | ✅ Pass (4/7) | Rich model: 30%, VOs: 3 in use |
| L3 Applied | ❌ Fail (3/7) | No aggregate boundaries, Service contains logic |
| L4 Scaled | ❌ Fail | Single BC, no CQRS |
| L5 Optimized | ❌ Fail | No continuous evolution |
Fitness Assessment
| Dimension | Score | Evidence |
|---|---|---|
| Business Alignment | 3/5 | Architecture reasonable but Order over-engineered for simple CRUD |
| Team Fit | 3/5 | 5/15 devs understand DDD; 20% convention violation rate |
| Technology Fit | 4/5 | MyBatis works with current pattern; JPA would be friction |
| Evolution Capability | 2/5 | Tight coupling between Order↔Inventory↔Payment modules |
| Delivery Efficiency | 3/5 | Feature cycle: 2 weeks (industry benchmark: 1 week) |
Overall Fitness: (3×0.25 + 3×0.25 + 4×0.20 + 2×0.15 + 3×0.15) = 3.05/5
Technical Debt
| Category | Score | Weight | Weighted |
|---|---|---|---|
| Structural (P0) | 24.1 | 0.5 | 12.05 |
| Design (P1) | 26.6 | 0.3 | 7.98 |
| Testing (P2) | 54.4 | 0.2 | 10.88 |
| Total | 30.91 🟡 Mild |
Evolution Roadmap
| Phase | Duration | Actions | Priority |
|---|---|---|---|
| 1. Emergency | 1-2 weeks | Cut circular dep Order↔Inventory; fix cross-aggregate refs | P0 |
| 2. Short-term | 2-4 weeks | Rich-fy Order aggregate; add Money/OrderStatus VOs; add OrderPlaced event | P1 |
| 3. Mid-term | 1-3 months | Split Order/Inventory/Payment BCs; adopt CQRS L1 for order queries | P2 |
| 4. Long-term | Ongoing | Monthly evaluation; ADR tracking; debt dashboard | P3 |
Migration Risk
| Risk Area | Level | Mitigation |
|---|---|---|
| Team learning curve | Medium | Pair programming + weekly DDD lunch session |
| BC split breakage | High | Strangler Fig: new features in new BC, old stays |
| Feature delivery freeze | Medium | Phased migration; no freeze |
| Data consistency | Low | Eventual consistency with Saga for cross-BC ops |
Next Assessment: 2026-08-29 (quarterly)
Architecture Evaluation Report — EdTech SaaS Platform
Date: 2026-05-29 Project: LearnHub (Python Django + PostgreSQL, 18 developers) Evaluator: DDD Architecture Evaluator
Maturity: 2 (Aware)
| Dimension | Score | Notes |
|---|---|---|
| Business Alignment | 3/5 | Django ORM-driven model fights domain thinking |
| Team Fit | 2/5 | Team trained on Django; DDD adoption slow |
| Technology Fit | 2/5 | Django's fat model pattern conflicts with DDD layering |
| Evolution Capability | 3/5 | Course/Enrollment/Assessment could be separate |
| Delivery Efficiency | 2/5 | Assessment module changes risky due to coupling |
Fitness Score: 2.45/5 🟠 Concerning
Technical Debt: 52.0 🟠 Moderate
Recommendations
- Apply Anti-Corruption Layer between Django models and domain
- Extract Assessment as first bounded context (highest ROI)
- Introduce course catalog as value objects (CourseId, LessonId)
- Phase migration: ACL → Assessment BC → Enrollment events → Course BC
Architecture Evaluation Report — FinTech Core Banking
Date: 2026-05-29 Project: FinCore (EJB + Oracle PL/SQL, 50+ developers) Evaluator: DDD Architecture Evaluator
Maturity Level: 1 (Ad Hoc)
| Level | Result | Key Gaps |
|---|---|---|
| L1 Ad Hoc | ✅ Pass (6/7) | 3-layer EJB, stored proc business logic |
| L2 Aware | ❌ Fail (1/7) | One team tried VO; no adoption |
| L3 Applied | ❌ Fail | No aggregates, no domain events |
| L4 Scaled | ❌ Fail | Multiple modules but no bounded contexts |
| L5 Optimized | ❌ Fail | Legacy lock-in |
Fitness Assessment
| Dimension | Score | Evidence |
|---|---|---|
| Business Alignment | 2/5 | PL/SQL logic matches banking complexity but is unmaintanable |
| Team Fit | 1/5 | Most devs know EJB; DDD is foreign; learning cost high |
| Technology Fit | 1/5 | EJB + Oracle is legacy; no modern DDD framework support |
| Evolution Capability | 1/5 | Monolith with PL/SQL → impossible to refactor incrementally |
| Delivery Efficiency | 1/5 | Regulation change: 3 months lead time (industry: 2 weeks) |
Overall Fitness: (2×0.25 + 1×0.25 + 1×0.20 + 1×0.15 + 1×0.15) = 1.25/5
Technical Debt
| Category | Score | Weight | Weighted |
|---|---|---|---|
| Structural (P0) | 78 | 0.5 | 39.0 |
| Design (P1) | 65 | 0.3 | 19.5 |
| Testing (P2) | 82 | 0.2 | 16.4 |
| Total | 74.9 🔴 Severe |
Evolution Roadmap
| Phase | Duration | Actions | Priority |
|---|---|---|---|
| 1. Emergency | 4 weeks | Create ACL around legacy; define ports for top 5 flows | P0 |
| 2. Short-term | 2-3 months | Implement Account port (Hexagonal); parallel run | P1 |
| 3. Mid-term | 4-6 months | Transaction domain + Event Sourcing for audit | P1 |
| 4. Long-term | 6-12 months | Full migration; sunset legacy; CQRS L2 | P2 |
Migration Risk
| Risk Area | Level | Mitigation |
|---|---|---|
| Core system stability | Critical | Canary release + automated rollback within 2 hours |
| Data integrity during migration | High | Checksum validation at each step |
| Team productivity drop | High | Dedicated migration team; rest focuses on features |
| Regulatory compliance | Critical | All flows must pass existing compliance tests before cutover |
| Third-party integration breakage | Medium | ACL isolates legacy interfaces |
Next Assessment: 2026-08-29 (quarterly)
Architecture Evaluation Report — Online Gaming Platform
Date: 2026-05-29 Project: GameVerse (C# .NET + Redis, 15 developers) Evaluator: DDD Architecture Evaluator
Maturity: 3 (Applied)
| Dimension | Score | Notes |
|---|---|---|
| Business Alignment | 5/5 | Domain-driven by nature (Player/Match/Tournament) |
| Team Fit | 4/5 | Strong domain language ingrained in team culture |
| Technology Fit | 4/5 | .NET supports DDD well; Redis for event store |
| Evolution Capability | 3/5 | Tournament BC tightly coupled with Match |
| Delivery Efficiency | 4/5 | Feature cycle: 1 week (industry benchmark) |
Fitness Score: 4.10/5 🟢 Excellent
Technical Debt: 15.8 🟢 Healthy
Key Strength
- Player aggregate is a textbook DDD example with domain events, value objects, and rich behavior
- Match aggregate has proper event-sourced state reconstruction
Minor Issues
- Tournament ↔ Match cross-aggregate refs via ID but some direct object refs remain
- Add Automated ArchUnit validation in CI/CD pipeline
Architecture Evaluation Report — Healthcare HIS System
Date: 2026-05-29 Project: MedCore (Spring Boot + RabbitMQ, Python ML services, 25 developers) Evaluator: DDD Architecture Evaluator
Maturity: 2 (Aware)
| Dimension | Score | Notes |
|---|---|---|
| Business Alignment | 4/5 | Patient-dominant model aligns well |
| Team Fit | 2/5 | Only 3/25 devs understand DDD patterns |
| Technology Fit | 3/5 | RabbitMQ good for events; JPA leaks into domain |
| Evolution Capability | 2/5 | Patient ↔ Appointment ↔ Billing tightly coupled |
| Delivery Efficiency | 2/5 | Average feature cycle: 3.5 weeks |
Fitness Score: 2.70/5 🟠 Concerning
Technical Debt: 48.5 🟠 Moderate
Key Issues & Recommendations
- Domain framework leak: JPA annotations in domain entities
- Cross-aggregate coupling: Patient → Appointment direct DB joins
- Missing domain events: No AppointmentScheduled or LabOrderPlaced events
- Phase 1: Extract JPA to Infrastructure; make domain POJO-only (2 weeks)
- Phase 2: Define aggregate boundaries; introduce ID-only cross-refs (3 weeks)
Architecture Evaluation Report — IoT Device Management
Date: 2026-05-29 Project: SensorHub (Python FastAPI + MQTT, 10 developers) Evaluator: DDD Architecture Evaluator
Maturity: 2 (Aware)
| Dimension | Score | Notes |
|---|---|---|
| Business Alignment | 4/5 | Device-centric architecture matches IoT naturally |
| Team Fit | 3/5 | Some devs use DDD patterns intuitively |
| Technology Fit | 4/5 | Event-driven by design; MQTT fits domain events |
| Evolution Capability | 3/5 | Device/Alert/Rule could be separate BCs |
| Delivery Efficiency | 3/5 | Rule engine changes cause cascading updates |
Fitness Score: 3.45/5 🟡 Adequate
Technical Debt: 22.1 🟡 Mild
Recommendations
- Formalize Device aggregate boundary (Device/Sensor/Reading)
- Move rule evaluation into a dedicated Bounded Context
- Add DeviceRegistered, AlertTriggered domain events
Architecture Evaluation Report — Legacy System Assessment
Date: 2026-05-29 Project: Retail POS Legacy (ASP.NET + SQL Server, 8 developers, maintain-only mode) Evaluator: DDD Architecture Evaluator
Maturity Level: 1 (Ad Hoc)
| Level | Result | Key Observations |
|---|---|---|
| L1 Ad Hoc | ✅ Pass (7/7) | Classic N-tier app; no DDD concepts found |
| L2 Aware | ❌ Fail (0/7) | Zero DDD adoption |
| L3+ | ❌ Fail | Not applicable |
Fitness Assessment
| Dimension | Score | Evidence |
|---|---|---|
| Business Alignment | 3/5 | N-tier works for POS complexity, but hard to extend |
| Team Fit | 2/5 | Original team left; new team reverse-engineers everything |
| Technology Fit | 2/5 | ASP.NET Framework 4.x → migration needed within 2 years |
| Evolution Capability | 1/5 | Tightly coupled; stored procedures as business layer |
| Delivery Efficiency | 2/5 | Simple bug fix: 3 days; feature: 2-4 weeks |
Overall Fitness: (3×0.25 + 2×0.25 + 2×0.20 + 1×0.15 + 2×0.15) = 2.10/5
Technical Debt
| Category | Score | Weight | Weighted |
|---|---|---|---|
| Structural (P0) | 71 | 0.5 | 35.5 |
| Design (P1) | 58 | 0.3 | 17.4 |
| Testing (P2) | 90 | 0.2 | 18.0 |
| Total | 70.9 🔴 Severe |
Evolution Roadmap
| Phase | Duration | Actions | Priority |
|---|---|---|---|
| 1. Emergency | 2 weeks | Document existing architecture + data flow | P0 |
| 2. Short-term | 1-2 months | Create ACL; isolate legacy from new features | P0 |
| 3. Mid-term | 3-6 months | Build new module in Hexagonal (greenfield); parallel run | P1 |
| 4. Long-term | 6-12 months | Strangler Fig; replace legacy modules one by one | P1 |
Migration Risk
| Risk Area | Level | Mitigation |
|---|---|---|
| Business knowledge loss | Critical | Domain expert interviews + documentation before any change |
| Data migration integrity | High | Checksum comparison at each step |
| Integration with external systems | Medium | ACL maintains existing API contracts |
| Team capacity (maintain + migrate) | High | Dedicated migration team; hire 2 more devs |
| ASP.NET end-of-life | High | Migration must complete within EOL timeline |
Recommendation: Start greenfield development for the new system. Do NOT refactor in-place — the legacy codebase is beyond incremental repair. Use Strangler Fig to route traffic to the new system over 12 months.
Next Assessment: 2026-06-29 (1 month — urgency due to tech EOL risk)
Architecture Evaluation Report — Logistics Platform
Date: 2026-05-29 Project: ShipFlow (Node.js + MongoDB, 8 developers) Evaluator: DDD Architecture Evaluator
Maturity: 1 (Ad Hoc)
| Dimension | Score | Notes |
|---|---|---|
| Business Alignment | 3/5 | Simple CRUD works but tracking complexity rising |
| Team Fit | 2/5 | Start-up team, DDD knowledge minimal |
| Technology Fit | 3/5 | MongoDB flexible but no aggregate enforcement |
| Evolution Capability | 1/5 | Shipment/Tracking/Invoice in one service |
| Delivery Efficiency | 3/5 | Fast now but slowing as features grow |
Fitness Score: 2.50/5 🟠 Concerning
Technical Debt: 55.3 🟠 Moderate
Recommendations
- Start with Event Storming to identify bounded contexts
- Extract Tracking BC first (highest churn)
- Introduce value objects (TrackingStatus, GeoLocation, Money)
- Adopt DDD Layered before considering microservices
Architecture Evaluation Report — SaaS Multi-Tenant Platform
Date: 2026-05-29 Project: PartMe Workspace (COLA v4, 20 developers) Evaluator: DDD Architecture Evaluator
Maturity Level: 3 (Applied)
| Level | Result | Key Gaps |
|---|---|---|
| L1 Ad Hoc | ✅ Pass | — |
| L2 Aware | ✅ Pass | — |
| L3 Applied | ✅ Pass (6/7) | Aggregates defined, domain events in use |
| L4 Scaled | ❌ Fail (4/7) | 1 BC per module but no CQRS yet |
| L5 Optimized | ❌ Fail | No continuous evolution mechanism |
Fitness Assessment
| Dimension | Score | Evidence |
|---|---|---|
| Business Alignment | 4/5 | Architecture matches SaaS multi-tenant needs |
| Team Fit | 4/5 | 12/20 devs comfortable with COLA; violations < 10% |
| Technology Fit | 4/5 | COLA aligns with Spring Boot ecosystem well |
| Evolution Capability | 3/5 | Module coupling increasing; cross-module events needed |
| Delivery Efficiency | 4/5 | Feature cycle: 1.5 weeks (industry: 1-2 weeks) |
Overall Fitness: (4×0.25 + 4×0.25 + 4×0.20 + 3×0.15 + 4×0.15) = 3.85/5
Technical Debt
| Category | Score | Weight | Weighted |
|---|---|---|---|
| Structural (P0) | 8 | 0.5 | 4.0 |
| Design (P1) | 18 | 0.3 | 5.4 |
| Testing (P2) | 25 | 0.2 | 5.0 |
| Total | 14.4 🟢 Healthy |
Evolution Roadmap
| Phase | Duration | Actions | Priority |
|---|---|---|---|
| 1. Emergency | 1 week | Fix 2 known layer violations (domain → infra) | P0 |
| 2. Short-term | 3 weeks | Introduce DomainEventBus; replace direct module calls | P1 |
| 3. Mid-term | 4-6 weeks | CQRS L1 for workspace listing (read is 80% of traffic) | P1 |
| 4. Long-term | Ongoing | Weekly architecture health check; ADR for every major change | P2 |
Migration Risk
| Risk Area | Level | Mitigation |
|---|---|---|
| EventBus breaking changes | Low | Message versioning + backward-compatible events |
| CQRS consistency | Low | Read model refreshed every 5 seconds (acceptable for platform) |
| Team distraction from features | Medium | Ring-fence 1 sprint for each phase; track separately |
Next Assessment: 2026-08-29 (quarterly)
架构反模式与气味 — 诊断+修复
贫血领域模型
| 症状 | 诊断 | 修复 |
|---|---|---|
| Entity 只有 getter/setter | 检查实体类:是否有 void 返回类型的业务方法? | 把 Service 中的业务逻辑搬进 Entity |
| 所有逻辑在 Service | 检查 Service 行数:是否 > 500 行? | 拆分为聚合内方法和领域服务 |
Repository per Table
| 症状 | 诊断 | 修复 |
|---|---|---|
| 每个 DB 表一个 Repository 接口 | grep -r "interface.*Repository" \ | wc -l → 是否远超聚合数? |
OrderItemRepository 独立存在 | OrderItem 是实体还是独立聚合? | 如果是 Order 聚合内的实体,删除独立 Repository |
泄露基础设施
| 症状 | 诊断 | 修复 |
|---|---|---|
Domain 层 import @Entity | grep "import javax.persistence" domain/ | 在 Infrastructure 层创建 PO,Domain 只用纯 Java |
Domain 层 import @Service | grep "import org.springframework" domain/ | 移除框架注解 |
| Domain 层 import JDBC | grep "import java.sql" domain/ | 移到 Infrastructure Repository |
God Aggregate(上帝聚合)
| 症状 | 诊断 | 修复 |
|---|---|---|
| 单个聚合 > 10 个实体 | wc -l domain/{aggregate}/*.java | 按业务子流程拆分 |
| 聚合加载慢 | 检查 N+1 查询 | 拆分聚合 + lazy loading |
| 并发修改冲突 | 检查事务冲突日志 | 拆分聚合减少锁范围 |
跳过 UseCase
| 症状 | 诊断 | 修复 |
|---|---|---|
| Controller 直接调 Repository | grep "repository\." adapter/controller/ | Controller → AppService → Repository |
CRUD Thinking
| 症状 | 诊断 | 修复 |
|---|---|---|
方法名是 save/update/delete | grep "public.*save\ | update\ |
| 实体没有业务含义的方法 | 检查方法是否反映业务操作 | 用领域语言重命名 |
不成熟的 CQRS
| 症状 | 诊断 | 修复 |
|---|---|---|
| 读写负载相似却引入了 CQRS | 检查读 QPS vs 写 QPS 差异 | 先共用模型,差异显著时再分离 |
| 引入了 Event Sourcing 但不需要审计 | 检查业务是否真的需要事件溯源 | 降级到 L1 或 L2 |
跨聚合事务
| 症状 | 诊断 | 修复 |
|---|---|---|
一个 @Transactional 操作多个聚合 | grep "@Transactional" \ | grep -c "save\ |
值对象滥用(设计气味)
| 症状 | 诊断 | 修复 |
|---|---|---|
| 每个 String 都包装成值对象 | 检查 VO 类数量 / 实体数量 比值 | 只在有业务含义时用 VO(Money ✓, Email ✓, NameString ✗) |
修复优先级
P0(阻止合并):
1. 领域层去框架化
2. 切断循环依赖
3. 修复跨聚合引用
P1(下个版本前):
4. Repository 返回聚合根
5. Controller 去业务化
6. App 层去 SQL
P2(持续改进):
7. 聚合瘦身(>5 实体 → 拆分)
8. 补充领域事件
9. String → Value Object 替换Technical Debt Calculation Guide
Debt Identification Methods
Structural Debt (P0) — Weight: 0.5
| Metric | Detection Method | Scoring |
|---|---|---|
| Layer violation ratio | grep for domain → infra imports | violations / total files × 100 |
| Circular dependency count | jdepend / archunit | each cycle = 5 pts |
| Anemic entity ratio | entities with only getter/setter / total entities | ratio × 100 |
| Framework leak ratio | domain files with Spring/JPA imports / total domain files | ratio × 100 |
Structural Debt Score = Σ(metric_scores) / 4
Score range: 0-100Design Debt (P1) — Weight: 0.3
| Metric | Detection Method | Scoring |
|---|---|---|
| Oversized aggregate ratio | aggregates with > 5 entities / total aggregates | ratio × 100 |
| Missing domain event ratio | key operations without events / total operations | ratio × 100 |
| Value object missing rate | String fields replaceable by VO / total fields | ratio × 100 |
| Cross-aggregate ref count | direct object references between aggregates | each = 3 pts |
Design Debt Score = Σ(metric_scores) / 4
Score range: 0-100Testing Debt (P2) — Weight: 0.2
| Metric | Detection Method | Scoring |
|---|---|---|
| Domain unit test coverage | line coverage for domain module | (100 - coverage%) |
| Aggregate root test coverage | distinct aggregate root tests / total aggregate roots | (100 - ratio × 100) |
| Integration test coverage | integration tests / infrastructure classes | (100 - ratio × 100) |
Testing Debt Score = Σ(metric_scores) / 3
Score range: 0-100Final Calculation
Total Debt = Structural × 0.5 + Design × 0.3 + Testing × 0.2
Thresholds:
≤ 20 → 🟢 Healthy (no action needed)
21-40 → 🟡 Mild (schedule repayment)
41-60 → 🟠 Moderate (create repayment plan this quarter)
> 60 → 🔴 Severe (start refactoring immediately)Example Calculation
Structural:
Layer violations: 12 files / 50 total = 24%
Circular dependencies: 2 cycles × 5 = 10
Anemic entities: 5/8 = 62.5%
Average: (24 + 10 + 62.5) / 4 = 24.1
Design:
Oversized aggregates: 2/6 = 33.3%
Missing events: 3/10 = 30%
VO missing rate: 40%
Cross-aggregate refs: 1 × 3 = 3
Average: (33.3 + 30 + 40 + 3) / 4 = 26.6
Testing:
Domain coverage: 100 - 45% = 55
Aggregate root testing: 100 - (3/6 × 100) = 50
Integration testing: 100 - (5/12 × 100) = 58.3
Average: (55 + 50 + 58.3) / 3 = 54.4
Total = 24.1 × 0.5 + 26.6 × 0.3 + 54.4 × 0.2
= 12.05 + 7.98 + 10.88
= 30.91 → 🟡 MildArchitecture Evolution — Real-World Cases
Case 1: E-Commerce Platform — MVC to DDD Layered
Context: 3-year old e-commerce platform, 15 developers, Spring Boot + MyBatis.
Initial State: Traditional 3-layer MVC. OrderService has 2,500 lines. Entity classes are anemic.
Trigger for Evaluation: New feature (flash sales) requires complex inventory logic. Monolithic OrderService is the bottleneck.
Evaluation Result:
- Maturity: Level 2 (Aware) — partial value objects, no aggregates
- Debt: 52 (Moderate 🟠)
- Recommendation: DDD Layered + Strangler Fig
Evolution Phases:
Phase 1 (2 weeks): Extract core aggregates
→ Order aggregate: Order(shipTo, items, total, status)
→ Inventory aggregate: Inventory(sku, quantity, reserved)
→ Cut circular dependency between Order ↔ Inventory
Phase 2 (3 weeks): Rich domain model
→ Order.pay(), Order.cancel(), Order.ship()
→ Value objects: Money, OrderStatus, ShippingAddress
→ Domain events: OrderPlaced, PaymentConfirmed
Phase 3 (4 weeks): Bounded context split
→ Order BC: order-service (new)
→ Inventory BC: inventory-service (new)
→ Payment BC: payment-service (new)
→ Event communication via RabbitMQ
Phase 4 (2 weeks): CQRS L1 for order read model
→ OrderQueryService (optimized for listing/aggregation)
→ Shared write DB, dedicated read viewsOutcome After 3 Months:
- Maturity: Level 3 (Applied)
- Debt: 18 (Healthy 🟢)
- New feature delivery: 2 weeks → 4 days
- Team confidence: High
Case 2: FinTech Core — Hexagonal Migration
Context: 8-year old banking core system, 50+ developers, multiple integration points.
Initial State: Monolith with EJB + Oracle PL/SQL stored procedures. Business logic in DB.
Trigger for Evaluation: Regulatory requirement changes every 6 months. Current system takes 3 months to implement any change.
Evaluation Result:
- Maturity: Level 1 (Ad Hoc)
- Debt: 78 (Severe 🔴)
- Recommendation: Hexagonal Architecture + Strangler Fig over 12 months
Evolution Phases:
Phase 1 (2 months): Port identification
→ Define inbound ports (UseCases) for top 5 core flows
→ Define outbound ports (AccountRepository, LedgerGateway)
→ Create anti-corruption layer for legacy EJB
Phase 2 (3 months): Account domain — first port
→ New Account aggregate in Hexagonal style
→ Parallel run: new system reads from legacy, writes to new DB
→ Canary release for account balance queries (non-critical reads)
Phase 3 (4 months): Transaction domain
→ Transaction aggregate + Event Sourcing for audit trail
→ CQRS L2: write DB (EventStore) + read DB (Postgres materialized views)
→ Integration with external settlement systems via outbound ports
Phase 4 (3 months): Full cutover
→ Migrate remaining flows (interest calculation, fee assessment)
→ Sunset legacy modules after 6-month parallel run
→ Architectural fitness monitoring dashboardOutcome After 12 Months:
- Maturity: Level 4 (Scaled)
- Debt: 28 (Mild 🟡)
- Regulatory change implementation: 3 months → 3 weeks
Case 3: SaaS Platform — COLA to Event-Driven
Context: Fast-growing SaaS startup, 20 developers, rapid feature iteration.
Initial State: COLA v4 architecture, well-structured, but cross-module coupling growing.
Trigger for Evaluation: User sync between modules causes cascading failures. Team wants decoupled event-driven architecture.
Evaluation Result:
- Maturity: Level 3 (Applied)
- Debt: 15 (Healthy 🟢) — well-maintained, but cross-module coupling identified
- Recommendation: Add event bus + gradually migrate to event-driven cross-BC communication
Evolution:
Phase 1 (2 weeks): Introduce DomainEventBus (in-process)
Phase 2 (4 weeks): Extract first event-driven flow (UserCreated → ProvisionTenant)
Phase 3 (6 weeks): Replace direct module calls with events
Phase 4 (ongoing): Add resilience patterns (dead letter, retry, idempotency)Architecture Fitness Assessment Template
5-Dimension Scoring
Dimension 1: Business Alignment
| Score | Description | Evidence Required |
|---|---|---|
| 5 | Architecture perfectly matches business complexity | Business complexity matrix matches architecture layers |
| 4 | Minor over/under-engineering in non-critical areas | ≤ 2 instances of mismatch |
| 3 | Noticeable mismatch in a core domain | 1 core bounded context has wrong architecture level |
| 2 | Significant over/under-engineering across multiple domains | ≥ 2 bounded contexts affected |
| 1 | Architecture fundamentally wrong for the business (e.g., Clean for CRUD) | Complete architecture-business mismatch |
Template Prompt:
Business Alignment Assessment:
- Project type (CRUD / Complex domain / Real-time / Data-heavy):
- Business complexity score (1-5):
- Current architecture complexity score (1-5):
- Gap: {complexity_score - architecture_score}
- Notes:Dimension 2: Team Fit
| Score | Description | Evidence Required |
|---|---|---|
| 5 | Team fully understands and follows conventions | < 5% code violates conventions |
| 4 | Most team members understand; occasional violations | 5-15% violations |
| 3 | Partial understanding; significant violations | 15-30% violations; rework needed |
| 2 | Architecture is foreign to most team members | 30-50% violations; onboarding required |
| 1 | Team ignores architecture entirely | > 50% violations; architecture not followed |
Template Prompt:
Team Fit Assessment:
- Team size:
- Average DDD experience (years):
- Ramp-up time for new members (weeks):
- Code convention violation rate (%):
- Notes:Dimension 3: Technology Fit
| Score | Description | Evidence Required |
|---|---|---|
| 5 | Architecture and tech stack perfectly aligned | No friction points |
| 4 | Minor friction in non-critical layers | 1-2 adaptation points needed |
| 3 | Some friction (e.g., JPA with Clean Architecture) | 3-5 workarounds in place |
| 2 | Significant mismatch requiring middleware / wrappers | Middleware layer needed |
| 1 | Architecture requires different tech stack | Major tech migration needed |
Template Prompt:
Technology Fit Assessment:
- Primary framework/ORM:
- Architecture pattern:
- Known friction points:
- Workarounds in use:
- Notes:Dimension 4: Evolution Capability
| Score | Description | Evidence Required |
|---|---|---|
| 5 | Easy to add new BCs, swap infrastructure | Module isolation proven |
| 4 | Possible with standard effort | Minor refactoring needed |
| 3 | Possible but requires planning | 1-2 sprint prep needed |
| 2 | Difficult; significant rework required | Multi-sprint effort |
| 1 | Monolith with tightly coupled modules | No module isolation |
Template Prompt:
Evolution Capability Assessment:
- BC count:
- Module coupling score (1-5):
- Average refactoring effort (points):
- New feature delivery cycle (weeks):
- Notes:Dimension 5: Delivery Efficiency
| Score | Description | Evidence Required |
|---|---|---|
| 5 | Architecture accelerates delivery | Feature cycle meets targets |
| 4 | Neutral impact on delivery | No significant drag |
| 3 | Architecture slightly slows delivery | 10-20% overhead |
| 2 | Architecture significantly slows delivery | 20-40% overhead |
| 1 | Architecture blocks delivery | Cannot ship without workarounds |
Template Prompt:
Delivery Efficiency Assessment:
- Average feature cycle time (days):
- Architecture overhead (%):
- Deployment frequency:
- Bottleneck layer:
- Notes:Overall Score
Total Fitness = (BA × 0.25 + TF × 0.25 + TT × 0.20 + EC × 0.15 + DE × 0.15)
Weighting rationale:
- Business Alignment & Team Fit: 25% each (people + purpose)
- Technology Fit: 20% (tools)
- Evolution Capability & Delivery Efficiency: 15% each (outcomes)DDD Architecture Evaluation Gotchas
常见评估陷阱,规避误判。
架构评估 ≠ 代码审查
评估关注架构结构、依赖方向、成熟度,而非具体代码质量。代码级问题交给 ddd-code-reviewer。
评分只是指标,不是目标
5 级成熟度评分是相对指标,用于指导改进方向。Level 3 (Applied) 对大多数项目已经足够,强求 Level 5 会过度设计。
忽视迁移成本
指出"需要迁移到 Hexagonal"但没有量化成本和时间。每次评估必须附带分阶段路线图和人力估算。
评估频率失当
月度评估太频繁消耗精力,年度太稀疏错过信号。推荐季度评估 + 重大业务变更时触发评估。
单点评估偏差
单人评估结果可能带有主观偏见。建议至少 2 人独立评估后协商综合结果,可结合 ArchUnit 自动化检查。
只评不跟
报告出完不追踪改进。下次评估必须对比上次改进项完成情况。建议建立 debt dashboard 追踪。
忽略团队能力
推荐了整洁架构但团队只有 3 人且 DDD 零经验,等于把项目推向灾难。架构决策必须匹配团队技能。
一刀切式建议
不同限界上下文可能有不同成熟度。建议对核心域做 Level 3+,支撑域可接受 Level 1-2。
用旧指标评价新架构
迁移后的新模块不应再使用三层架构的指标衡量(如 Service 行数),需建立新的评价基准。
忽略已有资产
完全废弃老代码去重构,而不是用 Strangler Fig 渐进替换。评估应优先考虑保留价值,而非大拆大建。
过度依赖工具
ArchUnit 是检查"约定是否被违反"的工具,不能替代人为判断"约定是否合理"。自动化检查 + 人工审查缺一不可。
把 CQRS 当银弹
不是所有项目都要 CQRS。80% 查询 + 20% 写入的简单场景不需要 CQRS。从 L1 模型分离开始,不要直接跳到 L3 Event Sourcing。
DDD Maturity Levels — Detailed Checklist
Level 1: Ad Hoc (初始级)
| # | Check Item | Pass Criteria |
|---|---|---|
| 1.1 | Architecture pattern | Traditional 3-layer (Controller-Service-Repository) |
| 1.2 | Entity richness | Entity classes have only getters/setters, zero business methods |
| 1.3 | Value objects | No value objects used; all fields are primitives/Strings |
| 1.4 | Aggregates | No aggregate concept; data model is table-driven |
| 1.5 | Domain events | No domain events |
| 1.6 | Repository | Repository is a thin wrapper around ORM/DB |
| 1.7 | Dependencies | Service layer contains all business logic |
Score: 1 point if ≥ 5 items match.
Level 2: Aware (认知级)
| # | Check Item | Pass Criteria |
|---|---|---|
| 2.1 | Partial rich model | ≥ 30% entities have at least one business method |
| 2.2 | Value objects | At least 3 value objects used (e.g., Money, Email, Phone) |
| 2.3 | Entity naming | Entity names use business language (not table names) |
| 2.4 | Service logic | Business logic is moving from Service to Entity |
| 2.5 | Domain awareness | Team can explain DDD concepts but not yet fully applied |
Score: 2 points if ≥ 3 items match.
Level 3: Applied (实践级)
| # | Check Item | Pass Criteria |
|---|---|---|
| 3.1 | Aggregate boundaries | Clear aggregate boundaries; cross-aggregate ID references |
| 3.2 | Repository interfaces | Repository interfaces in Domain, implementations in Infrastructure |
| 3.3 | Domain events | Core business flows publish domain events |
| 3.4 | Layer dependency | Correct dependency direction (Domain has zero framework deps) |
| 3.5 | Entities are rich | ≥ 80% entities have business methods, not just getters/setters |
| 3.6 | Unit of Work | Transaction scope at Application layer, not Domain |
| 3.7 | Bounded context | At least one bounded context defined |
Score: 3 points if ≥ 5 items match.
Level 4: Scaled (规模化级)
| # | Check Item | Pass Criteria |
|---|---|---|
| 4.1 | Multiple BCs | ≥ 2 bounded contexts with explicit context mapping |
| 4.2 | CQRS | CQRS adopted where read/write patterns diverge |
| 4.3 | Auto-validation | Architecture rules validated in CI/CD (ArchUnit) |
| 4.4 | Event-driven | Cross-context communication via events (not direct API calls) |
| 4.5 | Anti-corruption | ACL (Anti-Corruption Layer) for legacy integration |
| 4.6 | Domain service | Domain services used for operations spanning multiple aggregates |
| 4.7 | Testing strategy | Domain layer unit tests, integration tests for infrastructure |
Score: 4 points if ≥ 5 items match.
Level 5: Optimized (优化级)
| # | Check Item | Pass Criteria |
|---|---|---|
| 5.1 | Continuous evolution | Architecture fitness reviewed quarterly |
| 5.2 | Event Sourcing | Event Sourcing applied where audit trail is critical |
| 5.3 | Ubiquitous language | Domain model 100% aligned with business language |
| 5.4 | ADR | Complete Architecture Decision Record traceability |
| 5.5 | Debt dashboard | Technical debt is tracked and actively paid down |
| 5.6 | Automated metrics | Architecture metrics collected and trended over time |
| 5.7 | Team autonomy | Each bounded context team owns its architecture decisions |
Score: 5 points if ≥ 5 items match.
Maturity Score Calculation
Overall Maturity = max(Level where ≥ threshold check items pass)
Example:
L1 items pass: 7/7 ✓
L2 items pass: 4/7 ✓
L3 items pass: 6/7 ✓
L4 items pass: 3/7 ✗ (need 5)
→ Maturity Level: 3 (Applied)从 MVC/贫血到 DDD/充血 — 迁移路径
6 步渐进迁移
传统 MVC(贫血模型)
↓ Step 1: 识别限界上下文与聚合
↓ Step 2: 提取值对象(Money → Email → PhoneNumber)
↓ Step 3: 把业务规则从 Service 搬到 Entity(充血)
↓ Step 4: 引入 Repository 接口(Domain 定义,Infra 实现)
↓ Step 5: 用领域事件替代直接 Service 调用(跨聚合)
↓ Step 6: 把 Controller 变成薄适配器
DDD 分层架构(充血模型)Step 1: 识别限界上下文与聚合
操作:
- 用事件风暴识别领域事件和命令
- 找出聚合根(有独立生命周期、全局唯一 ID)
- 划定聚合边界(一次事务只改一个聚合)
产出:限界上下文清单 + 聚合清单
Step 2: 提取值对象
操作:
- 把 String status → OrderStatus 枚举/类
- 把 BigDecimal amount + String currency → Money 值对象
- 把 String email → Email 值对象(含格式校验)
收益:类型安全、自校验、业务语义清晰
Step 3: 充血化
操作:
- 把 OrderService.pay(orderId) 中的逻辑移到 Order.pay()
- 把 OrderService.cancel(orderId, reason) 移到 Order.cancel(reason)
- 把 OrderService.calculateTotal(orderId) 移到 Order.calculateTotal()
检验标准:Order 实体不再只有 getter/setter
Step 4: 引入 Repository 接口
操作:
- 在 Domain 层定义
interface OrderRepository { save(); findById(); } - 在 Infrastructure 层实现(JPA/MyBatis)
- 应用服务注入接口,不直接依赖 ORM
检验:Domain 层无 @Entity, @Repository, @Table
Step 5: 领域事件替代直接调用
操作:
- 跨聚合操作改为
addDomainEvent(new OrderPaid(orderId)) - 应用层统一发布领域事件
- 事件处理器完成后续操作
收益:聚合解耦,支持 1→N 订阅
Step 6: Controller 薄化
操作:
- Controller 只做协议转换(HTTP → Command)
- 业务逻辑全部在 Domain + Application
- DTO 转换在 Application 层完成
检验:Controller 无 if/else 业务判断
源代码
Migration Risk Assessment Checklist
Pre-Migration Readiness
| # | Check Item | Status | Notes |
|---|---|---|---|
| 1 | Current architecture fully documented | ☐ | ADR, C4 diagrams up to date |
| 2 | Business complexity assessment complete | ☐ | Is migration worth the investment? |
| 3 | Team DDD knowledge assessed | ☐ | Training needs identified |
| 4 | Migration scope defined | ☐ | Full vs incremental |
| 5 | Target architecture agreed upon | ☐ | Team and stakeholders aligned |
| 6 | Rollback plan established | ☐ | Maximum 4 hours to rollback |
| 7 | Stakeholder buy-in secured | ☐ | Business + engineering alignment |
| 8 | Success metrics defined | ☐ | Measurable before/after comparison |
Risk Scoring Matrix
| Risk Level | Impact | Probability | Score | Response |
|---|---|---|---|---|
| Critical | Business operation disruption | High | 16-25 | Canary + automated rollback |
| High | Core feature degradation | Medium | 10-15 | Feature flag + manual rollback |
| Medium | Non-core feature impact | Low | 5-9 | Parallel run + monitoring |
| Low | Performance regression | Very Low | 1-4 | Direct switch + performance test |
Risk = Impact × Probability (1-5 each)
Strangler Fig Migration Strategy
Step 1: Route new features to target architecture
Step 2: Wrap legacy modules with anti-corruption layer
Step 3: Migrate core aggregates first (highest ROI)
Step 4: Gradually replace legacy modules
Step 5: Remove legacy when all consumers migratedMigration Phasing Template
Phase | Duration | Scope | Risk | Rollback
------|----------|-------|:----:|---------
Pilot | 1-2 weeks | Single aggregate (read-only) | Low | Disable feature flag
Wave 1 | 2-4 weeks | Core write operations | Medium | Traffic switch back
Wave 2 | 1-2 months | Full bounded context | High | Canary release
Wave 3 | 2-3 months | Remaining modules | Medium | Per-module rollbackArchitecture-Specific Risks
| Current → Target | Key Risks | Mitigation |
|---|---|---|
| MVC → DDD Layered | Team learning curve, service extraction complexity | Training + pair programming |
| Layered → Hexagonal | Port design mistakes, over-abstraction | Start with 1 port, iterate |
| Monolith → Microservices | Network latency, data consistency, distributed transactions | Eventual consistency + Saga |
| Clean → Event Sourcing | Event schema evolution, replay complexity | Versioned events + snapshot |
| CQRS L1 → L3 | Eventual consistency gaps, projection rebuild time | Idempotency + throttled rebuild |
Post-Migration Validation
| # | Validation Item | Measure |
|---|---|---|
| 1 | Feature parity | All old test cases pass |
| 2 | Performance | P95 latency ≤ 1.2× baseline |
| 3 | Data integrity | Row count + checksum match |
| 4 | Team productivity | Feature cycle time not increased |
| 5 | Architecture compliance | ArchUnit score ≥ 85% |
进入两千年后,随着互联网应用的快速发展,很多传统企业开始触网,建设自己的互联网电商平台。后来又随着微信和 App 等移动互联应用的兴起,又形成了新一轮的移动应用热潮。这些移动互联应用大多面向个人或者第三方,市场和需求变化快,需要以更敏捷的速度适应市场变化,为了保持快速响应能力和频繁发版的要求,很多时候这些移动互联网应用是独立于传统核心系统建设的,但两者承载的业务大部分又都是同质的,因此很容易出现业务能力重叠的问题。
阿里巴巴过去带动了传统企业向互联网电商转型。而如今又到了一个新的历史时期,在阿里巴巴提出中台战略后,很多企业又紧跟它的步伐,高举中台大旗,轰轰烈烈地开始了数字化转型之路。
那么传统企业在中台转型时,该如何从错综复杂的业务中构建中台业务模型呢?今天我就用一个传统企业中台建模的案例,带你一起用 DDD 的设计思想来构建中台业务模型。
传统企业应用分析
互联网电商平台和传统核心应用,两者面向的渠道和客户不一样,但销售的产品却很相似,它们之间的业务模型既有相同的地方,又有不同的地方。
现在我拿保险行业的互联网电商和传统核心应用来做个对比分析。我们看一下下面这张图,这两者在业务功能上会有很多相似和差异,这种相似和差异主要体现在四个方面。
1. 核心能力的重复建设。
由于销售同质保险产品,二者在核心业务流程和功能上必然相似,因此在核心业务能力上存在功能重叠是不可避免的。传统保险核心应用有报价、投保、核保和出单功能,同样在互联网电商平台也有。这就是核心能力的重复建设。
2. 通用能力的重复建设。
传统核心应用的通用平台大而全,通常会比较重。而互联网电商平台离不开这些通用能力的支撑,但为了保持敏捷性,一般会自己建设缩小版的通用功能,比如用户、客户等。这是通用能力的重复建设。
3. 业务职能的分离建设。
有一类业务功能,在互联网电商平台中建设了一部分,在传统核心应用中也建设了一部分,二者功能不重叠而且还互补,组合在一起是一个完整的业务职能。比如缴费功能,互联网电商平台主要面向个人客户,于是采用了支付宝和微信支付的方式。而传统核心应用主要是柜台操作,仍在采用移动 POS 机的缴费方式。二者都是缴费,为了保证业务模型的完整性,在构建中台业务模型时,我们可以考虑将这两部分模型重组为一个完整的业务模型。
4. 互联网电商平台和传统核心功能前后完全独立建设。
传统核心应用主要面向柜台,不需要互联网电商平台的在线客户、话务、订单和购物车等功能。而互联网电商平台主要面向个人客户,它不需要后端比较重的再保、佣金、打印等功能。在构建中台业务模型时,对这种情况应区别对待,将面向后端业务管理的应用沉淀到后台,将前端能力构建为面向互联网渠道的通用中台,比如订单等。
如何避免重复造轮子?
要避免重复建设,就要理解中台的理念和思想。前面说了“
中台是企业级能力复用平台
”用白话说就是重复使用,就是要避免重复造轮子的事情。
中台的设计思想与“高内聚、低耦合”的设计原则是高度一致的。高内聚是把相关的业务行为聚集在一起,把不相关的行为放在其它地方,如果你要修改某个业务行为,只需要修改一处。对了!中台就是要这样做,按照“高内聚、松耦合”的原则,实现企业级的能力复用!
那如果你的企业遇到了重复造轮子的情况,应该怎么处理?
你需要站在企业高度,将重复的需要共享的通用能力、核心能力沉淀到中台,将分离的业务能力重组为完整的业务板块,构建可复用的中台业务模型。前端个性能力归前端,后端管理能力归后台。建立前、中、后台边界清晰,融合协作的企业级可复用的业务模型。
如何构建中台业务模型?
我们可以用 DDD 领域建模的方法来构建中台业务模型。你可以选择两种建模策略:自顶向下和自底向上的策略。具体采用哪种策略,你需要结合公司的具体情况来分析,下面我就来介绍一下这两种策略。
1. 自顶向下的策略
第一种策略是自顶向下。这种策略是先做顶层设计,从最高领域逐级分解为中台,分别建立领域模型,根据业务属性分为通用中台或核心中台。领域建模过程主要基于业务现状,暂时不考虑系统现状。
自顶向下的策略适用于全新的应用系统建设,或旧系统推倒重建的情况。
由于这种策略不必受限于现有系统,你可以用 DDD 领域逐级分解的领域建模方法。从下面这张图我们可以看出它的主要步骤:第一步是将领域分解为子域,子域可以分为核心域、通用域和支撑域;第二步是对子域建模,划分领域边界,建立领域模型和限界上下文;第三步则是根据限界上下文进行微服务设计。
2. 自底向上的策略
第二种策略是自底向上。这种策略是基于业务和系统现状完成领域建模。首先分别完成系统所在业务域的领域建模;然后对齐业务域,找出具有同类或相似业务功能的领域模型,对比分析领域模型的差异,重组领域对象,重构领域模型。这个过程会沉淀公共和复用的业务能力,会将分散的业务模型整合。
自底向上策略适用于遗留系统业务模型的演进式重构。
下面我以互联网电商和传统核心应用的几个典型业务域为例,带你了解具体如何采用自底向上的策略来构建中台业务模型,主要分为这样三个步骤。
第一步:锁定系统所在业务域,构建领域模型。
锁定系统所在的业务域,采用事件风暴,找出领域对象,构建聚合,划分限界上下文,建立领域模型。看一下下面这张图,我们选取了传统核心应用的用户、客户、传统收付和承保四个业务域以及互联网电商业务域,共计五个业务域来完成领域建模。
从上面这张图中,我们可以看到传统核心共构建了八个领域模型。其中用户域构建了用户认证和权限两个领域模型,客户域构建了个人和团体两个领域模型,传统收付构建了 POS 刷卡领域模型,承保域构建了定报价、投保和保单管理三个领域模型。
互联网电商构建了报价、投保、订单、客户、用户认证和移动收付六个领域模型。
在这些领域模型的清单里,我们可以看到二者之间有很多名称相似的领域模型。深入分析后你会发现,这些名称相似的领域模型存在业务能力重复,或者业务职能分散(比如移动支付和传统支付)的问题。那在构建中台业务模型时,你就需要重点关注它们,将这些不同领域模型中重复的业务能力沉淀到中台业务模型中,将分散的领域模型整合到统一的中台业务模型中,对外提供统一的共享的中台服务。
第二步:对齐业务域,构建中台业务模型。
在下面这张图里,你可以看到右侧的传统核心领域模型明显多于左侧的互联网电商,那我们是不是就可以得出一个初步的结论:传统核心面向企业内大部分应用,大而全,领域模型相对完备,而互联网电商面向单一渠道,领域模型相对单一。
这个结论也给我们指明了一个方向:首先我们可以将传统核心的领域模型作为主领域模型,将互联网电商领域模型作为辅助模型来构建中台业务模型。然后再将互联网电商中重复的能力沉淀到传统核心的领域模型中,只保留自己的个性能力,比如订单。中台业务建模时,既要关注领域模型的完备性,也要关注不同渠道敏捷响应市场的要求。
有了上述这样一个思路,我们就可以开始构建中台业务模型了。
我们从互联网电商和传统核心的领域模型中,归纳并分离出能覆盖两个域的所有业务子域。通过分析,我们找到了用户、客户、承保、收付和订单五个业务域,它们是可以用于领域模型对比分析的基准域。
下面我以客户为例,来给你讲一下客户中台业务模型的构建过程。
互联网电商客户主要面向个人客户,除了有个人客户信息管理功能外,基于营销目的它还有客户积分功能,因此它的领域模型有个人和积分两个聚合。
而传统核心客户除了支持个人客户外,还有单位和组织机构等团体客户,它有个人和团体两个领域模型。其中个人领域模型中除了个人客户信息管理功能外,还有个人客户的评级、重复客户的归并和客户的统一视图等功能,因此它的领域模型有个人、视图、评级和归并四个聚合。
构建多业务域的中台业务模型的过程,就是找出同一业务域内所有同类业务的领域模型,对比分析域内领域模型和聚合的差异和共同点,打破原有的模型,完成新的中台业务模型重组或归并的过程。
我们将互联网电商和传统核心的领域模型分解后,我们找到了五个与个人客户领域相关的聚合,包括:个人、积分、评级、归并和视图。这五个聚合原来分别分散在互联网电商和传统核心的领域模型中,我们需要打破原有的领域模型,进行功能沉淀和聚合的重组,重新找出这些聚合的限界上下文,重构领域模型。
最终个人客户的领域模型重构为:
个人、归并和视图三个聚合重构为个人领域模型(客户信息管理),评级和积分两个聚合重构为评级积分领域模型(面向个人客户)。到这里我们就完成了个人客户领域模型的构建了。
好像还漏掉点什么东西呢?对了,还有团队客户领域模型!其实团体客户很简单。由于它只在传统核心中出现,我们将它在传统核心中的领域模型直接拿过来用就行了。
至此我们就完成了客户中台业务模型的构建了,客户中台构建了个人、团体和评级积分三个领域模型。
通过客户中台业务模型的构建,你是否 get 到构建中台业务模型的要点了呢?总结成一句话就是:“分域建模型,找准基准域,划定上下文,聚合重归类。”
其它业务域其实也是一样的过程,在这里我就不一一讲述了,你可以自己练习一下,作为课后作业。完成后你可以对照下面这张图看一下,这就是其它业务域重构后的中台业务模型。
第三步:中台归类,根据领域模型设计微服务。
完成中台业务建模后,我们就有了下面这张图。从这张图中我们可以看到总共构建了多少个中台,中台下面有哪些领域模型,哪些中台是通用中台,哪些中台是核心中台,中台的基本信息等等,都一目了然。你根据中台下的领域模型就可以设计微服务了。
重构过程中的领域对象
上面主要是从聚合的角度来描述中台业务模型的重组,是相对高阶的业务模块的重构。业务模型重构和聚合重组,往往会带来领域对象和业务行为的变化。下面我带你了解一下,在领域模型重组过程中,发生在更底层的领域对象的活动。
我们还是以客户为例来讲述。由于对象过多,我只选取了部分领域对象和业务行为。
传统核心客户领域模型重构之前,包含个人、团体和评级三个聚合,每个聚合内部都有自己的聚合根、实体、方法和领域服务等。
互联网电商客户领域模型重构前包含个人和积分两个聚合,每个聚合包含了自己的领域对象、方法和领域服务等。
传统核心和互联网电商客户领域模型重构成客户中台后,建立了个人、团体和评级积分三个领域模型。其中个人领域模型有个人聚合,团体领域模型有团体聚合,评级积分领域模型有评级和积分两个聚合。这些领域模型的领域对象来自原来的领域模型,但积分评级是重组后的领域模型,它们原来的聚合会带着各自的领域对象,加入到新的领域模型中。
这里还要注意:部分领域对象可能会根据新的业务要求,从原来的聚合中分离,重组到其它聚合。新领域模型的领域对象,比如实体、领域服务等,在重组后可能还会根据新的业务场景和需求进行代码重构。
今天我们一起讨论了传统企业中台数字化转型,在面对多个不同渠道应用重复建设时,如何用 DDD 领域建模的思想来构建中台业务模型。中台业务建模有自顶向下和自底向上两种策略,这两种策略有自己的适用场景,你需要结合自己公司的情况选择合适的策略。
其实呢,中台业务模型的重构过程,也是微服务架构演进的过程。业务边界即微服务边界,业务边界做好了,微服务的边界自然就会很好。
Technical Debt Repayment Strategies
Strategy Selection Matrix
| Debt Level | Strategy | Effort | ROI Timeline |
|---|---|---|---|
| Severe (>60) | All-hands refactoring sprint | 2-4 weeks | Immediate |
| Moderate (41-60) | Ring-fenced 20% time per sprint | Ongoing | 3 months |
| Mild (21-40) | Quarterly debt sprint | 1 week/quarter | 6-12 months |
| Healthy (≤20) | Continuous improvement | As needed | Ongoing |
Structural Debt Repayment (P0)
1. Layer violations: Add ArchUnit rules, block CI for new violations 2. Circular deps: Extract shared interface or event-based communication 3. Anemic entities: Move one service method per sprint into entity 4. Framework leaks: Replace @Entity with POJO in domain; use JPA in infra only
Design Debt Repayment (P1)
1. Oversized aggregates: Identify sub-aggregates, extract with ID refs 2. Missing events: Map domain events from existing @Transactional methods 3. String → VO: Replace one field per sprint using Strangler Fig for DB columns
Fitness Scoring Rubric — Detailed Criteria
Business Alignment
| Context | Over-engineered | Just right | Under-engineered |
|---|---|---|---|
| Simple CRUD | Clean/Hexagonal | N-tier / MVC | — |
| Medium complexity | Microservices | DDD Layered / Onion | N-tier / MVC |
| Complex domain | — | Hexagonal / Clean | DDD Layered |
| High-scale | — | Event-driven + CQRS | Monolith DDD |
Scoring Calibration
- Score 5: Architecture enables business agility. New features are easy to add.
- Score 4: Minor friction. Some adaptation needed.
- Score 3: Architecture does not actively help or hinder.
- Score 2: Architecture creates noticeable friction.
- Score 1: Architecture is a blocker. Major rework needed.
Maturity Assessment Workflow
Preparation
1. Collect sample code from each layer (Controller/Service/Domain/Infrastructure) 2. Pull architecture documentation (ADR, C4 diagrams) 3. Interview 2-3 team members about DDD understanding 4. Run automated scans (ArchUnit, JDepend) for metrics
Assessment Session
1. Per-level checklist evaluation (30 min) 2. Score calculation with evidence 3. Gap analysis: current vs target 4. Timeline estimation for each level progression
Common Assessment Traps
- Confirmation bias: Looking for evidence that confirms expected level
- Recency effect: Judging based on recently refactored modules, ignoring rest
- Scale blindness: A small project at L3 is different from an enterprise at L3
Strangler Fig Migration — Detailed Planning
Phase Breakdown
| Phase | Activity | Duration | Success Criteria |
|---|---|---|---|
| Wrap | Add ACL around legacy | 1-2 weeks | New code calls ACL, not legacy directly |
| Replace | Implement core feature in new system | 2-6 weeks | Feature parity with legacy |
| Route | Route traffic to new implementation | 1-2 weeks | 100% of traffic goes to new system |
| Remove | Delete legacy code | 1 week | Zero legacy references remain |
Migration Decision Tree
Want to migrate?
├─ Is business value clear?
│ ├─ Yes → Proceed with Strangler Fig
│ └─ No → Don't migrate; document decision
├─ Team capacity available?
│ ├─ Yes → Start with lowest-risk module
│ └─ No → Hire or pause; don't half-migrate
├─ Data migration needed?
│ ├─ Yes → Plan dual-write + validation
│ └─ No → Simpler cutoverRollback Checklist
☐ Feature flag to switch traffic
☐ Dual-write to legacy DB until validated
☐ Data integrity comparison script
☐ Performance baseline recorded
☐ Max rollback time: 4 hours