# aidc-ai/pixelle-video architecture

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

- Interactive diagram: https://gitdiagram.com/aidc-ai/pixelle-video
- Repository: https://github.com/aidc-ai/pixelle-video

## Overview

1. **What this repo is**
   Pixelle-Video is a Python-based AI video generation platform with two user-facing entry points: a **Streamlit web UI** for interactive creation and a **FastAPI backend** for programmatic control. The core product is an orchestration engine that turns a topic or script into a finished short video.

2. **Top-level architecture**
   The repository is split into four main layers:
   - **Presentation**: `web/` for the Streamlit app, `api/` for HTTP endpoints
   - **Orchestration/core**: `pixelle_video/` for pipelines, services, prompts, and config
   - **Assets and execution artifacts**: `templates/`, `workflows/`, `bgm/`, `output/`-style generated files
   - **Docs and packaging**: `docs/`, `packaging/`, Docker and Windows packaging scripts

3. **Primary generation flow**
   The central data flow is: **topic/script input → script generation → storyboard/media planning → image/video generation → TTS narration → frame assembly → final video composition**. The README’s “one topic to full video” workflow is reflected in the `pixelle_video/pipelines/` and `pixelle_video/services/` modules.

4. **Core orchestration layer**
   `pixelle_video/service.py` and the pipeline modules under `pixelle_video/pipelines/` are the main coordination layer. The available pipeline variants indicate the system can generate videos in different modes:
   - **standard / linear**: default end-to-end automation
   - **asset_based**: builds videos from user-provided assets
   - **custom**: user-defined workflow composition  
   This layer is the boundary that decides which services to call and in what order.

5. **Service layer responsibilities**
   `pixelle_video/services/` contains the concrete integrations and media-processing logic:
   - `llm_service.py` for language-model calls and text generation
   - `tts_service.py` for text-to-speech generation
   - `video.py` and `media.py` for media assembly/handling
   - `frame_processor.py` and `frame_html.py` for template-driven frame rendering
   - `image_analysis.py` and `video_analysis.py` for understanding uploaded media
   - `persistence.py` and `history_manager.py` for saving and retrieving past jobs  
   This layer sits between the orchestration pipelines and external AI/media systems.

6. **External AI/runtime boundaries**
   The repo is designed around pluggable AI backends rather than one fixed model provider:
   - **LLMs**: GPT, Qwen, DeepSeek, Ollama, etc.
   - **Image/video generation**: primarily ComfyUI-compatible workflows
   - **Cloud or self-hosted execution**: `workflows/runninghub/` and `workflows/selfhost/` show two deployment modes
   - **TTS**: Edge-TTS, Index-TTS, and other workflow-backed voice engines  
   These are not embedded models; they are called through configured services and workflow JSON files.

7. **Workflow-as-configuration model**
   The `workflows/` directory is a major architectural boundary. It stores JSON definitions for ComfyUI-style workflows for image generation, video generation, TTS, and media analysis. The application scans these workflows and lets the user choose them at runtime, which makes the system highly extensible without changing Python code.

8. **Template-driven rendering**
   `templates/` contains HTML templates grouped by resolution and media type:
   - `static_*.html`
   - `image_*.html`
   - `video_*.html`  
   These templates define the visual layout of each video frame. The frame processor and template utilities turn generated content into rendered frames, so the template layer is a separate presentation subsystem from the web UI.

9. **API backend**
   `api/` exposes functional endpoints for the generation platform. The router split shows the backend surface area:
   - content/script generation
   - file handling
   - frame generation
   - image, LLM, TTS, and video endpoints
   - resources/config discovery
   - task management
   - health checks  
   This API is likely the integration point for external clients and for the web app if it delegates generation work over HTTP.

10. **Async job management**
   `api/tasks/` contains task models and a manager, indicating generation is handled as **background work** rather than a single synchronous request. That fits the long-running nature of LLM, image, TTS, and video composition jobs. The UI likely polls task status or receives progress updates from this layer.

11. **Web UI composition**
   `web/` is a Streamlit application with reusable components, page modules, i18n, session state, and UI-side pipeline helpers. It provides the interactive experience described in the README: configuration panels, content input, voice settings, visual settings, generation, preview, and history. The web layer is presentation-only; it orchestrates user input and displays progress/results.

12. **Config and runtime state**
   Configuration is handled through `pixelle_video/config/` plus `api/config.py`, with a sample YAML config at the repo root. The system supports first-run setup for model endpoints, API keys, and workflow selection. UI session state in `web/state/session.py` keeps per-user runtime choices separate from persistent project configuration.

13. **Media and history storage**
   The project appears to use the filesystem as the primary persistence boundary: background music under `bgm/`, generated outputs saved locally, and history managed through service classes rather than a relational database. That means the architecture is closer to a **file-backed media pipeline** than a database-centered application.

14. **Deployment and packaging**
   The repo supports several delivery modes: local source execution, Docker, devcontainer, and a Windows bundled release. The packaging and startup scripts show that the app is meant to run as a self-hosted creative workstation, with optional cloud services for generation workloads.

15. **How to draw the diagram**
   A good architecture diagram should show:
   - **User → Streamlit UI / FastAPI API**
   - **UI/API → orchestration pipelines**
   - **Pipelines → services**
   - **Services → external LLM / ComfyUI / TTS providers**
   - **Rendering services → templates/workflows/filesystem**
   - **Background task manager → progress/history storage**  
   The key idea is that Pixelle-Video is an orchestration platform for multi-step AI media generation, not a single-model app.

Main entry points: [`pixelle_video/service.py`](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/service.py) (Service Core), [`pixelle_video/pipelines/linear.py`](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/linear.py) (Linear), [`workflows`](https://github.com/aidc-ai/pixelle-video/tree/main/workflows) (Workflows), [`pixelle_video/config/manager.py`](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/config/manager.py) (Config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_web_app["Web UI<br/>streamlit app<br/>[app.py]"]
  node_api_app["API<br/>[app.py]"]
  node_web_pipeline_standard["Standard UI<br/>ui pipeline<br/>[standard.py]"]
  node_web_pipeline_asset["Asset UI<br/>ui pipeline<br/>[asset_based.py]"]
  node_web_pipeline_transfer["Action Transfer<br/>ui adapter<br/>[action_transfer.py]"]
end

subgraph group_orchestration["Orchestration Core"]
  node_service_coordinator{{"Service Core<br/>orchestrator<br/>[service.py]"}}
  node_pipeline_standard["Standard<br/>generation pipeline<br/>[standard.py]"]
  node_pipeline_linear["Linear<br/>generation pipeline<br/>[linear.py]"]
  node_pipeline_asset["Asset Based<br/>generation pipeline<br/>[asset_based.py]"]
  node_pipeline_custom["Custom<br/>generation pipeline<br/>[custom.py]"]
  node_pipeline_base["Pipeline Base<br/>pipeline abstraction<br/>[base.py]"]
  node_storyboard_models["Storyboards<br/>domain models<br/>[storyboard.py]"]
  node_media_models["Media Models<br/>domain models<br/>[media.py]"]
end

subgraph group_services["Media Services"]
  node_llm_service["LLM Service<br/>text generation service<br/>[llm_service.py]"]
  node_tts_service["TTS Service<br/>voice synthesis service<br/>[tts_service.py]"]
  node_frame_processor["Frame Processor<br/>rendering service<br/>[frame_processor.py]"]
  node_video_service["Video Service<br/>composition service<br/>[video.py]"]
  node_analysis_services["Analysis<br/>media understanding service<br/>[image_analysis.py]"]
end

subgraph group_runtime["Workflows and Templates"]
  node_workflow_catalog[("Workflows<br/>workflow json")]
  node_template_catalog["Templates"]
end

subgraph group_state["Config and State"]
  node_persistence_services["History Store<br/>storage service<br/>[persistence.py]"]
  node_task_manager["Task Manager<br/>background jobs<br/>[manager.py]"]
  node_config_manager["Config<br/>[manager.py]"]
end

node_web_app -->|"drives"| node_web_pipeline_standard
node_web_app -->|"drives"| node_web_pipeline_asset
node_web_pipeline_standard -->|"delegates"| node_web_pipeline_transfer
node_web_pipeline_asset -->|"delegates"| node_web_pipeline_transfer
node_api_app -->|"dispatches"| node_task_manager
node_task_manager -->|"runs"| node_service_coordinator
node_service_coordinator -->|"uses"| node_pipeline_base
node_service_coordinator -->|"selects"| node_pipeline_standard
node_service_coordinator -->|"selects"| node_pipeline_asset
node_service_coordinator -->|"selects"| node_pipeline_custom
node_pipeline_standard -->|"implements"| node_pipeline_linear
node_pipeline_linear -->|"calls"| node_llm_service
node_pipeline_linear -->|"calls"| node_analysis_services
node_pipeline_linear -->|"calls"| node_tts_service
node_pipeline_linear -->|"calls"| node_frame_processor
node_pipeline_linear -->|"calls"| node_video_service
node_frame_processor -->|"renders with"| node_template_catalog
node_llm_service -->|"backs onto"| node_workflow_catalog
node_tts_service -->|"backs onto"| node_workflow_catalog
node_analysis_services -->|"backs onto"| node_workflow_catalog
node_video_service -->|"uses"| node_workflow_catalog
node_config_manager -->|"discovers"| node_workflow_catalog
node_config_manager -->|"configures"| node_task_manager
node_persistence_services -->|"stores"| node_task_manager
node_api_app -->|"loads"| node_config_manager
node_web_app -->|"loads"| node_config_manager
node_service_coordinator -->|"builds"| node_storyboard_models
node_service_coordinator -->|"tracks"| node_media_models
node_api_app -->|"reads/writes"| node_persistence_services

click node_web_app "https://github.com/aidc-ai/pixelle-video/blob/main/web/app.py"
click node_api_app "https://github.com/aidc-ai/pixelle-video/blob/main/api/app.py"
click node_web_pipeline_standard "https://github.com/aidc-ai/pixelle-video/blob/main/web/pipelines/standard.py"
click node_web_pipeline_asset "https://github.com/aidc-ai/pixelle-video/blob/main/web/pipelines/asset_based.py"
click node_web_pipeline_transfer "https://github.com/aidc-ai/pixelle-video/blob/main/web/pipelines/action_transfer.py"
click node_service_coordinator "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/service.py"
click node_pipeline_standard "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/standard.py"
click node_pipeline_linear "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/linear.py"
click node_pipeline_asset "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/asset_based.py"
click node_pipeline_custom "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/custom.py"
click node_pipeline_base "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/base.py"
click node_storyboard_models "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/models/storyboard.py"
click node_media_models "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/models/media.py"
click node_llm_service "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/llm_service.py"
click node_tts_service "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/tts_service.py"
click node_frame_processor "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/frame_processor.py"
click node_video_service "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/video.py"
click node_analysis_services "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/image_analysis.py"
click node_persistence_services "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/persistence.py"
click node_task_manager "https://github.com/aidc-ai/pixelle-video/blob/main/api/tasks/manager.py"
click node_config_manager "https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/config/manager.py"
click node_workflow_catalog "https://github.com/aidc-ai/pixelle-video/tree/main/workflows"
click node_template_catalog "https://github.com/aidc-ai/pixelle-video/tree/main/templates"

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_web_app,node_api_app,node_web_pipeline_standard,node_web_pipeline_asset,node_web_pipeline_transfer toneBlue
class node_service_coordinator,node_pipeline_standard,node_pipeline_linear,node_pipeline_asset,node_pipeline_custom,node_pipeline_base,node_storyboard_models,node_media_models toneAmber
class node_llm_service,node_tts_service,node_frame_processor,node_video_service,node_analysis_services toneMint
class node_workflow_catalog,node_template_catalog toneRose
class node_persistence_services,node_task_manager,node_config_manager toneIndigo
```

## Components

### Presentation

User-facing entry points for interactive and programmatic use

- [Web UI](https://github.com/aidc-ai/pixelle-video/blob/main/web/app.py): streamlit app · Interactive creation interface for content input, settings, generation, preview, and history · `web/app.py`
- [API](https://github.com/aidc-ai/pixelle-video/blob/main/api/app.py): fastapi app · HTTP backend exposing generation, files, tasks, and health endpoints · `api/app.py`
- [Standard UI](https://github.com/aidc-ai/pixelle-video/blob/main/web/pipelines/standard.py): ui pipeline · Main Streamlit flow for guided video creation · `web/pipelines/standard.py`
- [Asset UI](https://github.com/aidc-ai/pixelle-video/blob/main/web/pipelines/asset_based.py): ui pipeline · UI flow for assembling videos from uploaded or user-provided assets · `web/pipelines/asset_based.py`
- [Action Transfer](https://github.com/aidc-ai/pixelle-video/blob/main/web/pipelines/action_transfer.py): ui adapter · Bridges UI actions into the underlying generation pipeline · `web/pipelines/action_transfer.py`

### Orchestration Core

Central pipelines and coordination logic for video generation

- [Service Core](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/service.py): orchestrator · Coordinates pipeline execution and service calls across generation modes · `pixelle_video/service.py`
- [Standard](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/standard.py): generation pipeline · Default end-to-end topic-to-video pipeline · `pixelle_video/pipelines/standard.py`
- [Linear](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/linear.py): generation pipeline · Sequential pipeline implementation for the core generation flow · `pixelle_video/pipelines/linear.py`
- [Asset Based](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/asset_based.py): generation pipeline · Pipeline for building videos from provided assets · `pixelle_video/pipelines/asset_based.py`
- [Custom](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/custom.py): generation pipeline · User-composed workflow pipeline · `pixelle_video/pipelines/custom.py`
- [Pipeline Base](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/pipelines/base.py): pipeline abstraction · Shared pipeline interface and common execution behavior · `pixelle_video/pipelines/base.py`
- [Storyboards](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/models/storyboard.py): domain models · Structured video planning objects used by orchestration and services · `pixelle_video/models/storyboard.py`
- [Media Models](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/models/media.py): domain models · Media and progress data structures shared across generation and API layers · `pixelle_video/models/media.py`

### Media Services

Concrete integrations for LLM, TTS, analysis, rendering, and assembly

- [LLM Service](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/llm_service.py): text generation service · Language-model integration for scripts, titles, prompts, and narration text · `pixelle_video/services/llm_service.py`
- [TTS Service](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/tts_service.py): voice synthesis service · Text-to-speech generation and voice configuration integration · `pixelle_video/services/tts_service.py`
- [Frame Processor](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/frame_processor.py): rendering service · Transforms content into rendered video frames using templates · `pixelle_video/services/frame_processor.py`
- [Video Service](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/video.py): composition service · Assembles frames, audio, and media into final video outputs · `pixelle_video/services/video.py`
- [Analysis](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/image_analysis.py): media understanding service · Image and video analysis for uploaded media and workflow selection · `pixelle_video/services/image_analysis.py`

### Workflows and Templates

Workflow JSON and HTML templates used at runtime

- [Workflows](https://github.com/aidc-ai/pixelle-video/tree/main/workflows): workflow json · ComfyUI-style workflow definitions for image, video, TTS, and analysis · `workflows`
- [Templates](https://github.com/aidc-ai/pixelle-video/tree/main/templates): html templates · Resolution-specific HTML templates for static, image, and video frames · `templates`

### Config and State

Configuration, task management, and stored job history

- [History Store](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/services/persistence.py): storage service · File-backed persistence and job history management · `pixelle_video/services/persistence.py`
- [Task Manager](https://github.com/aidc-ai/pixelle-video/blob/main/api/tasks/manager.py): background jobs · Manages asynchronous long-running generation tasks and status tracking · `api/tasks/manager.py`
- [Config](https://github.com/aidc-ai/pixelle-video/blob/main/pixelle_video/config/manager.py): runtime config · Loads and validates application configuration and presets · `pixelle_video/config/manager.py`

## Connections

- Web UI → Standard UI: drives · The UI routes user actions into the standard generation flow
- Web UI → Asset UI: drives · The UI supports asset-based creation when users provide source media
- Standard UI → Action Transfer: delegates · UI pipeline helpers transfer requests into execution logic
- Asset UI → Action Transfer: delegates · Asset-based UI shares the same action-transfer layer
- API → Task Manager: dispatches · API endpoints submit long-running work to background tasks
- Task Manager → Service Core: runs · Tasks invoke orchestration for generation jobs
- Service Core → Pipeline Base: uses · The coordinator selects a pipeline implementation
- Service Core → Standard: selects · Default end-to-end automation path
- Service Core → Asset Based: selects · Asset-driven generation path
- Service Core → Custom: selects · User-defined composition path
- Standard → Linear: implements · Standard mode is realized through the linear execution flow
- Linear → LLM Service: calls · Generates topic, script, titles, and narration text
- Linear → Analysis: calls · Analyzes source images and videos when needed
- Linear → TTS Service: calls · Produces narration audio
- Linear → Frame Processor: calls · Renders frames from generated content and templates
- Linear → Video Service: calls · Composes final video artifacts
- Frame Processor → Templates: renders with · Uses HTML templates as frame layouts
- LLM Service → Workflows: backs onto · LLM and related generation modes can be driven by workflow definitions
- TTS Service → Workflows: backs onto · Voice synthesis may use workflow-backed engines
- Analysis → Workflows: backs onto · Media understanding integrations can be workflow-defined
- Video Service → Workflows: uses · Video generation and enhancement can delegate to workflow JSON
- Config → Workflows: discovers · Configuration resolves available workflows and runtime choices
- Config → Task Manager: configures · Task behavior depends on runtime configuration
- History Store → Task Manager: stores · History and persisted job data support background execution
- API → Config: loads · API bootstrapping uses shared configuration
- Web UI → Config: loads · Web UI initializes from the shared runtime configuration
- Service Core → Storyboards: builds · Pipelines produce and consume storyboard structures
- Service Core → Media Models: tracks · Generation outputs and progress move through shared media models
- API → History Store: reads/writes · API surfaces stored histories and media artifacts
