# tencentcloudbase/cloudbase-agent-ui architecture

> Architecture diagram of the GitHub repository tencentcloudbase/cloudbase-agent-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tencentcloudbase/cloudbase-agent-ui
- Repository: https://github.com/tencentcloudbase/cloudbase-agent-ui

## Overview

##### Project Type and Purpose
- This is an open-source WeChat MiniProgram UI component library (“Agent UI”) plus a reference sample app.
- It also supports custom “tool cards” via Tencent Cloud MCP Server integrations (e.g., maps, weather).

##### File Structure Analysis
- Top level:
- components/agent-ui → the reusable UI component you ship to user projects
- apps/miniprogram-agent-ui → a working demo MiniProgram that consumes agent-ui
- scripts/ → helper scripts for syncing to COS, uploading cloud functions
- .github/ → CI (GitHub Actions) for packaging/releases
- docs/, README.md, CHANGELOG.md → documentation
- Under the demo app: standard WeChat MiniProgram structure (pages/, components/, app.js/json, project.config.json).
- Configuration files: package.json & versionrc.js for versioning; prettier.config.js; project.private.config.json for local secrets.

##### README Insights
- Agent UI supports two modes: “Agent” (bot) mode or “Model” (direct LLM) mode.
- Back-end is Tencent CloudBase (“wx.cloud.init”), with optional MCP Server for tool calls.
- Third-party LLM providers (DeepSeek, Hunyuan) are called over HTTP from the cloud environment.
- Custom tool cards are plug-ins under components/toolCard in the demo or in user projects.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Front-end Layer
    subgraph "Front-end (MiniProgram UI)"
        direction TB
        UI["MiniProgram UI"]:::frontend
        AgentComp["Agent UI Component"]:::frontend
        DemoAgentUsage["Demo Agent-UI Usage"]:::frontend
        ChatBot["ChatBot Page"]:::frontend
        FoodBuy["FoodBuy Page"]:::frontend
        ToolCard["Custom ToolCard"]:::frontend
    end

    %% CloudBase Back-end
    subgraph "CloudBase Backend"
        direction TB
        APIGW["CloudBase API Gateway"]:::cloud
        AgentService["AI Agent Service"]:::cloud
        MCP["Cloud Function / MCP Server"]:::cloud
    end

    %% External LLM & Tool Services
    subgraph "External Services"
        direction TB
        DeepSeek["DeepSeek API"]:::external
        Hunyuan["Hunyuan API"]:::external
        Tools["Mapping / Weather APIs"]:::external
    end

    %% CI/CD & Tooling
    subgraph "CI/CD & Tooling"
        direction TB
        GH["GitHub Actions"]:::ci
        Sync["sync-component.js"]:::ci
        Upload["upload-to-cos.js"]:::ci
        COS["Tencent COS"]:::ci
        Version[".versionrc.js"]:::ci
        Package["package.json"]:::ci
        Prettier["prettier.config.js"]:::ci
    end

    %% Data Flows
    UI -->|"renders UI"| AgentComp
    AgentComp -->|"wx.cloud.init\n& invoke"| APIGW
    APIGW -->|"chatMode=bot"| AgentService
    APIGW -->|"chatMode=model"| MCP
    AgentService -->|"streaming responses\n& tool calls"| MCP
    MCP -->|"calls"| Tools
    MCP -->|"forwards model calls"| DeepSeek
    MCP -->|"forwards model calls"| Hunyuan
    DeepSeek -->|"LLM response"| APIGW
    Hunyuan -->|"LLM response"| APIGW
    Tools -->|"tool data"| MCP
    APIGW -->|"response"| AgentComp
    AgentComp -->|"update UI"| UI

    %% CI/CD Flows
    GH -->|runs| Sync
    GH -->|runs| Upload
    Sync -->|uploads| COS
    Upload -->|uploads| COS

    %% Click Events
    click AgentComp "https://github.com/tencentcloudbase/cloudbase-agent-ui/tree/main/components/agent-ui"
    click UI "https://github.com/tencentcloudbase/cloudbase-agent-ui/tree/main/apps/miniprogram-agent-ui/miniprogram"
    click ChatBot "https://github.com/tencentcloudbase/cloudbase-agent-ui/tree/main/apps/miniprogram-agent-ui/miniprogram/pages/chatBot"
    click FoodBuy "https://github.com/tencentcloudbase/cloudbase-agent-ui/tree/main/apps/miniprogram-agent-ui/miniprogram/pages/foodBuy"
    click DemoAgentUsage "https://github.com/tencentcloudbase/cloudbase-agent-ui/tree/main/apps/miniprogram-agent-ui/miniprogram/components/agent-ui"
    click ToolCard "https://github.com/tencentcloudbase/cloudbase-agent-ui/tree/main/apps/miniprogram-agent-ui/miniprogram/components/toolCard"
    click Sync "https://github.com/tencentcloudbase/cloudbase-agent-ui/blob/main/scripts/sync-component.js"
    click Upload "https://github.com/tencentcloudbase/cloudbase-agent-ui/blob/main/scripts/upload-to-cos.js"
    click GH "https://github.com/tencentcloudbase/cloudbase-agent-ui/blob/main/.github/workflows/release-main.yml"
    click Version "https://github.com/tencentcloudbase/cloudbase-agent-ui/blob/main/.versionrc.js"
    click Package "https://github.com/tencentcloudbase/cloudbase-agent-ui/blob/main/package.json"
    click Prettier "https://github.com/tencentcloudbase/cloudbase-agent-ui/blob/main/prettier.config.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#4F81BD,color:#000;
    classDef cloud fill:#FFD8A8,stroke:#D2691E,color:#000;
    classDef external fill:#C8E6C9,stroke:#388E3C,color:#000;
    classDef ci fill:#E0E0E0,stroke:#757575,color:#000;
    class GH,Sync,Upload,COS,Version,Package,Prettier ci
    class UI,AgentComp,DemoAgentUsage,ChatBot,FoodBuy,ToolCard frontend
    class APIGW,AgentService,MCP cloud
    class DeepSeek,Hunyuan,Tools external
```
