c4-container

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

C4 Container Level: System Deployment

C4容器级别:系统部署

Use this skill when

适用场景

  • Working on c4 container level: system deployment tasks or workflows
  • Needing guidance, best practices, or checklists for c4 container level: system deployment
  • 处理C4容器级别:系统部署任务或工作流时
  • 需要C4容器级别:系统部署的指导、最佳实践或检查清单时

Do not use this skill when

不适用场景

  • The task is unrelated to c4 container level: system deployment
  • You need a different domain or tool outside this scope
  • 任务与C4容器级别:系统部署无关时
  • 需要该范围之外的其他领域或工具时

Instructions

操作说明

  • Clarify goals, constraints, and required inputs.
  • Apply relevant best practices and validate outcomes.
  • Provide actionable steps and verification.
  • If detailed examples are required, open
    resources/implementation-playbook.md
    .
  • 明确目标、约束条件和所需输入。
  • 应用相关最佳实践并验证结果。
  • 提供可执行步骤和验证方法。
  • 如果需要详细示例,请打开
    resources/implementation-playbook.md

Containers

容器

[Container Name]

[容器名称]

  • Name: [Container name]
  • Description: [Short description of container purpose and deployment]
  • Type: [Web Application, API, Database, Message Queue, etc.]
  • Technology: [Primary technologies: Node.js, Python, PostgreSQL, Redis, etc.]
  • Deployment: [Docker, Kubernetes, Cloud Service, etc.]
  • 名称:[容器名称]
  • 描述:[容器用途和部署方式的简短描述]
  • 类型:[Web应用、API、数据库、消息队列等]
  • 技术栈:[核心技术:Node.js、Python、PostgreSQL、Redis等]
  • 部署方式:[Docker、Kubernetes、云服务等]

Purpose

用途

[Detailed description of what this container does and how it's deployed]
[详细描述该容器的功能及其部署方式]

Components

组件

This container deploys the following components:
    • Documentation: c4-component-name.md
本容器部署以下组件:
  • [组件名称]:[描述]
    • 文档:c4-component-name.md

Interfaces

接口

[API/Interface Name]

[API/接口名称]

  • Protocol: [REST/GraphQL/gRPC/Events/etc.]
  • Description: [What this interface provides]
  • Specification: [Link to OpenAPI/Swagger/API Spec file]
  • Endpoints:
    • GET /api/resource
      - [Description]
    • POST /api/resource
      - [Description]
  • 协议:[REST/GraphQL/gRPC/事件等]
  • 描述:[该接口提供的功能]
  • 规范:[OpenAPI/Swagger/API规范文件链接]
  • 端点:
    • GET /api/resource
      - [描述]
    • POST /api/resource
      - [描述]

Dependencies

依赖项

Containers Used

所使用的容器

  • [Container Name]: [How it's used, communication protocol]
  • [容器名称]:[使用方式、通信协议]

External Systems

外部系统

  • [External System]: [How it's used, integration type]
  • [外部系统]:[使用方式、集成类型]

Infrastructure

基础设施

  • Deployment Config: [Link to Dockerfile, K8s manifest, etc.]
  • Scaling: [Horizontal/vertical scaling strategy]
  • Resources: [CPU, memory, storage requirements]
  • 部署配置:[Dockerfile、K8s清单等链接]
  • 扩容策略:[水平/垂直扩容策略]
  • 资源要求:[CPU、内存、存储需求]

Container Diagram

容器图

Use proper Mermaid C4Container syntax:
mermaid
C4Container
    title Container Diagram for [System Name]

    Person(user, "User", "Uses the system")
    System_Boundary(system, "System Name") {
        Container(webApp, "Web Application", "Spring Boot, Java", "Provides web interface")
        Container(api, "API Application", "Node.js, Express", "Provides REST API")
        ContainerDb(database, "Database", "PostgreSQL", "Stores data")
        Container_Queue(messageQueue, "Message Queue", "RabbitMQ", "Handles async messaging")
    }
    System_Ext(external, "External System", "Third-party service")

    Rel(user, webApp, "Uses", "HTTPS")
    Rel(webApp, api, "Makes API calls to", "JSON/HTTPS")
    Rel(api, database, "Reads from and writes to", "SQL")
    Rel(api, messageQueue, "Publishes messages to")
    Rel(api, external, "Uses", "API")

**Key Principles** (from [c4model.com](https://c4model.com/diagrams/container)):

- Show **high-level technology choices** (this is where technology details belong)
- Show how **responsibilities are distributed** across containers
- Include **container types**: Applications, Databases, Message Queues, File Systems, etc.
- Show **communication protocols** between containers
- Include **external systems** that containers interact with
使用标准Mermaid C4Container语法:
mermaid
C4Container
    title Container Diagram for [System Name]

    Person(user, "User", "Uses the system")
    System_Boundary(system, "System Name") {
        Container(webApp, "Web Application", "Spring Boot, Java", "Provides web interface")
        Container(api, "API Application", "Node.js, Express", "Provides REST API")
        ContainerDb(database, "Database", "PostgreSQL", "Stores data")
        Container_Queue(messageQueue, "Message Queue", "RabbitMQ", "Handles async messaging")
    }
    System_Ext(external, "External System", "Third-party service")

    Rel(user, webApp, "Uses", "HTTPS")
    Rel(webApp, api, "Makes API calls to", "JSON/HTTPS")
    Rel(api, database, "Reads from and writes to", "SQL")
    Rel(api, messageQueue, "Publishes messages to")
    Rel(api, external, "Uses", "API")
核心原则(来自c4model.com):
  • 展示高层技术选型(技术细节应在此处体现)
  • 展示职责如何在容器间分配
  • 包含容器类型:应用、数据库、消息队列、文件系统等
  • 展示容器间的通信协议
  • 包含容器交互的外部系统

API Specification Template

API规范模板

For each container API, create an OpenAPI/Swagger specification:
yaml
openapi: 3.1.0
info:
  title: [Container Name] API
  description: [API description]
  version: 1.0.0
servers:
  - url: https://api.example.com
    description: Production server
paths:
  /api/resource:
    get:
      summary: [Operation summary]
      description: [Operation description]
      parameters:
        - name: param1
          in: query
          schema:
            type: string
      responses:
        '200':
          description: [Response description]
          content:
            application/json:
              schema:
                type: object
为每个容器API创建OpenAPI/Swagger规范:
yaml
openapi: 3.1.0
info:
  title: [Container Name] API
  description: [API description]
  version: 1.0.0
servers:
  - url: https://api.example.com
    description: Production server
paths:
  /api/resource:
    get:
      summary: [Operation summary]
      description: [Operation description]
      parameters:
        - name: param1
          in: query
          schema:
            type: string
      responses:
        '200':
          description: [Response description]
          content:
            application/json:
              schema:
                type: object

Example Interactions

示例交互场景

  • "Synthesize all components into containers based on deployment definitions"
  • "Map the API components to containers and document their APIs as OpenAPI specs"
  • "Create container-level documentation for the microservices architecture"
  • "Document container interfaces as Swagger/OpenAPI specifications"
  • "Analyze Kubernetes manifests and create container documentation"
  • "根据部署定义将所有组件整合为容器"
  • "将API组件映射到容器并将其API文档记录为OpenAPI规范"
  • "为微服务架构创建容器级文档"
  • "将容器接口文档记录为Swagger/OpenAPI规范"
  • "分析Kubernetes清单并创建容器文档"

Key Distinctions

核心差异

  • vs C4-Component agent: Maps components to deployment units; Component agent focuses on logical grouping
  • vs C4-Context agent: Provides container-level detail; Context agent creates high-level system diagrams
  • vs C4-Code agent: Focuses on deployment architecture; Code agent documents individual code elements
  • 与C4-Component agent对比:将组件映射到部署单元;Component agent专注于逻辑分组
  • 与C4-Context agent对比:提供容器级细节;Context agent创建高层系统图
  • 与C4-Code agent对比:专注于部署架构;Code agent记录单个代码元素

Output Examples

输出示例

When synthesizing containers, provide:
  • Clear container boundaries with deployment rationale
  • Descriptive container names and deployment characteristics
  • Complete API documentation with OpenAPI/Swagger specifications
  • Links to all contained components
  • Mermaid container diagrams showing deployment architecture
  • Links to deployment configurations (Dockerfiles, K8s manifests, etc.)
  • Infrastructure requirements and scaling considerations
  • Consistent documentation format across all containers
整合容器时,需提供:
  • 清晰的容器边界及部署依据
  • 描述性的容器名称和部署特征
  • 完整的API文档及OpenAPI/Swagger规范
  • 所有包含组件的链接
  • 展示部署架构的Mermaid容器图
  • 部署配置链接(Dockerfile、K8s清单等)
  • 基础设施要求和扩容考量
  • 所有容器保持一致的文档格式