# eliasprost/reels-maker architecture

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

- Interactive diagram: https://gitdiagram.com/eliasprost/reels-maker
- Repository: https://github.com/eliasprost/reels-maker

## Overview

##### Main Components
- User Input & Environment: The process starts with a user running “make start” (or the app via “make app” for the Streamlit version) and providing a Reddit post URL, with environment variables stored (and loaded via src/config.py) to configure credentials and video parameters.
- Core Processing / Pipeline: Central to the project is the pipeline (found in src/pipelines/pipelines.py) that orchestrates the video generation process. This module likely calls in different submodules to fetch data, process media content, and compose the final video.
- Reddit Integration Module: Under src/utils/reddit, these modules (post.py and screenshot.py) handle interactions with the Reddit API and capture media/screenshot contents.
- Media Handling Utilities: Located in src/utils/media, these modules (audio.py, video.py) deal with processing and manipulating media (audio and video files).
- Additional Utilities: Other support utilities like src/utils/path.py (for file path management) and modules for text-to-speech (src/utils/tts.py) and speech-to-text (src/utils/stt.py) support the media generation workflow.
- Configuration & Data Resources: The data directory contains JSON configuration files for language settings, cookies (for light/dark mode), and background media (background_audios.json, background_videos.json); the .env file (and src/config.py) is used to load runtime configurations such as Reddit API credentials and video specs.
- Scripts and Build/Deployment Files: The scripts directory (for tasks like downloading background media with download_background_media.py) and Makefile (offering commands for installation, downloading media, and running the application) support operational needs.

##### Relationships and Interactions
- Environment Setup: The application reads environment variables via the configuration (src/config.py) so that modules have access to API credentials and video settings.
- Reddit API Module: The utility modules under src/utils/reddit fetch the post content and screenshots.
- Pipeline Orchestration: The processing in src/pipelines calls on the Reddit module and then leverages the media utilities (audio.py and video.py) to combine fetched contents with background media defined in the data folder.
- Output and Storage: The final video is saved (typically within the assets directory), and examples of generated reels are available in assets/examples.
- Optional Interface: There’s an alternate Streamlit application (src/app.py) to provide a UI layer, if needed.

##### Architectural Patterns and Technologies
- Modular Design: The project is organized into clearly separated modules (for pipelines, utilities, and configuration), which simplifies maintenance and enhancements.
- Pipelines: The use of a dedicated pipelines folder indicates an emphasis on chaining together discrete processing steps.
- Configuration-Driven: Reliance on environment variables and JSON configuration files underlines a design that cleanly separates configuration from code.
- Automation & Development Tools: The use of Makefile commands, pre-commit configs, and dependency management via Poetry represent best practices for project automation and collaboration.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Input Layer
    subgraph "User Input"
        CLI("CLI (Makefile)"):::interface
        streamlitApp("Streamlit App"):::interface
    end

    %% Configuration Layer
    subgraph "Configuration"
        config("Configuration (.env & src/config.py)"):::config
    end

    %% Core Application Layer
    subgraph "Core Application"
        mainRunner("Main Runner (src/main.py)"):::pipeline
        pipelineProc("Processing Pipeline (src/pipelines/pipelines.py)"):::pipeline
    end

    %% Reddit Integration Module
    subgraph "Reddit Integration"
        redditPost("Reddit Post Fetcher (src/utils/reddit/post.py)"):::reddit
        redditScreenshot("Screenshot Capture (src/utils/reddit/screenshot.py)"):::reddit
    end

    %% Media Handling Utilities
    subgraph "Media Utilities"
        audioProc("Audio Processing (src/utils/media/audio.py)"):::media
        videoProc("Video Processing (src/utils/media/video.py)"):::media
        ttsUtil("Text-to-Speech (src/utils/tts.py)"):::media
        sttUtil("Speech-to-Text (src/utils/stt.py)"):::media
        pathUtil("File Path Utility (src/utils/path.py)"):::media
    end

    %% Data and Configuration Resources
    subgraph "Data Resources"
        bgAudios("Background Audios (data/background_audios.json)"):::data
        bgVideos("Background Videos (data/background_videos.json)"):::data
        languages("Languages (data/languages.json)"):::data
        fileMapping("File Mapping (data/file_mapping.json)"):::data
        cookies("Cookies (data/cookies)"):::data
    end

    %% Scripts and Build/Deployment
    subgraph "Scripts & Deployment"
        downloadMedia("Download Media Script (scripts/download_background_media.py)"):::scripts
        buildFiles("Makefile & Pre-commit Configs"):::scripts
    end

    %% Output Layer
    subgraph "Output"
        assetsOut("Assets (assets)"):::output
    end

    %% Connections
    CLI -->|"triggers"| config
    streamlitApp -->|"triggers"| config

    config -->|"loads settings"| mainRunner
    mainRunner -->|"orchestrates"| pipelineProc

    pipelineProc -->|"fetches"| redditPost
    pipelineProc -->|"captures"| redditScreenshot
    pipelineProc -->|"processes"| audioProc
    pipelineProc -->|"processes"| videoProc
    pipelineProc -->|"utilizes"| ttsUtil
    pipelineProc -->|"utilizes"| sttUtil
    pipelineProc -->|"utilizes"| pathUtil

    audioProc ---|"uses"| bgAudios
    audioProc ---|"uses"| bgVideos
    videoProc ---|"uses"| bgAudios
    videoProc ---|"uses"| bgVideos

    bgAudios --- languages
    bgVideos --- fileMapping
    bgVideos --- cookies

    pipelineProc -->|"outputs final video"| assetsOut

    downloadMedia -->|"updates"| bgAudios
    downloadMedia -->|"updates"| bgVideos

    %% Click Events
    click streamlitApp "https://github.com/eliasprost/reels-maker/blob/main/src/app.py"
    click config "https://github.com/eliasprost/reels-maker/blob/main/src/config.py"
    click mainRunner "https://github.com/eliasprost/reels-maker/blob/main/src/main.py"
    click pipelineProc "https://github.com/eliasprost/reels-maker/blob/main/src/pipelines/pipelines.py"
    click redditPost "https://github.com/eliasprost/reels-maker/blob/main/src/utils/reddit/post.py"
    click redditScreenshot "https://github.com/eliasprost/reels-maker/blob/main/src/utils/reddit/screenshot.py"
    click audioProc "https://github.com/eliasprost/reels-maker/blob/main/src/utils/media/audio.py"
    click videoProc "https://github.com/eliasprost/reels-maker/blob/main/src/utils/media/video.py"
    click ttsUtil "https://github.com/eliasprost/reels-maker/blob/main/src/utils/tts.py"
    click sttUtil "https://github.com/eliasprost/reels-maker/blob/main/src/utils/stt.py"
    click pathUtil "https://github.com/eliasprost/reels-maker/blob/main/src/utils/path.py"
    click bgAudios "https://github.com/eliasprost/reels-maker/blob/main/data/background_audios.json"
    click bgVideos "https://github.com/eliasprost/reels-maker/blob/main/data/background_videos.json"
    click languages "https://github.com/eliasprost/reels-maker/blob/main/data/languages.json"
    click fileMapping "https://github.com/eliasprost/reels-maker/blob/main/data/file_mapping.json"
    click cookies "https://github.com/eliasprost/reels-maker/tree/main/data/cookies"
    click downloadMedia "https://github.com/eliasprost/reels-maker/blob/main/scripts/download_background_media.py"
    click assetsOut "https://github.com/eliasprost/reels-maker/tree/main/assets"

    %% Styles
    classDef interface fill:#a2d2ff,stroke:#000,stroke-width:2px;
    classDef config fill:#ffeeba,stroke:#000,stroke-width:2px;
    classDef pipeline fill:#c3f7d0,stroke:#000,stroke-width:2px;
    classDef reddit fill:#fef1d1,stroke:#000,stroke-width:2px;
    classDef media fill:#ffcccb,stroke:#000,stroke-width:2px;
    classDef data fill:#d0f0c0,stroke:#000,stroke-width:2px;
    classDef scripts fill:#e6ccff,stroke:#000,stroke-width:2px;
    classDef output fill:#d1d1f7,stroke:#000,stroke-width:2px;
```
