# darkpancakes/clipforge architecture

> Architecture diagram of the GitHub repository darkpancakes/clipforge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/darkpancakes/clipforge
- Repository: https://github.com/darkpancakes/clipforge

## Overview

ClipForge turns a topic or supplied script into a vertical short-form video. Users can start through the CLI or the Python API; each orchestrates script generation (or accepts custom text), narration with word timings, subtitles, visual clips, and final composition. Visual generation includes scene prompts, AI-image generation with a gradient fallback, and Ken Burns effects; composition mixes narration and optional music and burns in subtitles. Source excerpts show the orchestration and core implementations; some visual-provider and fallback details are also documented in the README.

Main entry points: [`clipforge/cli.py`](https://github.com/darkpancakes/clipforge/blob/main/clipforge/cli.py) (CLI), [`clipforge/__init__.py`](https://github.com/darkpancakes/clipforge/blob/main/clipforge/__init__.py) (Python API), [`clipforge/voice.py`](https://github.com/darkpancakes/clipforge/blob/main/clipforge/voice.py) (Speech synthesis), [`clipforge/config.py`](https://github.com/darkpancakes/clipforge/blob/main/clipforge/config.py) (Configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI<br/>[cli.py]"]
  node_api["Python API<br/>[__init__.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_content["Script and visuals"]
  node_story["Script generation<br/>[story.py]"]
  node_visuals["Visual clips<br/>[visuals.py]"]
end

subgraph group_audio["Narration and captions"]
  node_voice["Speech synthesis<br/>[voice.py]"]
  node_subtitles["Subtitle generation<br/>[subtitles.py]"]
end

subgraph group_render["Video rendering"]
  node_compose["Video composition<br/>[compose.py]"]
end

node_user(("User"))
node_llm{{"LLM provider"}}
node_fal{{"fal.ai images"}}
node_edge{{"Edge TTS"}}
node_ffmpeg{{"FFmpeg tools"}}
node_video["Final video"]

node_user -->|"runs command"| node_cli
node_user -->|"calls library"| node_api
node_cli -->|"loads settings"| node_config
node_api -->|"loads settings"| node_config
node_cli -->|"generates script"| node_story
node_api -->|"generates script"| node_story
node_story -->|"reads provider settings"| node_config
node_story -->|"requests completion"| node_llm
node_cli -->|"synthesizes narration"| node_voice
node_api -->|"synthesizes narration"| node_voice
node_voice -->|"reads voice settings"| node_config
node_voice -->|"requests speech"| node_edge
node_cli -->|"creates captions"| node_subtitles
node_api -->|"creates captions"| node_subtitles
node_voice -->|"provides word timings"| node_subtitles
node_cli -->|"generates clips"| node_visuals
node_api -->|"generates clips"| node_visuals
node_visuals -->|"reads image settings"| node_config
node_visuals -->|"requests images"| node_fal
node_cli -->|"composes video"| node_compose
node_api -->|"composes video"| node_compose
node_compose -->|"renders media"| node_ffmpeg
node_compose -->|"writes output"| node_video
node_cli -->|"reports output"| node_video

click node_cli "https://github.com/darkpancakes/clipforge/blob/main/clipforge/cli.py"
click node_api "https://github.com/darkpancakes/clipforge/blob/main/clipforge/__init__.py"
click node_config "https://github.com/darkpancakes/clipforge/blob/main/clipforge/config.py"
click node_story "https://github.com/darkpancakes/clipforge/blob/main/clipforge/story.py"
click node_visuals "https://github.com/darkpancakes/clipforge/blob/main/clipforge/visuals.py"
click node_voice "https://github.com/darkpancakes/clipforge/blob/main/clipforge/voice.py"
click node_subtitles "https://github.com/darkpancakes/clipforge/blob/main/clipforge/subtitles.py"
click node_compose "https://github.com/darkpancakes/clipforge/blob/main/clipforge/compose.py"

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_cli,node_api,node_config,node_user toneBlue
class node_story,node_visuals toneAmber
class node_voice,node_subtitles toneMint
class node_compose toneRose
class node_llm,node_fal,node_edge,node_ffmpeg,node_video toneIndigo
```

## Components

### Entry points

- [CLI](https://github.com/darkpancakes/clipforge/blob/main/clipforge/cli.py): `clipforge/cli.py`
- [Python API](https://github.com/darkpancakes/clipforge/blob/main/clipforge/__init__.py): `clipforge/__init__.py`
- [Configuration](https://github.com/darkpancakes/clipforge/blob/main/clipforge/config.py): `clipforge/config.py`

### Script and visuals

- [Script generation](https://github.com/darkpancakes/clipforge/blob/main/clipforge/story.py): `clipforge/story.py`
- [Visual clips](https://github.com/darkpancakes/clipforge/blob/main/clipforge/visuals.py): `clipforge/visuals.py`

### Narration and captions

- [Speech synthesis](https://github.com/darkpancakes/clipforge/blob/main/clipforge/voice.py): `clipforge/voice.py`
- [Subtitle generation](https://github.com/darkpancakes/clipforge/blob/main/clipforge/subtitles.py): `clipforge/subtitles.py`

### Video rendering

- [Video composition](https://github.com/darkpancakes/clipforge/blob/main/clipforge/compose.py): `clipforge/compose.py`

### Other components

- **User**
- **LLM provider**
- **fal.ai images**
- **Edge TTS**
- **FFmpeg tools**
- **Final video**

## Connections

- User → CLI: runs command (evidence: `README.md`)
- User → Python API: calls library (evidence: `README.md`)
- CLI → Configuration: loads settings (evidence: `clipforge/cli.py`)
- Python API → Configuration: loads settings (evidence: `clipforge/__init__.py`)
- CLI → Script generation: generates script (evidence: `clipforge/cli.py`)
- Python API → Script generation: generates script (evidence: `clipforge/__init__.py`)
- Script generation → Configuration: reads provider settings (evidence: `clipforge/story.py`)
- Script generation → LLM provider: requests completion (evidence: `clipforge/story.py`)
- CLI → Speech synthesis: synthesizes narration (evidence: `clipforge/cli.py`)
- Python API → Speech synthesis: synthesizes narration (evidence: `clipforge/__init__.py`)
- Speech synthesis → Configuration: reads voice settings (evidence: `clipforge/voice.py`)
- Speech synthesis → Edge TTS: requests speech (evidence: `clipforge/voice.py`)
- CLI → Subtitle generation: creates captions (evidence: `clipforge/cli.py`)
- Python API → Subtitle generation: creates captions (evidence: `clipforge/__init__.py`)
- Speech synthesis → Subtitle generation: provides word timings (evidence: `README.md`)
- CLI → Visual clips: generates clips (evidence: `clipforge/cli.py`)
- Python API → Visual clips: generates clips (evidence: `clipforge/__init__.py`)
- Visual clips → Configuration: reads image settings (evidence: `clipforge/visuals.py`)
- Visual clips → fal.ai images: requests images (evidence: `README.md`)
- CLI → Video composition: composes video (evidence: `clipforge/cli.py`)
- Python API → Video composition: composes video (evidence: `clipforge/__init__.py`)
- Video composition → FFmpeg tools: renders media (evidence: `clipforge/compose.py`)
- Video composition → Final video: writes output (evidence: `clipforge/compose.py`)
- CLI → Final video: reports output (evidence: `clipforge/cli.py`)
