微服务 API 网关架构
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。
Architecture
Backend-for-Frontend 架构图,为 Web 和移动客户端提供独立的 BFF 层,每层针对其特定平台优化 API 响应,同时共享通用后端微服务。该模板展示如何通过按客户端类型定制数据聚合和负载优化来避免一刀切的 API。推荐给从共享微服务后端服务多个前端平台的团队。
WebApp { # Web Application
n1: circle label:"Browser Request"
n2: rectangle label:"Web BFF"
n3: rectangle label:"Render HTML Response"
n4: circle label:"Display Page"
n1.handle(right) -> n2.handle(left)
n2.handle(bottom) -> Services.n9.handle(top) [label="Fetch Data"]
n3.handle(right) -> n4.handle(left)
}
MobileApp { # Mobile Application
n5: circle label:"Mobile API Call"
n6: rectangle label:"Mobile BFF"
n7: rectangle label:"Optimized Payload"
n8: circle label:"Render Native UI"
n5.handle(right) -> n6.handle(left)
n6.handle(bottom) -> Services.n9.handle(top) [label="Fetch Data"]
n7.handle(right) -> n8.handle(left)
}
Services { # Shared Microservices
n9: rectangle label:"User Profile Service"
n10: rectangle label:"Content Service"
n11: rectangle label:"Notification Service"
n12: rectangle label:"Analytics Service"
n9.handle(right) -> n10.handle(left) [label="User Context"]
n10.handle(top) -> WebApp.n3.handle(bottom) [label="Full Payload"]
n10.handle(top) -> MobileApp.n7.handle(bottom) [label="Compact Payload"]
n11.handle(top) -> MobileApp.n7.handle(bottom) [label="Push Token"]
n12.handle(top) -> WebApp.n2.handle(bottom) [label="Track"]
n12.handle(top) -> MobileApp.n6.handle(bottom) [label="Track"]
}
A single API serving both web and mobile clients forces compromises: web clients receive unnecessary mobile-specific fields, and mobile clients download bloated payloads. The BFF pattern creates dedicated API layers for each client type, optimizing response payloads, aggregation logic, and caching strategies per platform.
A single API with field selection (GraphQL) can reduce the need for BFFs. API versioning per client type is simpler but harder to maintain. This template helps teams decide when a dedicated BFF layer is worth the operational cost.
| Template Name | 微服务 Backend-for-Frontend (BFF) 架构 |
| Category | Architecture |
| Steps | 6 workflow steps |
| Format | FlowZap Code (.fz file) |
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。
Architecture
Saga 编排架构图,中央编排器协调跨订单、库存和支付服务的多步骤分布式事务,具有专用的补偿链用于失败时的回滚。该模板模拟基于编排的 Saga 模式,单个协调器管理事务生命周期并在任何步骤失败时触发补偿操作。对于实施不使用两阶段提交的可靠分布式事务的架构师至关重要。
Architecture
API 组合架构图,组合器服务向多个微服务扇出并行请求,收集带超时处理的响应,并将结果合并为单一统一响应,支持部分降级。该模板模拟当单个客户端查询需要来自多个服务的数据时使用的 API 组合模式,避免直接的服务间调用。适合在微服务架构中构建聚合层的团队。