# davide97l/ai-video-generator architecture

> Architecture diagram of the GitHub repository davide97l/ai-video-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/davide97l/ai-video-generator
- Repository: https://github.com/davide97l/ai-video-generator

## Overview

##### Project type and purpose
- From the README and file tree, this is a specialized *flow-based AI video generation agent* with an auxiliary *voice-cloning service*.
- It is not a traditional monolithic web app but a *pipeline of small “functions”* (micro-tasks) that get orchestrated into end-to-end video creation and optional social-media upload.
- The voice-clone module is a mini-microservice (with its own REST API for training and inference).

##### File structure
- Top-level:
- agent-video-generator/functions → ≈30 Python scripts, each implements one step in the flow (script gen, image gen, music gen, speech gen, captioning, composition, upload).
- voice_clone/ → two parts:
– functions/ → scripts to prepare and train a voice-cloning model
– voice_clone_api/ → REST API (infer_api.py, train_api.py) and test clients
- Configuration and orchestration appear to live on Mindsflow.ai, which calls these functions in sequence.

##### Extract architecture hints from the README
- The “Flow” section shows a *flow-based programming* model: each function is a node in a directed graph.
- External dependencies:
- OpenAI GPT-4 for script generation
- Replicate SDXL for images
- Replicate MusicGen for music
- Azure TTS for narration
- ffmpeg / MoviePy / OpenCV for video processing
- AWS S3 for interim storage and upload
- Social-media APIs (YouTube or Instagram) for final posting

##### Elements
- Clear labels on each function or service (use file names like GenerateVideoScript, PromptImagesToVideo, etc.).
- Sequencing of pipeline steps
- Dependencies on external AI services
- Storage read/write flows
- Rectangles for functions
- Clouds for external APIs

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Pipeline Functions
    subgraph "Pipeline Functions"
        FO["Flow Orchestrator"]:::orchestrator
        script["GenerateVideoScript"]:::function
        images["PromptImagesToVideo"]:::function
        music["MusicGeneration"]:::function
        speech["textToSpeech"]:::function
        capFF["AddCaptionsToVideoFFMPEG"]:::function
        capMP["AddCaptionsToVideoMoviepy"]:::function
        capCV["AddCaptionsToVideoOpenCV"]:::function
        comp1["addAudioSegmentsToVideo"]:::function
        comp2["addSoundToVideo"]:::function
        comp3["addTextToImage"]:::function
        uploadS3["UploadResultZipS3"]:::function
        uploadYT["uploadYoutubeVideo"]:::function
    end

    %% Storage
    subgraph "Storage"
        S3[(AWS S3)]:::storage
    end

    %% External APIs
    subgraph "External APIs"
        GPT4((GPT-4)):::external
        SDXL((Replicate SDXL)):::external
        MusicGen((Replicate MusicGen)):::external
        AzureTTS((Azure TTS)):::external
        Social((YouTube API)):::external
    end

    %% Voice-Clone Microservice
    subgraph "Voice-Clone Microservice"
        subgraph "Training Functions"
            genV["generate_voice_vits"]:::function
            cloneV["clone_voice_vits"]:::function
            setEpoch["set_epoch_in_json_config"]:::function
        end
        subgraph "REST API"
            inferAPI["infer_api"]:::function
            trainAPI["train_api"]:::function
            apiFuncs["functions"]:::function
            apiInfer["infer"]:::function
            apiTrain["train"]:::function
        end
        subgraph "Test Clients"
            client1["run_make_prompt"]:::function
            client2["run_voice_clone"]:::function
        end
    end

    %% Sequence
    FO -->|triggers| script
    script -->|"uses"| GPT4
    script -->|writes| S3

    FO --> images
    images -->|"uses"| SDXL
    images -->|writes| S3

    FO --> music
    music -->|"uses"| MusicGen
    music -->|writes| S3

    FO --> speech
    speech -->|"uses"| AzureTTS
    speech -->|writes| S3

    FO --> capFF
    FO --> capMP
    FO --> capCV
    capFF -->|writes| S3
    capMP -->|writes| S3
    capCV -->|writes| S3

    FO --> comp1
    FO --> comp2
    FO --> comp3
    comp1 -->|writes| S3
    comp2 -->|writes| S3
    comp3 -->|writes| S3

    FO --> uploadS3
    uploadS3 -->|writes zip| S3

    FO --> uploadYT
    uploadYT -->|"posts"| Social

    %% Optional Voice-Clone Branch
    speech -.-> inferAPI
    inferAPI --> genV
    genV --> cloneV
    cloneV --> setEpoch
    setEpoch --> apiFuncs
    apiFuncs --> inferAPI
    apiFuncs --> trainAPI
    inferAPI --> apiInfer
    trainAPI --> apiTrain
    apiInfer --> client1
    apiTrain --> client2

    %% Click Events
    click FO "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/MindsflowAgent.py"
    click script "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/generateVideoScript.py"
    click images "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/PromptImagesToVideo.py"
    click music "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/MusicGeneration.py"
    click speech "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/textToSpeech.py"
    click capFF "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/AddCaptionsToVideoFFMPEG.py"
    click capMP "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/AddCaptionsToVideoMoviepy.py"
    click capCV "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/AddCaptionsToVideoOpenCV.py"
    click comp1 "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/addAudioSegmentsToVideo.py"
    click comp2 "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/addSoundToVideo.py"
    click comp3 "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/addTextToImage.py"
    click uploadS3 "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/UploadResultZipS3.py"
    click uploadYT "https://github.com/davide97l/ai-video-generator/blob/main/agent-video-generator/functions/uploadYoutubeVideo.py"
    click genV "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/functions/generate_voice_vits.py"
    click cloneV "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/functions/clone_voice_vits.py"
    click setEpoch "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/functions/set_epoch_in_json_config.py"
    click inferAPI "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/voice_clone_api/infer_api.py"
    click trainAPI "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/voice_clone_api/train_api.py"
    click apiFuncs "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/voice_clone_api/functions.py"
    click apiInfer "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/voice_clone_api/infer.py"
    click apiTrain "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/voice_clone_api/train.py"
    click client1 "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/voice_clone_api/test_api/run_make_prompt.py"
    click client2 "https://github.com/davide97l/ai-video-generator/blob/main/voice_clone/voice_clone_api/test_api/run_voice_clone.py"

    %% Styles
    classDef function fill:#E3F2FD,stroke:#2196F3,color:#0D47A1
    classDef orchestrator fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef storage fill:#E8F5E9,stroke:#388E3C,color:#1B5E20
    classDef external fill:#F3E5F5,stroke:#8E24AA,color:#4A148C
    classDef optional stroke-dasharray: 5 5,color:#757575;
```
