backend

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Backend Architecture

后端架构

Design scalable, reliable backend systems and APIs.
设计可扩展、高可靠的后端系统与API。

When to Use

适用场景

  • Creating new APIs or services
  • Database schema design
  • Service architecture decisions
  • Performance optimization
  • API versioning and documentation
  • 创建新的API或服务
  • 数据库架构设计
  • 服务架构决策
  • 性能优化
  • API版本控制与文档

Focus Areas

核心关注领域

API Design

API设计

  • RESTful conventions
  • Consistent error responses
  • Proper HTTP methods and status codes
  • Versioning strategy (URL or header)
  • Rate limiting and throttling
  • RESTful规范
  • 统一的错误响应
  • 正确的HTTP方法与状态码
  • 版本控制策略(URL或请求头)
  • 请求限流与节流

Service Boundaries

服务边界

  • Single responsibility per service
  • Clear contracts between services
  • Async communication where appropriate
  • Circuit breakers for resilience
  • 单一服务单一职责
  • 服务间清晰的契约
  • 合理使用异步通信
  • 熔断器实现容错

Database Design

数据库设计

  • Normalized schemas (3NF default)
  • Appropriate indexes
  • Migration strategy
  • Connection pooling
  • 规范化架构(默认遵循3NF)
  • 合理的索引设计
  • 数据迁移策略
  • 连接池配置

Security

安全机制

  • Authentication (JWT, OAuth2)
  • Authorization (RBAC, ABAC)
  • Input validation
  • SQL injection prevention
  • 身份认证(JWT、OAuth2)
  • 权限控制(RBAC、ABAC)
  • 输入校验
  • SQL注入防护

API Response Template

API响应模板

json
{
  "data": { ... },
  "meta": {
    "page": 1,
    "total": 100
  },
  "errors": null
}
json
{
  "data": { ... },
  "meta": {
    "page": 1,
    "total": 100
  },
  "errors": null
}

Error Response Template

错误响应模板

json
{
  "data": null,
  "errors": [
    {
      "code": "VALIDATION_ERROR",
      "message": "Email is required",
      "field": "email"
    }
  ]
}
json
{
  "data": null,
  "errors": [
    {
      "code": "VALIDATION_ERROR",
      "message": "Email is required",
      "field": "email"
    }
  ]
}

Reliability Targets

可靠性指标

  • Uptime: 99.9%
  • Error rate: <0.1%
  • Response time: <200ms p95
  • 可用性:99.9%
  • 错误率:<0.1%
  • 响应时间:p95 <200ms

Examples

示例

Input: "Design an API for user management" Action: Define endpoints, request/response schemas, auth flow, database schema
Input: "Set up microservice architecture" Action: Define service boundaries, communication patterns, deployment strategy
输入:“设计用户管理API” **操作:**定义接口、请求/响应架构、认证流程、数据库架构
输入:“搭建微服务架构” **操作:**定义服务边界、通信模式、部署策略