# jaswanthroyg/storyforageai architecture

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

- Interactive diagram: https://gitdiagram.com/jaswanthroyg/storyforageai
- Repository: https://github.com/jaswanthroyg/storyforageai

## Overview

StoryForge AI is a CLI that turns a user’s story into a timed scene plan, generates per-scene images and narration, renders scene videos, then merges them with background music into an MP4. The pipeline coordinates these stages and handles stage-level failures; its runtime also creates a project folder and saves the plan. The graph reflects the documented workflow and sampled calls. The README describes capabilities such as configurable duration; unsampled internals are represented only where the documentation supports them.

Main entry points: [`pipeline.py`](https://github.com/jaswanthroyg/storyforageai/blob/main/pipeline.py) (Generation pipeline), [`ai/story.py`](https://github.com/jaswanthroyg/storyforageai/blob/main/ai/story.py) (Scene planner), [`video/composer.py`](https://github.com/jaswanthroyg/storyforageai/blob/main/video/composer.py) (Scene video composer), [`video/merge.py`](https://github.com/jaswanthroyg/storyforageai/blob/main/video/merge.py) (Video merger and music mix)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and orchestration"]
  node_cli["Story CLI<br/>[main.py]"]
  node_pipeline["Generation pipeline<br/>[pipeline.py]"]
end

subgraph group_planning["Planning and assets"]
  node_story["Scene planner<br/>[story.py]"]
  node_retry["Retry helper<br/>[retry.py]"]
  node_gemini{{"Gemini API"}}
  node_images["Scene image generator<br/>[image.py]"]
  node_pixazo{{"Pixazo API"}}
  node_audio["Narration generator<br/>[audio.py]"]
  node_edge_tts{{"Edge TTS"}}
end

subgraph group_rendering["Video rendering"]
  node_composer["Scene video composer<br/>[composer.py]"]
  node_ffmpeg{{"FFmpeg"}}
  node_merger["Video merger and music mix<br/>[merge.py]"]
end

subgraph group_project["Project output"]
  node_project_files["Project and plan files<br/>[files.py]"]
  node_music["Background music file"]
  node_output["Project assets and final MP4"]
end

node_user(("Story author"))

node_user -->|"enters story"| node_cli
node_cli -->|"runs workflow"| node_pipeline
node_pipeline -->|"requests scene plan"| node_story
node_story -->|"retries generation"| node_retry
node_story -->|"generates plan"| node_gemini
node_pipeline -->|"creates project and saves plan"| node_project_files
node_pipeline -->|"generates scene images"| node_images
node_images -->|"requests image generation"| node_pixazo
node_pipeline -->|"generates narration"| node_audio
node_audio -->|"synthesizes speech"| node_edge_tts
node_pipeline -->|"composes scene videos"| node_composer
node_composer -->|"renders scenes"| node_ffmpeg
node_pipeline -->|"merges scene videos"| node_merger
node_merger -->|"merges and mixes audio"| node_ffmpeg
node_pipeline -->|"configures music path"| node_music
node_project_files -->|"writes plan and project"| node_output
node_composer -->|"writes scene videos"| node_output
node_merger -->|"writes final MP4"| node_output
node_output -->|"reports final video"| node_cli

click node_cli "https://github.com/jaswanthroyg/storyforageai/blob/main/main.py"
click node_pipeline "https://github.com/jaswanthroyg/storyforageai/blob/main/pipeline.py"
click node_story "https://github.com/jaswanthroyg/storyforageai/blob/main/ai/story.py"
click node_retry "https://github.com/jaswanthroyg/storyforageai/blob/main/utils/retry.py"
click node_images "https://github.com/jaswanthroyg/storyforageai/blob/main/ai/image.py"
click node_audio "https://github.com/jaswanthroyg/storyforageai/blob/main/ai/audio.py"
click node_project_files "https://github.com/jaswanthroyg/storyforageai/blob/main/utils/files.py"
click node_composer "https://github.com/jaswanthroyg/storyforageai/blob/main/video/composer.py"
click node_merger "https://github.com/jaswanthroyg/storyforageai/blob/main/video/merge.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_pipeline toneBlue
class node_story,node_retry,node_gemini,node_images,node_pixazo,node_audio,node_edge_tts toneAmber
class node_composer,node_ffmpeg,node_merger toneMint
class node_project_files,node_music,node_output toneRose
class node_user toneIndigo
```

## Components

### CLI and orchestration

- [Story CLI](https://github.com/jaswanthroyg/storyforageai/blob/main/main.py): `main.py`
- [Generation pipeline](https://github.com/jaswanthroyg/storyforageai/blob/main/pipeline.py): `pipeline.py`

### Planning and assets

- [Scene planner](https://github.com/jaswanthroyg/storyforageai/blob/main/ai/story.py): `ai/story.py`
- [Retry helper](https://github.com/jaswanthroyg/storyforageai/blob/main/utils/retry.py): `utils/retry.py`
- **Gemini API**
- [Scene image generator](https://github.com/jaswanthroyg/storyforageai/blob/main/ai/image.py): `ai/image.py`
- **Pixazo API**
- [Narration generator](https://github.com/jaswanthroyg/storyforageai/blob/main/ai/audio.py): `ai/audio.py`
- **Edge TTS**

### Video rendering

- [Scene video composer](https://github.com/jaswanthroyg/storyforageai/blob/main/video/composer.py): `video/composer.py`
- **FFmpeg**
- [Video merger and music mix](https://github.com/jaswanthroyg/storyforageai/blob/main/video/merge.py): `video/merge.py`

### Project output

- [Project and plan files](https://github.com/jaswanthroyg/storyforageai/blob/main/utils/files.py): `utils/files.py`
- **Background music file**
- **Project assets and final MP4**

### Other components

- **Story author**

## Connections

- Story author → Story CLI: enters story (evidence: `main.py`)
- Story CLI → Generation pipeline: runs workflow (evidence: `main.py`)
- Generation pipeline → Scene planner: requests scene plan (evidence: `pipeline.py`)
- Scene planner → Retry helper: retries generation (evidence: `ai/story.py`)
- Scene planner → Gemini API: generates plan (evidence: `ai/story.py`)
- Generation pipeline → Project and plan files: creates project and saves plan (evidence: `pipeline.py`)
- Generation pipeline → Scene image generator: generates scene images (evidence: `pipeline.py`)
- Scene image generator → Pixazo API: requests image generation (evidence: `ai/image.py`)
- Generation pipeline → Narration generator: generates narration (evidence: `pipeline.py`)
- Narration generator → Edge TTS: synthesizes speech (evidence: `ai/audio.py`)
- Generation pipeline → Scene video composer: composes scene videos (evidence: `pipeline.py`)
- Scene video composer → FFmpeg: renders scenes (evidence: `video/composer.py`)
- Generation pipeline → Video merger and music mix: merges scene videos (evidence: `pipeline.py`)
- Video merger and music mix → FFmpeg: merges and mixes audio (evidence: `video/merge.py`)
- Generation pipeline → Background music file: configures music path (evidence: `pipeline.py`)
- Project and plan files → Project assets and final MP4: writes plan and project (evidence: `utils/files.py`)
- Scene video composer → Project assets and final MP4: writes scene videos
- Video merger and music mix → Project assets and final MP4: writes final MP4 (evidence: `video/merge.py`)
- Project assets and final MP4 → Story CLI: reports final video (evidence: `main.py`)
