微服务 API 网关架构
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。
Architecture
API 组合架构图,组合器服务向多个微服务扇出并行请求,收集带超时处理的响应,并将结果合并为单一统一响应,支持部分降级。该模板模拟当单个客户端查询需要来自多个服务的数据时使用的 API 组合模式,避免直接的服务间调用。适合在微服务架构中构建聚合层的团队。
Client { # Client Application
n1: circle label:"Complex Query Request"
n2: rectangle label:"API Composer Service"
n3: rectangle label:"Receive Composed Response"
n4: circle label:"End"
n1.handle(right) -> n2.handle(left)
n2.handle(bottom) -> Composer.n5.handle(top) [label="Compose"]
n3.handle(right) -> n4.handle(left)
}
Composer { # API Composition Layer
n5: rectangle label:"Parse Query Requirements"
n6: rectangle label:"Fan-Out Parallel Requests"
n7: rectangle label:"Collect Responses"
n8: diamond label:"All Responses Received?"
n9: rectangle label:"Merge and Transform"
n10: rectangle label:"Return Partial with Fallback"
n5.handle(right) -> n6.handle(left) [label="Decompose"]
n6.handle(bottom) -> Services.n11.handle(top) [label="GET /users"]
n6.handle(bottom) -> Services.n12.handle(top) [label="GET /orders"]
n6.handle(bottom) -> Services.n13.handle(top) [label="GET /products"]
n7.handle(right) -> n8.handle(left)
n8.handle(right) -> n9.handle(left) [label="Yes"]
n8.handle(bottom) -> n10.handle(top) [label="Timeout"]
n9.handle(top) -> Client.n3.handle(bottom) [label="Composed JSON"]
n10.handle(top) -> Client.n3.handle(bottom) [label="Partial JSON"]
}
Services { # Microservices
n11: rectangle label:"User Service"
n12: rectangle label:"Order Service"
n13: rectangle label:"Product Service"
n14: rectangle label:"User Response"
n15: rectangle label:"Order Response"
n16: rectangle label:"Product Response"
n11.handle(right) -> n14.handle(left) [label="Query"]
n12.handle(right) -> n15.handle(left) [label="Query"]
n13.handle(right) -> n16.handle(left) [label="Query"]
n14.handle(top) -> Composer.n7.handle(bottom) [label="User Data"]
n15.handle(top) -> Composer.n7.handle(bottom) [label="Order Data"]
n16.handle(top) -> Composer.n7.handle(bottom) [label="Product Data"]
}
When a single UI view requires data from multiple microservices, having the client make multiple API calls increases latency and complexity. The API composition pattern provides a server-side aggregation layer that fans out requests in parallel, collects responses, and returns a single unified result.
GraphQL federation provides query-level composition without a custom aggregator. Client-side composition gives more control but increases latency. BFF pattern is similar but client-specific. This template shows the generic API composition approach.
| Template Name | API 组合模式架构 |
| Category | Architecture |
| Steps | 6 workflow steps |
| Format | FlowZap Code (.fz file) |
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。
Architecture
Backend-for-Frontend 架构图,为 Web 和移动客户端提供独立的 BFF 层,每层针对其特定平台优化 API 响应,同时共享通用后端微服务。该模板展示如何通过按客户端类型定制数据聚合和负载优化来避免一刀切的 API。推荐给从共享微服务后端服务多个前端平台的团队。
Architecture
事件驱动发布-订阅架构图,展示 Kafka 或 RabbitMQ 消息代理、事件序列化、主题分区、向多个消费者的扇出交付以及死信队列错误处理。该模板模拟了生产者和消费者通过消息代理完全解耦的基础异步消息传递模式。对于构建松耦合、可扩展的事件驱动系统的架构师至关重要。
Architecture
Saga 编排架构图,中央编排器协调跨订单、库存和支付服务的多步骤分布式事务,具有专用的补偿链用于失败时的回滚。该模板模拟基于编排的 Saga 模式,单个协调器管理事务生命周期并在任何步骤失败时触发补偿操作。对于实施不使用两阶段提交的可靠分布式事务的架构师至关重要。