事件驱动领域事件架构
Architecture
领域事件架构图,展示聚合根如何引发领域事件,这些事件既在进程内分发给本地处理器,也跨边界分发给其他限界上下文中的集成事件消费者。该模板模拟 DDD 事件模式,领域逻辑通过干净的事件分发器触发副作用,保持领域和基础设施关注点的分离。对于实施基于事件集成的领域驱动设计的团队至关重要。
Architecture
DDD 限界上下文架构图,订单、客户、物流和计费上下文通过防腐层、共享内核和定义集成关系的上下文映射连接。该模板可视化战略 DDD 模式,将复杂领域分解为通过明确定义的集成事件通信的自治限界上下文。对于将领域驱动设计应用于大规模企业系统的架构师至关重要。
OrderContext { # Order Bounded Context
n1: rectangle label:"Order Aggregate"
n2: rectangle label:"Order Line Item"
n3: rectangle label:"Order Repository"
n4: rectangle label:"Order Service"
n1.handle(right) -> n2.handle(left) [label="Contains"]
n4.handle(right) -> n1.handle(left) [label="Manages"]
n4.handle(bottom) -> n3.handle(top) [label="Persists"]
n4.handle(bottom) -> ACL.n9.handle(top) [label="Integration Event"]
}
CustomerContext { # Customer Bounded Context
n5: rectangle label:"Customer Aggregate"
n6: rectangle label:"Address Value Object"
n7: rectangle label:"Customer Repository"
n8: rectangle label:"Customer Service"
n5.handle(right) -> n6.handle(left) [label="Has"]
n8.handle(right) -> n5.handle(left) [label="Manages"]
n8.handle(bottom) -> n7.handle(top) [label="Persists"]
n8.handle(bottom) -> ACL.n10.handle(top) [label="Integration Event"]
}
ACL { # Anti-Corruption Layer
n9: rectangle label:"Order-to-Shipping Translator"
n10: rectangle label:"Customer-to-Billing Translator"
n11: rectangle label:"Shared Kernel (Common Types)"
n12: rectangle label:"Context Map"
n9.handle(bottom) -> ShippingContext.n13.handle(top) [label="ShipmentRequested"]
n10.handle(bottom) -> BillingContext.n16.handle(top) [label="InvoiceRequested"]
n11.handle(right) -> n12.handle(left) [label="Defines"]
}
ShippingContext { # Shipping Bounded Context
n13: rectangle label:"Shipment Aggregate"
n14: rectangle label:"Tracking Number VO"
n15: rectangle label:"Shipping Service"
n13.handle(right) -> n14.handle(left) [label="Assigned"]
n15.handle(right) -> n13.handle(left) [label="Manages"]
}
BillingContext { # Billing Bounded Context
n16: rectangle label:"Invoice Aggregate"
n17: rectangle label:"Payment Entity"
n18: rectangle label:"Billing Service"
n16.handle(right) -> n17.handle(left) [label="Contains"]
n18.handle(right) -> n16.handle(left) [label="Manages"]
}
Large systems with a single unified model become increasingly complex as different teams interpret the same concepts differently. Bounded contexts establish clear boundaries where each context has its own ubiquitous language, data model, and team ownership—preventing model pollution and enabling independent evolution.
A single shared model is simpler for small teams but does not scale. Microservices without DDD boundaries often create distributed monoliths. This template shows the strategic DDD patterns for decomposing complex domains.
| Template Name | 领域驱动设计限界上下文架构 |
| Category | Architecture |
| Steps | 6 workflow steps |
| Format | FlowZap Code (.fz file) |
Architecture
领域事件架构图,展示聚合根如何引发领域事件,这些事件既在进程内分发给本地处理器,也跨边界分发给其他限界上下文中的集成事件消费者。该模板模拟 DDD 事件模式,领域逻辑通过干净的事件分发器触发副作用,保持领域和基础设施关注点的分离。对于实施基于事件集成的领域驱动设计的团队至关重要。
Architecture
按业务能力组织的微服务分解架构图:身份认证、产品目录、定价和订单履行,每个都有独立的数据存储和 API。该模板展示如何将单体应用拆分为与业务领域对齐的服务,使用 Backend-for-Frontend (BFF) 模式进行客户端特定的聚合。适合规划领域驱动微服务边界的架构师。
Architecture
绞杀者模式迁移架构图,展示使用路由层在新旧系统之间分流流量,逐步用新微服务替换遗留单体应用。该模板模拟经过验证的迁移策略,新功能作为微服务构建,遗留端点逐步退役。对于在不进行高风险大爆炸重写的情况下现代化遗留系统的团队至关重要。
Architecture
事件溯源架构图,所有状态变更存储为不可变的领域事件序列,读取投影从事件流构建,快照优化用于快速聚合加载。该模板展示事件溯源如何通过保留每次状态转换的完整历史来消除数据丢失。对于需要完整审计跟踪、时间查询和事件重放能力的系统至关重要。
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。