# elebumm/redditvideomakerbot architecture

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

- Interactive diagram: https://gitdiagram.com/elebumm/redditvideomakerbot
- Repository: https://github.com/elebumm/redditvideomakerbot

## Overview

##### Project type and purpose
- This is a command-line/desktop application (with an optional HTML-based GUI) that automates the creation of short videos from Reddit posts.
- It fetches Reddit content, synthesizes speech via multiple TTS providers, assembles audio with backgrounds, captures screenshots, and produces a final video.

##### File structure
- Top-level orchestrator:
- main.py – CLI entry point
- GUI.py – launches the HTML/Playwright-driven GUI
- Configuration and assets:
- utils/settings.py & .config.template.toml – user preferences and API secrets
- assets/, fonts/ – static assets and font resources
- GUI/ – HTML templates (index, layout, settings) and preloaded voice clips
- Core modules:
- reddit/ – subreddit.py for Reddit API integration
- TTS/ – engine_wrapper.py plus provider modules (aws_polly, GTTS, elevenlabs, pyttsx, TikTok, streamlabs_polly)
- video_creation/ – background.py, screenshot_downloader.py, voices.py, final_video.py for video assembly
- Utilities:
- utils/ai_methods.py, console.py, ffmpeg_install.py, play­wright.py, thumbnail.py, videos.py, cleanup.py, etc.
- Deployment/build:
- Dockerfile, build.sh, install.sh, run.sh/.bat

##### Readme insights
- Core workflow: fetch Reddit thread → configure voice/background → synthesize audio → render screenshots with Playwright → mix and compile video → output final MP4.
- No automatic upload; manual upload step remains.

##### Detail is critical
- Both synchronous (CLI call returns) and asynchronous operations (Playwright browser launch)
- Error-handling or cleanup via utils/cleanup if desired

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interface Layer
    subgraph "User Interface" 
        direction TB
        UI_CLI["CLI\n(main.py)"]:::ui
        UI_GUI["GUI Launcher\n(GUI.py + HTML Templates)"]:::ui
        GUI_TEMPLATES["HTML Templates & Preloaded Voices\n(GUI/)"]:::ui
    end

    %% Configuration Store
    CONFIG["Configuration Store\n(utils/settings.py & .config.template.toml)"]:::data

    %% Core Services
    subgraph "Core Services" 
        direction TB
        REDDIT["Reddit Integration\n(reddit/subreddit.py)"]:::core
        subgraph "TTS Layer"
            direction TB
            TTS_WRAPPER["TTS Orchestrator\n(TTS/engine_wrapper.py)"]:::core
            AWS_POLLY["AWS Polly\n(TTS/aws_polly.py)"]:::core
            GTTS["GTTS\n(TTS/GTTS.py)"]:::core
            ELEVENLABS["ElevenLabs\n(TTS/elevenlabs.py)"]:::core
            PYTTSX["pyttsx\n(TTS/pyttsx.py)"]:::core
            TIKTOK["TikTok\n(TTS/TikTok.py)"]:::core
            STREAMLABS["Streamlabs Polly\n(TTS/streamlabs_polly.py)"]:::core
        end
    end

    %% Asset Manager
    subgraph "Asset Manager"
        direction TB
        BACK_AUDIOS["Background Audio Manifests\n(utils/background_audios.json)"]:::data
        BACK_VIDEOS["Background Video Manifests\n(utils/background_videos.json)"]:::data
        ASSETS["Static Assets\n(assets/)"]:::data
        FONTS["Fonts\n(fonts/)"]:::data
    end

    %% Video Composition
    subgraph "Video Composition"
        direction TB
        BACKGROUND_MODULE["Background Selection\n(video_creation/background.py)"]:::core
        SCREENSHOT["Screenshot Capture\n(video_creation/screenshot_downloader.py)"]:::core
        VOICES_ASSEMBLY["Voice Track Assembly\n(video_creation/voices.py)"]:::core
        FINAL_VIDEO["Final Rendering\n(video_creation/final_video.py)"]:::core
        COOKIE_DARK["Cookie (Dark)\n(video_creation/data/cookie-dark-mode.json)"]:::data
        COOKIE_LIGHT["Cookie (Light)\n(video_creation/data/cookie-light-mode.json)"]:::data
    end

    %% Utilities
    subgraph "Utilities"
        direction TB
        CONSOLE["Console Logging\n(utils/console.py)"]:::util
        FFMPEG_INSTALL["FFmpeg Installer\n(utils/ffmpeg_install.py)"]:::util
        CLEANUP["Cleanup Tasks\n(utils/cleanup.py)"]:::util
        THUMBNAIL["Thumbnail Generation\n(utils/thumbnail.py)"]:::util
        VIDEOS_UTIL["Video Helpers\n(utils/videos.py)"]:::util
        PLAYWRIGHT_UTIL["Playwright Wrapper\n(utils/playwright.py)"]:::util
        AI_METHODS["AI Text & Parsing\n(utils/ai_methods.py)"]:::util
        POSTPARSER["Post Text Parser\n(utils/posttextparser.py)"]:::util
        VOICE_UTIL["Voice File Utils\n(utils/voice.py)"]:::util
        VERSION["Version Info\n(utils/version.py)"]:::util
    end

    %% External Services
    subgraph "External Services"
        direction TB
        EX_REDDIT["Reddit API"]:::external
        EX_TTS["TTS Provider Endpoints"]:::external
        PLAYWRIGHT_ENGINE["Playwright Browser Engine"]:::external
    end

    %% Data Flow
    UI_CLI -->|"reads/writes settings"| CONFIG
    UI_GUI -->|"reads/writes settings"| CONFIG
    UI_CLI -->|"fetch options"| REDDIT
    UI_GUI -->|"fetch options"| REDDIT
    REDDIT -->|"Fetch Posts"| EX_REDDIT
    EX_REDDIT -->|"Return Data"| REDDIT
    REDDIT -->|"Post Data"| TTS_WRAPPER
    TTS_WRAPPER -->|"Synthesize Audio"| AWS_POLLY
    TTS_WRAPPER -->|"Synthesize Audio"| GTTS
    TTS_WRAPPER -->|"Synthesize Audio"| ELEVENLABS
    TTS_WRAPPER -->|"Synthesize Audio"| PYTTSX
    TTS_WRAPPER -->|"Synthesize Audio"| TIKTOK
    TTS_WRAPPER -->|"Synthesize Audio"| STREAMLABS
    AWS_POLLY -->|"Audio Files"| TTS_WRAPPER
    GTTS -->|"Audio Files"| TTS_WRAPPER
    ELEVENLABS -->|"Audio Files"| TTS_WRAPPER
    PYTTSX -->|"Audio Files"| TTS_WRAPPER
    TIKTOK -->|"Audio Files"| TTS_WRAPPER
    STREAMLABS -->|"Audio Files"| TTS_WRAPPER
    TTS_WRAPPER -->|"Audio + Assets"| BACKGROUND_MODULE
    BACKGROUND_MODULE -->|"Add Backgrounds"| ASSETS
    BACKGROUND_MODULE -->|"Fonts"| FONTS
    BACKGROUND_MODULE -->|"Audio Manifests"| BACK_AUDIOS
    BACKGROUND_MODULE -->|"Video Manifests"| BACK_VIDEOS
    BACKGROUND_MODULE -->|"Pass to Composition"| SCREENSHOT
    SCREENSHOT -->|"Use Playwright"| PLAYWRIGHT_ENGINE
    SCREENSHOT -->|"Cookies"| COOKIE_DARK
    SCREENSHOT -->|"Cookies"| COOKIE_LIGHT
    SCREENSHOT -->|"Screenshots"| VOICES_ASSEMBLY
    VOICES_ASSEMBLY -->|"Merge Tracks"| FINAL_VIDEO
    FINAL_VIDEO -->|"Invoke FFmpeg"| FFMPEG_INSTALL
    FINAL_VIDEO -->|"Output MP4"| UI_CLI
    FINAL_VIDEO -->|"Output MP4"| UI_GUI
    UI_GUI -->|"Display Progress"| CONSOLE
    UI_CLI -->|"Logs"| CONSOLE
    CLEANUP -->|"Cleanup Files"| FINAL_VIDEO
    THUMBNAIL -->|"Generate Thumbnail"| FINAL_VIDEO

    %% Utilities Integration
    FINAL_VIDEO --> VIDEOS_UTIL
    SCREENSHOT --> PLAYWRIGHT_UTIL
    REDDIT --> AI_METHODS
    REDDIT --> POSTPARSER
    TTS_WRAPPER --> VOICE_UTIL
    UI_CLI --> VERSION

    %% Click Events
    click UI_CLI "https://github.com/elebumm/redditvideomakerbot/blob/master/main.py"
    click UI_GUI "https://github.com/elebumm/redditvideomakerbot/blob/master/GUI.py"
    click GUI_TEMPLATES "https://github.com/elebumm/redditvideomakerbot/tree/master/GUI/"
    click CONFIG "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/settings.py"
    click REDDIT "https://github.com/elebumm/redditvideomakerbot/blob/master/reddit/subreddit.py"
    click TTS_WRAPPER "https://github.com/elebumm/redditvideomakerbot/blob/master/TTS/engine_wrapper.py"
    click AWS_POLLY "https://github.com/elebumm/redditvideomakerbot/blob/master/TTS/aws_polly.py"
    click GTTS "https://github.com/elebumm/redditvideomakerbot/blob/master/TTS/GTTS.py"
    click ELEVENLABS "https://github.com/elebumm/redditvideomakerbot/blob/master/TTS/elevenlabs.py"
    click PYTTSX "https://github.com/elebumm/redditvideomakerbot/blob/master/TTS/pyttsx.py"
    click TIKTOK "https://github.com/elebumm/redditvideomakerbot/blob/master/TTS/TikTok.py"
    click STREAMLABS "https://github.com/elebumm/redditvideomakerbot/blob/master/TTS/streamlabs_polly.py"
    click BACK_AUDIOS "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/background_audios.json"
    click BACK_VIDEOS "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/background_videos.json"
    click ASSETS "https://github.com/elebumm/redditvideomakerbot/tree/master/assets/"
    click FONTS "https://github.com/elebumm/redditvideomakerbot/tree/master/fonts/"
    click BACKGROUND_MODULE "https://github.com/elebumm/redditvideomakerbot/blob/master/video_creation/background.py"
    click SCREENSHOT "https://github.com/elebumm/redditvideomakerbot/blob/master/video_creation/screenshot_downloader.py"
    click VOICES_ASSEMBLY "https://github.com/elebumm/redditvideomakerbot/blob/master/video_creation/voices.py"
    click FINAL_VIDEO "https://github.com/elebumm/redditvideomakerbot/blob/master/video_creation/final_video.py"
    click COOKIE_DARK "https://github.com/elebumm/redditvideomakerbot/blob/master/video_creation/data/cookie-dark-mode.json"
    click COOKIE_LIGHT "https://github.com/elebumm/redditvideomakerbot/blob/master/video_creation/data/cookie-light-mode.json"
    click CONSOLE "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/console.py"
    click FFMPEG_INSTALL "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/ffmpeg_install.py"
    click CLEANUP "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/cleanup.py"
    click THUMBNAIL "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/thumbnail.py"
    click VIDEOS_UTIL "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/videos.py"
    click PLAYWRIGHT_UTIL "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/playwright.py"
    click AI_METHODS "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/ai_methods.py"
    click POSTPARSER "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/posttextparser.py"
    click VOICE_UTIL "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/voice.py"
    click VERSION "https://github.com/elebumm/redditvideomakerbot/blob/master/utils/version.py"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#3399ff,color:#000
    classDef core fill:#d4edda,stroke:#28a745,color:#000
    classDef data fill:#fff3cd,stroke:#ffc107,color:#000
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#000
    classDef util fill:#f8f9fa,stroke:#adb5bd,color:#000
```
