| name | architecture-design |
| description | System architecture design. 当用户需要设计系统架构、画架构图、讨论微服务拆分、CQRS、事件驱动、DDD等架构模式时使用此skill。 |
System Architecture Design
系统架构设计技能,提供经过验证的架构模式和设计方法。
核心架构模式
1. 分层架构 (Layered Architecture)
┌─────────────────────────────────────┐
│ Presentation Layer │
├─────────────────────────────────────┤
│ Application Layer │
├─────────────────────────────────────┤
│ Domain Layer │
├─────────────────────────────────────┤
│ Infrastructure Layer │
└─────────────────────────────────────┘
适用场景:传统 Web 应用、CRUD 系统
优点:清晰简单,易于理解和维护
缺点:领域逻辑可能渗透到其他层
2. 微服务架构 (Microservices)
┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐
│Service│ │Service│ │Service│ │Service│
│ A │ │ B │ │ C │ │ D │
└──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘
│ │ │ │
└─────────┴────┬────┴─────────┘
│
┌──────┴──────┐
│ API Gateway │
└──────────────┘
适用场景:大规模系统、需要独立部署、多团队协作
优点:独立部署、技术异构、故障隔离
缺点:复杂度高、数据一致性挑战
3. CQRS (Command Query Responsibility Segregation)
┌─────────────┐ Command ┌─────────────┐
│ Command │───────────────▶│ Command │
│ Side │ │ Handler │
└─────────────┘ └──────┬──────┘
│
┌──────▼──────┐
│ Write │
│ Database │
└──────┬──────┘
│ Sync
┌────────────┴────────────┐
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ Read │ │ Read │
│ Model │ │ Model │
└─────────────┘ └─────────────┘