# samuraigpt/text-to-video-ai architecture

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

- Interactive diagram: https://gitdiagram.com/samuraigpt/text-to-video-ai
- Repository: https://github.com/samuraigpt/text-to-video-ai

## Overview

#### Purpose and entry point
Text-To-Video-AI is a CLI-driven Python pipeline that turns a topic into a rendered MP4 for short-form or landscape video. The operational entry point is `app.py`; runtime configuration and provider selection are centralized in `.env.example` and `utility/config.py`.

#### Pipeline orchestration
`utility/pipeline_manager.py` coordinates the end-to-end job: generate a script, produce narration, derive caption timing, acquire/generate visual segments, then render the output. `app.py` supplies the topic and invokes this orchestration. Intermediate media and final composition are local filesystem artifacts, ending in `rendered_video.mp4`.

#### Script and visual planning
LLM-backed script creation is implemented in `utility/script/script_generator.py`, with provider credentials/configuration supplied through `utility/config.py`. Visual-query generation is separated in `utility/video/video_search_query_generator.py`, creating a boundary between narrative content and footage retrieval/generation.

#### Audio and caption timeline
Narration is generated through a selectable TTS abstraction in `utility/audio/audio_generator.py`, backed by EdgeTTS or ElevenLabs implementations in `utility/tts/edgetts_tts.py` and `utility/tts/elevenlabs_tts.py`. The resulting audio is transcribed into timed captions by `utility/captions/timed_captions_generator.py`, selecting local Whisper (`utility/stt/whisper_stt.py`) or Deepgram (`utility/stt/deepgram_stt.py`). This audio-derived timeline governs caption synchronization.

#### Visual media sources
Background footage is managed by `utility/video/background_video_generator.py`. The system can use Pexels for stock B-roll and MuAPI for text-to-video generation; MuAPI API interaction is isolated in `utility/muapi_client.py`. External model selection—including Veo, Sora, Kling, and others exposed by MuAPI—is configuration-driven rather than embedded in the renderer.

#### Rendering boundary
Python rendering integration lives in `utility/render/render_engine.py` and `utility/render/remotion_renderer.py`. FFmpeg and ImageMagick are material local dependencies for media processing. A separate Node/TypeScript Remotion project (`remotion-composer/package.json`) provides the composition runtime, preserving a clear boundary between Python’s AI/media pipeline and React-based video layout/rendering.

#### Remotion composition layer
`remotion-composer/src/Root.tsx` registers compositions, while `remotion-composer/src/CinematicRenderer.tsx` is the cinematic scene renderer. Reusable visual primitives—captions, title cards, charts, screenshot/terminal scenes, callouts, and overlays—reside under `remotion-composer/src/components/`. Composition-specific modules such as `remotion-composer/src/TitledVideo.tsx`, `remotion-composer/src/Explainer.tsx`, and `remotion-composer/src/TalkingHead.tsx` support multiple output formats driven by props.

#### Runtime and service dependencies
The main runtime is Python 3.8+ with a Node/Remotion rendering subprocess. Required or selectable external services are LLM providers (OpenAI, Groq, Gemini), Pexels, MuAPI, ElevenLabs, and Deepgram. Local alternatives—EdgeTTS and Whisper—reduce paid-service requirements but still require local media tooling and model/runtime support.

Main entry points: [`utility/pipeline_manager.py`](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/pipeline_manager.py) (Pipeline manager), [`utility/audio/audio_generator.py`](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/audio/audio_generator.py) (Audio generator), [`utility/script/script_generator.py`](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/script/script_generator.py) (Script generator), [`utility/captions/timed_captions_generator.py`](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/captions/timed_captions_generator.py) (Timed captions generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python["Python pipeline"]
  node_app["CLI entry point<br/>Python CLI<br/>[app.py]"]
  node_config["Runtime config<br/>configuration<br/>[config.py]"]
  node_pipeline["Pipeline manager<br/>orchestrator"]
  node_script["Script generator<br/>LLM stage"]
  node_visual_queries["Visual query generator<br/>planning stage"]
  node_audio["Audio generator<br/>TTS abstraction<br/>[audio_generator.py]"]
  node_edgetts["EdgeTTS adapter<br/>local TTS<br/>[edgetts_tts.py]"]
  node_elevenlabs["ElevenLabs adapter<br/>TTS provider adapter<br/>[elevenlabs_tts.py]"]
  node_captions["Timed captions generator<br/>caption timeline stage"]
  node_whisper["Whisper adapter<br/>local STT<br/>[whisper_stt.py]"]
  node_deepgram["Deepgram adapter<br/>STT provider adapter<br/>[deepgram_stt.py]"]
  node_background_video["Background video generator<br/>visual media stage"]
  node_muapi_client["MuAPI client<br/>video API adapter<br/>[muapi_client.py]"]
  node_render_engine["Render engine<br/>render coordinator<br/>[render_engine.py]"]
  node_remotion_renderer["Remotion renderer<br/>subprocess bridge"]
end

subgraph group_remotion["Remotion composer"]
  node_root["Composition registry<br/>Remotion root<br/>[Root.tsx]"]
  node_cinematic["Cinematic renderer<br/>scene renderer"]
  node_components["Visual primitives<br/>React components"]
  node_remotion_project["Remotion runtime<br/>Node project<br/>[package.json]"]
end

subgraph group_external["Providers &amp; local tools"]
  node_providers{{"Cloud providers<br/>external APIs"}}
  node_media_tools{{"Media tooling<br/>local dependencies"}}
end

node_output["Rendered MP4<br/>output artifact"]

node_app -->|"topic"| node_pipeline
node_config -->|"settings"| node_pipeline
node_pipeline -->|"generate narrative"| node_script
node_script -->|"script"| node_visual_queries
node_pipeline -->|"script"| node_audio
node_config -.->|"LLM selection"| node_script
node_script -->|"LLM request"| node_providers
node_audio -.->|"local option"| node_edgetts
node_audio -.->|"cloud option"| node_elevenlabs
node_elevenlabs -->|"narration API"| node_providers
node_audio -->|"narration audio"| node_captions
node_captions -.->|"local option"| node_whisper
node_captions -.->|"cloud option"| node_deepgram
node_deepgram -->|"transcription API"| node_providers
node_visual_queries -->|"visual prompts"| node_background_video
node_background_video -.->|"generated-video option"| node_muapi_client
node_background_video -->|"Pexels stock footage"| node_providers
node_muapi_client -->|"MuAPI models"| node_providers
node_pipeline -->|"script, media, captions"| node_render_engine
node_render_engine -->|"render job"| node_remotion_renderer
node_remotion_renderer -->|"Node subprocess"| node_remotion_project
node_remotion_project -->|"loads compositions"| node_root
node_root -->|"registers"| node_cinematic
node_cinematic -->|"uses"| node_components
node_remotion_renderer -->|"writes MP4"| node_output
node_render_engine -->|"media processing"| node_media_tools

click node_app "https://github.com/samuraigpt/text-to-video-ai/blob/main/app.py"
click node_config "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/config.py"
click node_pipeline "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/pipeline_manager.py"
click node_script "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/script/script_generator.py"
click node_visual_queries "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/video/video_search_query_generator.py"
click node_audio "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/audio/audio_generator.py"
click node_edgetts "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/tts/edgetts_tts.py"
click node_elevenlabs "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/tts/elevenlabs_tts.py"
click node_captions "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/captions/timed_captions_generator.py"
click node_whisper "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/stt/whisper_stt.py"
click node_deepgram "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/stt/deepgram_stt.py"
click node_background_video "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/video/background_video_generator.py"
click node_muapi_client "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/muapi_client.py"
click node_render_engine "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/render/render_engine.py"
click node_remotion_renderer "https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/render/remotion_renderer.py"
click node_root "https://github.com/samuraigpt/text-to-video-ai/blob/main/remotion-composer/src/Root.tsx"
click node_cinematic "https://github.com/samuraigpt/text-to-video-ai/blob/main/remotion-composer/src/CinematicRenderer.tsx"
click node_remotion_project "https://github.com/samuraigpt/text-to-video-ai/blob/main/remotion-composer/package.json"

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_config,node_pipeline,node_script,node_visual_queries,node_audio,node_edgetts,node_elevenlabs,node_captions,node_whisper,node_deepgram,node_background_video,node_muapi_client,node_render_engine,node_remotion_renderer toneBlue
class node_root,node_cinematic,node_components,node_remotion_project toneAmber
class node_providers,node_media_tools toneMint
class node_output toneNeutral
```

## Components

### Python pipeline

CLI orchestration and AI/media preparation.

- [CLI entry point](https://github.com/samuraigpt/text-to-video-ai/blob/main/app.py): Python CLI · Accepts a topic and starts a video job. · `app.py`
- [Runtime config](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/config.py): configuration · Centralizes credentials and provider selection. · `utility/config.py`
- [Pipeline manager](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/pipeline_manager.py): orchestrator · Coordinates script, audio, visuals, captions, and rendering. · `utility/pipeline_manager.py`
- [Script generator](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/script/script_generator.py): LLM stage · `utility/script/script_generator.py`
- [Visual query generator](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/video/video_search_query_generator.py): planning stage · Separates visual retrieval prompts from narrative generation. · `utility/video/video_search_query_generator.py`
- [Audio generator](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/audio/audio_generator.py): TTS abstraction · Selects the configured narration provider. · `utility/audio/audio_generator.py`
- [EdgeTTS adapter](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/tts/edgetts_tts.py): local TTS · `utility/tts/edgetts_tts.py`
- [ElevenLabs adapter](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/tts/elevenlabs_tts.py): TTS provider adapter · `utility/tts/elevenlabs_tts.py`
- [Timed captions generator](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/captions/timed_captions_generator.py): caption timeline stage · Transcribes narration into synchronized captions. · `utility/captions/timed_captions_generator.py`
- [Whisper adapter](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/stt/whisper_stt.py): local STT · `utility/stt/whisper_stt.py`
- [Deepgram adapter](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/stt/deepgram_stt.py): STT provider adapter · `utility/stt/deepgram_stt.py`
- [Background video generator](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/video/background_video_generator.py): visual media stage · Acquires stock footage or generated video segments. · `utility/video/background_video_generator.py`
- [MuAPI client](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/muapi_client.py): video API adapter · Isolates text-to-video API interaction. · `utility/muapi_client.py`
- [Render engine](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/render/render_engine.py): render coordinator · `utility/render/render_engine.py`
- [Remotion renderer](https://github.com/samuraigpt/text-to-video-ai/blob/main/utility/render/remotion_renderer.py): subprocess bridge · Invokes the Node/Remotion composition runtime. · `utility/render/remotion_renderer.py`

### Remotion composer

Node/TypeScript video composition runtime.

- [Composition registry](https://github.com/samuraigpt/text-to-video-ai/blob/main/remotion-composer/src/Root.tsx): Remotion root · `remotion-composer/src/Root.tsx`
- [Cinematic renderer](https://github.com/samuraigpt/text-to-video-ai/blob/main/remotion-composer/src/CinematicRenderer.tsx): scene renderer · Builds cinematic scenes from prepared media and timeline props. · `remotion-composer/src/CinematicRenderer.tsx`
- **Visual primitives**: React components · Captions, title cards, charts, callouts, overlays, and scene elements.
- [Remotion runtime](https://github.com/samuraigpt/text-to-video-ai/blob/main/remotion-composer/package.json): Node project · `remotion-composer/package.json`

### Providers & local tools

Selectable services and required media tooling.

- **Cloud providers**: external APIs · LLM, Pexels, MuAPI, ElevenLabs, and Deepgram services.
- **Media tooling**: local dependencies · FFmpeg and ImageMagick process local media.

### Other components

- **Rendered MP4**: output artifact · Final local video composition.

## Connections

- CLI entry point → Pipeline manager: topic
- Runtime config → Pipeline manager: settings
- Pipeline manager → Script generator: generate narrative
- Script generator → Visual query generator: script
- Pipeline manager → Audio generator: script
- Runtime config → Script generator: LLM selection
- Script generator → Cloud providers: LLM request
- Audio generator → EdgeTTS adapter: local option
- Audio generator → ElevenLabs adapter: cloud option
- ElevenLabs adapter → Cloud providers: narration API
- Audio generator → Timed captions generator: narration audio
- Timed captions generator → Whisper adapter: local option
- Timed captions generator → Deepgram adapter: cloud option
- Deepgram adapter → Cloud providers: transcription API
- Visual query generator → Background video generator: visual prompts
- Background video generator → MuAPI client: generated-video option
- Background video generator → Cloud providers: Pexels stock footage
- MuAPI client → Cloud providers: MuAPI models
- Pipeline manager → Render engine: script, media, captions
- Render engine → Remotion renderer: render job
- Remotion renderer → Remotion runtime: Node subprocess
- Remotion runtime → Composition registry: loads compositions
- Composition registry → Cinematic renderer: registers
- Cinematic renderer → Visual primitives: uses
- Remotion renderer → Rendered MP4: writes MP4
- Render engine → Media tooling: media processing
