# chatfire-ai/huobao-canvas architecture

> Architecture diagram of the GitHub repository chatfire-ai/huobao-canvas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chatfire-ai/huobao-canvas
- Repository: https://github.com/chatfire-ai/huobao-canvas

## Overview

1. **Project type and runtime**
   - This is a single-page Vue 3 application built with Vite.
   - It runs as a browser-based “AI canvas” for node graph editing, with Docker/Nginx packaging available for static hosting.

2. **Top-level UI structure**
   - The app has two main views: `Home.vue` for landing/project entry and `Canvas.vue` for the editable workflow canvas.
   - `App.vue`, `router/index.js`, and `main.js` form the shell that bootstraps routing, global state, and styling.

3. **Core interaction surface: the canvas**
   - The main product surface is the Vue Flow canvas in `Canvas.vue`.
   - Users build workflows by dragging nodes, connecting them, and editing node-specific parameters.
   - Custom edge components and node components indicate the graph is not generic-only; it has domain-specific connection semantics.

4. **Node-based workflow model**
   - The repository centers on four node categories:
     - text input/editing
     - image generation config
     - image output/display
     - video generation config and video output/display
   - Node components live under `src/components/nodes`, while connection behavior is specialized through `src/components/edges`.

5. **AI provider/API boundary**
   - All external AI calls are isolated in `src/api/` with separate clients for chat, image, video, and model metadata.
   - `src/components/ApiSettings.vue` plus `src/stores/api.js` define the boundary between local UI state and the remote AI backend.
   - The README indicates the backend must be OpenAI-compatible, so the app is designed to target pluggable model providers rather than one fixed service.

6. **Workflow orchestration**
   - `useWorkflowOrchestrator` is the key coordination layer for automatic execution.
   - It converts user intent into a concrete node sequence, creates or wires nodes, then waits for configuration/output readiness before continuing.
   - The README’s “自动执行工作流” feature suggests this orchestrator is the main engine for non-manual graph generation and execution.

7. **Configuration and model catalog**
   - `src/config/providers.js`, `models.js`, and `workflows.js` define the supported providers, model choices, and workflow templates.
   - `src/stores/models.js` and `src/stores/pinia/models.js` suggest the app keeps model metadata both in app-level state and in a Pinia-backed store layer.
   - This separation lets UI components render only the available options for the selected provider/API setup.

8. **State management boundaries**
   - Persistent app state is split across stores for API config, canvas state, projects, models, and theme.
   - `src/stores/projects.js` implies multiple canvases or saved project graphs are managed locally.
   - `src/stores/canvas.js` likely tracks the live graph, selection, history, and execution state, while `theme.js` handles dark/light mode.

9. **Composable hooks as the integration layer**
   - The `src/hooks/` directory is the main coordination layer between UI, stores, and API calls.
   - Hooks such as `useApi`, `useProvider`, `useModelConfig`, `useApiConfig`, and `useNodeRef` keep node components thin and reusable.
   - This is the architectural seam where graph nodes obtain config, resolve refs, and trigger execution.

10. **Utility and request pipeline**
    - `src/utils/request.js`, `schema.js`, and `constants.js` provide shared request logic, validation/schema helpers, and app constants.
    - `src/api/index.js` likely centralizes API client setup, so the rest of the app does not directly handle low-level HTTP concerns.
    - This keeps network concerns separate from canvas rendering and workflow logic.

11. **User-facing composition**
    - `AppHeader.vue`, `WorkflowPanel.vue`, `MentionsPicker.vue`, and `DownloadModal.vue` are the main non-canvas UI pieces.
    - These components support workflow selection, prompt editing, export/download flows, and app-level actions like settings or theme switching.
    - They sit above the canvas as control and utility surfaces, not as core execution logic.

12. **Data flow from input to output**
    - A user enters prompt text or a structured workflow.
    - The canvas/store layer records the graph and node parameters.
    - The orchestrator resolves the workflow, calls the appropriate API client, and writes results back into output nodes.
    - Generated images/videos are then displayed in the corresponding nodes and can be downloaded or reused as inputs to later steps.

13. **Architecture boundary for extensibility**
    - The app is designed around pluggable providers and workflow templates rather than hardcoded one-off screens.
    - Adding a new generation type would mainly involve adding a config entry, an API wrapper, a node component, and orchestration rules.
    - That makes the diagram naturally centered on a reusable graph engine with provider-specific adapters around it.

Main entry points: [`src/views/Canvas.vue`](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/views/Canvas.vue) (Canvas), [`src/hooks`](https://github.com/chatfire-ai/huobao-canvas/tree/main/src/hooks) (Hooks), [`src/stores`](https://github.com/chatfire-ai/huobao-canvas/tree/main/src/stores) (Stores), [`src/api`](https://github.com/chatfire-ai/huobao-canvas/tree/main/src/api) (API clients)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_app["App<br/>vue root<br/>[App.vue]"]
  node_main["Main<br/>bootstrap<br/>[main.js]"]
  node_router["Router<br/>routing<br/>[index.js]"]
  node_home["Home<br/>landing view<br/>[Home.vue]"]
  node_workflowpanel["Workflow panel<br/>control ui<br/>[WorkflowPanel.vue]"]
  node_header["Header<br/>chrome ui<br/>[AppHeader.vue]"]
end

subgraph group_workspace["Canvas workspace"]
  node_canvasview["Canvas<br/>editor view<br/>[Canvas.vue]"]
  node_textnode["Text node<br/>input node<br/>[TextNode.vue]"]
  node_llmnode["LLM config<br/>config node<br/>[LLMConfigNode.vue]"]
  node_imgconf["Image config<br/>config node"]
  node_imgnode["Image node<br/>output node<br/>[ImageNode.vue]"]
  node_vidconf["Video config<br/>config node"]
  node_vidnode["Video node<br/>output node<br/>[VideoNode.vue]"]
  node_edges["Custom edges<br/>graph links"]
end

subgraph group_workflow["Workflow engine"]
  node_orchestrator{{"Orchestrator<br/>workflow engine"}}
  node_hooks["Hooks<br/>integration layer"]
end

subgraph group_ai["AI integration"]
  node_apiclients[("API clients<br/>provider adapters")]
  node_request["Request core<br/>http core<br/>[request.js]"]
  node_settings["API settings<br/>config UI<br/>[ApiSettings.vue]"]
end

subgraph group_state["State and config"]
  node_stores[("Stores<br/>app state")]
  node_modelscfg["Model config<br/>catalog config"]
end

node_main -->|"mounts"| node_app
node_app -->|"uses"| node_router
node_router -->|"route"| node_home
node_router -->|"route"| node_canvasview
node_canvasview -->|"renders"| node_textnode
node_canvasview -->|"renders"| node_llmnode
node_canvasview -->|"renders"| node_imgconf
node_canvasview -->|"renders"| node_imgnode
node_canvasview -->|"renders"| node_vidconf
node_canvasview -->|"renders"| node_vidnode
node_canvasview -->|"connects"| node_edges
node_workflowpanel -->|"controls"| node_canvasview
node_header -->|"controls"| node_canvasview
node_hooks -->|"reads/writes"| node_stores
node_hooks -->|"calls"| node_apiclients
node_hooks -->|"uses"| node_request
node_hooks -->|"consults"| node_modelscfg
node_orchestrator -->|"uses"| node_hooks
node_orchestrator -->|"invokes"| node_apiclients
node_orchestrator -->|"updates"| node_stores
node_settings -->|"binds"| node_stores
node_stores -->|"derives from"| node_modelscfg
node_stores -->|"drives"| node_canvasview
node_apiclients -->|"built on"| node_request
node_apiclients -->|"targets"| node_modelscfg

click node_app "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/App.vue"
click node_main "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/main.js"
click node_router "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/router/index.js"
click node_home "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/views/Home.vue"
click node_canvasview "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/views/Canvas.vue"
click node_textnode "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/TextNode.vue"
click node_llmnode "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/LLMConfigNode.vue"
click node_imgconf "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/ImageConfigNode.vue"
click node_imgnode "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/ImageNode.vue"
click node_vidconf "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/VideoConfigNode.vue"
click node_vidnode "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/VideoNode.vue"
click node_edges "https://github.com/chatfire-ai/huobao-canvas/tree/main/src/components/edges"
click node_orchestrator "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/hooks/useWorkflowOrchestrator.js"
click node_hooks "https://github.com/chatfire-ai/huobao-canvas/tree/main/src/hooks"
click node_apiclients "https://github.com/chatfire-ai/huobao-canvas/tree/main/src/api"
click node_request "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/utils/request.js"
click node_settings "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/ApiSettings.vue"
click node_stores "https://github.com/chatfire-ai/huobao-canvas/tree/main/src/stores"
click node_modelscfg "https://github.com/chatfire-ai/huobao-canvas/tree/main/src/config"
click node_workflowpanel "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/WorkflowPanel.vue"
click node_header "https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/AppHeader.vue"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_main,node_router,node_home,node_workflowpanel,node_header toneBlue
class node_canvasview,node_textnode,node_llmnode,node_imgconf,node_imgnode,node_vidconf,node_vidnode,node_edges toneAmber
class node_orchestrator,node_hooks toneMint
class node_apiclients,node_request,node_settings toneRose
class node_stores,node_modelscfg toneIndigo
```

## Components

### App shell

Bootstraps routing, layout, and global UI chrome.

- [App](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/App.vue): vue root · Root Vue component that hosts the application shell. · `src/App.vue`
- [Main](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/main.js): bootstrap · Application entry that mounts Vue and registers global setup. · `src/main.js`
- [Router](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/router/index.js): routing · Route definitions for landing and canvas views. · `src/router/index.js`
- [Home](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/views/Home.vue): landing view · Entry view for projects and initial navigation. · `src/views/Home.vue`
- [Workflow panel](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/WorkflowPanel.vue): control ui · Controls for choosing workflows and steering prompt-driven actions. · `src/components/WorkflowPanel.vue`
- [Header](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/AppHeader.vue): chrome ui · Top-level app actions such as navigation and theme or settings access. · `src/components/AppHeader.vue`

### Canvas workspace

Main graph-editing surface and node/edge rendering.

- [Canvas](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/views/Canvas.vue): editor view · Primary workflow editor view built around Vue Flow. · `src/views/Canvas.vue`
- [Text node](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/TextNode.vue): input node · Prompt/text editing node used as workflow input. · `src/components/nodes/TextNode.vue`
- [LLM config](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/LLMConfigNode.vue): config node · Configuration node for language model generation settings. · `src/components/nodes/LLMConfigNode.vue`
- [Image config](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/ImageConfigNode.vue): config node · Configuration node for image generation parameters. · `src/components/nodes/ImageConfigNode.vue`
- [Image node](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/ImageNode.vue): output node · Displays generated images and serves as image workflow output. · `src/components/nodes/ImageNode.vue`
- [Video config](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/VideoConfigNode.vue): config node · Configuration node for video generation parameters. · `src/components/nodes/VideoConfigNode.vue`
- [Video node](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/nodes/VideoNode.vue): output node · Displays generated videos and serves as video workflow output. · `src/components/nodes/VideoNode.vue`
- [Custom edges](https://github.com/chatfire-ai/huobao-canvas/tree/main/src/components/edges): graph links · Domain-specific connection rules for prompt, image, and role relationships. · `src/components/edges`

### Workflow engine

Orchestrates node sequences and execution.

- [Orchestrator](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/hooks/useWorkflowOrchestrator.js): workflow engine · Builds, wires, and advances automatic workflow execution. · `src/hooks/useWorkflowOrchestrator.js`
- [Hooks](https://github.com/chatfire-ai/huobao-canvas/tree/main/src/hooks): integration layer · Composable layer that connects UI, stores, providers, and node refs. · `src/hooks`

### AI integration

Provider-facing API clients and request boundary.

- [API clients](https://github.com/chatfire-ai/huobao-canvas/tree/main/src/api): provider adapters · Chat, image, video, and model metadata clients for external AI calls. · `src/api`
- [Request core](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/utils/request.js): http core · Shared request helper and API setup used by the provider clients. · `src/utils/request.js`
- [API settings](https://github.com/chatfire-ai/huobao-canvas/blob/main/src/components/ApiSettings.vue): config UI · UI and store boundary for provider credentials and API settings. · `src/components/ApiSettings.vue`

### State and config

Stores and static configuration shared across the app.

- [Stores](https://github.com/chatfire-ai/huobao-canvas/tree/main/src/stores): app state · Pinia and app-level stores for API, canvas, projects, models, and theme. · `src/stores`
- [Model config](https://github.com/chatfire-ai/huobao-canvas/tree/main/src/config): catalog config · Provider, model, and workflow template definitions. · `src/config`

## Connections

- Main → App: mounts · Bootstraps the root component.
- App → Router: uses · Delegates navigation to the router.
- Router → Home: route · Maps the landing path to the home view.
- Router → Canvas: route · Maps the editor path to the canvas view.
- Canvas → Text node: renders · Places text input nodes on the canvas.
- Canvas → LLM config: renders · Places model-configuration nodes on the canvas.
- Canvas → Image config: renders · Places image configuration nodes on the canvas.
- Canvas → Image node: renders · Places image output nodes on the canvas.
- Canvas → Video config: renders · Places video configuration nodes on the canvas.
- Canvas → Video node: renders · Places video output nodes on the canvas.
- Canvas → Custom edges: connects · Uses custom edge components for graph semantics.
- Workflow panel → Canvas: controls · Drives canvas-side workflow creation and selection.
- Header → Canvas: controls · Provides top-level actions for the editor experience.
- Hooks → Stores: reads/writes · Integrates composables with shared application state.
- Hooks → API clients: calls · Composables trigger provider client operations.
- Hooks → Request core: uses · Shares low-level request behavior across API calls.
- Hooks → Model config: consults · Resolves provider and model options from config.
- Orchestrator → Hooks: uses · Coordinates execution through composable integration points.
- Orchestrator → API clients: invokes · Executes generation steps through provider adapters.
- Orchestrator → Stores: updates · Writes execution and graph state back to stores.
- API settings → Stores: binds · Edits and persists API configuration in state.
- Stores → Model config: derives from · Uses static catalogs to populate available options.
- Stores → Canvas: drives · Supplies live graph, selection, and execution state.
- API clients → Request core: built on · Provider clients share the HTTP/request core.
- API clients → Model config: targets · Uses provider/model metadata to shape requests.
