How chatfire-ai/huobao-canvas works
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: Canvas.vue Canvas · hooks Hooks · stores Stores · api API clients
Components 21
App shell
Bootstraps routing, layout, and global UI chrome.
- App · Root Vue component that hosts the application shell.
src/App.vue - Main · Application entry that mounts Vue and registers global setup.
src/main.js - Router · Route definitions for landing and canvas views.
src/router/index.js - Home · Entry view for projects and initial navigation.
src/views/Home.vue - Workflow panel · Controls for choosing workflows and steering prompt-driven actions.
src/components/WorkflowPanel.vue - Header · 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 · Primary workflow editor view built around Vue Flow.
src/views/Canvas.vue - Text node · Prompt/text editing node used as workflow input.
src/components/nodes/TextNode.vue - LLM config · Configuration node for language model generation settings.
src/components/nodes/LLMConfigNode.vue - Image config · Configuration node for image generation parameters.
src/components/nodes/ImageConfigNode.vue - Image node · Displays generated images and serves as image workflow output.
src/components/nodes/ImageNode.vue - Video config · Configuration node for video generation parameters.
src/components/nodes/VideoConfigNode.vue - Video node · Displays generated videos and serves as video workflow output.
src/components/nodes/VideoNode.vue - Custom edges · Domain-specific connection rules for prompt, image, and role relationships.
src/components/edges
Workflow engine
Orchestrates node sequences and execution.
- Orchestrator · Builds, wires, and advances automatic workflow execution.
src/hooks/useWorkflowOrchestrator.js - Hooks · Composable layer that connects UI, stores, providers, and node refs.
src/hooks
AI integration
Provider-facing API clients and request boundary.
- API clients · Chat, image, video, and model metadata clients for external AI calls.
src/api - Request core · Shared request helper and API setup used by the provider clients.
src/utils/request.js - API settings · 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 · Pinia and app-level stores for API, canvas, projects, models, and theme.
src/stores - Model config · Provider, model, and workflow template definitions.
src/config
Connections 25
- 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.