# sokosam/viddat architecture

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

- Interactive diagram: https://gitdiagram.com/sokosam/viddat
- Repository: https://github.com/sokosam/viddat

## Overview

##### Main Components

A. Frontend Layer:
- Flask web application (in /app directory)
- Static assets (CSS, audio files)
- Template rendering system (Jinja2 templates)

B. Authentication System:
- Auth.py as a separate component
- User management flow
- Email verification system (evident from email-related templates)

C. Worker Service:
- Video generation worker (/worker directory)
- Polly integration for text-to-speech
- Background music processing
- Stock footage handling
- Thumbnail generation

D. Nginx Layer:
- Reverse proxy configuration
- Static file serving
- Load balancing

##### Component Relationships

- Client Browser → Nginx
- Nginx → Flask Application
- Flask Application → Worker Service
- Worker Service → External Services (AWS Polly)

##### Specific Implementation Details

- Blue rectangles for containers (Flask app, Worker, Nginx)
- Green diamonds for storage components (stock footage, bg music)
- Yellow hexagons for external services (AWS Polly)
- Purple rectangles for authentication components

Following flows:
- User requests → Nginx → Flask App
- Video generation requests → Worker Service
- Text-to-speech requests → Polly Service
- Media file handling between components

##### Key Architectural Elements

Architectural patterns:
- Microservices architecture (separate app and worker services)
- Container orchestration (Docker Compose)
- MVC pattern in Flask app (models.py, views.py)
- Asynchronous video processing

##### Technical Stack Indicators

Technology labels:
- Python/Flask
- Nginx
- Docker
- AWS Polly
- Jinja2 Templates

**[Client Browser] → [Nginx Container]**
- ↓
- [Flask App Container] ← → [Authentication]
- ↓                      ↓
- [Worker Container] → [AWS Polly]
- ↓
**[Media Storage (Stock/Music)]**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "Nginx Layer"
        Nginx["Nginx Server"]:::nginx
    end

    subgraph "Flask Application"
        FlaskApp["Flask App"]:::flask
        Views["Views"]:::flask
        Models["Models"]:::flask
        ClientInterface["Client Interface"]:::flask
        Auth["Authentication"]:::auth
        
        subgraph "Frontend Assets"
            Static["Static Files"]:::static
            Templates["Templates"]:::static
            Styles["CSS Styles"]:::static
            Audio["Audio Assets"]:::static
        end
    end

    subgraph "Worker Service"
        Worker["Main Worker"]:::worker
        VideoGen["Video Generator"]:::worker
        ThumbnailGen["Thumbnail Generator"]:::worker
        TextProcess["Text Processor"]:::worker
        ErrorHandler["Error Handler"]:::worker
        
        subgraph "Media Assets"
            BGMusic["Background Music"]:::media
            StockFootage["Stock Footage"]:::media
            Fonts["Fonts"]:::media
            Thumbnails["Thumbnails"]:::media
        end
        
        subgraph "AWS Integration"
            Polly["Polly Service"]:::aws
            VTTProcess["VTT Processor"]:::aws
        end
    end

    Browser --> Nginx
    Nginx --> FlaskApp
    FlaskApp --> Views
    FlaskApp --> Models
    FlaskApp --> ClientInterface
    FlaskApp --> Auth
    FlaskApp --> Static
    FlaskApp --> Templates
    
    FlaskApp --> Worker
    Worker --> VideoGen
    Worker --> ThumbnailGen
    Worker --> TextProcess
    Worker --> ErrorHandler
    Worker --> Polly
    Polly --> VTTProcess
    
    VideoGen --> BGMusic
    VideoGen --> StockFootage
    VideoGen --> Fonts
    ThumbnailGen --> Thumbnails

    %% Click events
    click FlaskApp "https://github.com/sokosam/viddat/blob/main/app/__init__.py"
    click Views "https://github.com/sokosam/viddat/blob/main/app/views.py"
    click Models "https://github.com/sokosam/viddat/blob/main/app/models.py"
    click ClientInterface "https://github.com/sokosam/viddat/blob/main/app/client_page.py"
    click Auth "https://github.com/sokosam/viddat/blob/main/app/auth.py"
    click Static "https://github.com/sokosam/viddat/tree/main/app/static/"
    click Styles "https://github.com/sokosam/viddat/tree/main/app/static/styles/"
    click Templates "https://github.com/sokosam/viddat/tree/main/app/templates/"
    click Audio "https://github.com/sokosam/viddat/blob/main/app/static/on_complete.wav"
    click Worker "https://github.com/sokosam/viddat/blob/main/worker/worker.py"
    click VideoGen "https://github.com/sokosam/viddat/blob/main/worker/video_generator.py"
    click ThumbnailGen "https://github.com/sokosam/viddat/blob/main/worker/title_page_gen.py"
    click TextProcess "https://github.com/sokosam/viddat/blob/main/worker/text_scripts.py"
    click ErrorHandler "https://github.com/sokosam/viddat/blob/main/worker/viddat_exceptions.py"
    click Polly "https://github.com/sokosam/viddat/blob/main/worker/pollyFiles/polly.py"
    click VTTProcess "https://github.com/sokosam/viddat/blob/main/worker/pollyFiles/polly_vtt.py"
    click BGMusic "https://github.com/sokosam/viddat/tree/main/worker/bg_music/"
    click StockFootage "https://github.com/sokosam/viddat/tree/main/worker/stock_footage/"
    click Fonts "https://github.com/sokosam/viddat/tree/main/worker/fonts/"
    click Thumbnails "https://github.com/sokosam/viddat/tree/main/worker/thumbnail_static/"
    click Nginx "https://github.com/sokosam/viddat/blob/main/nginx/nginx.conf"

    %% Styling
    classDef flask fill:#3776AB,color:white
    classDef nginx fill:#009639,color:white
    classDef static fill:#FFD700,color:black
    classDef auth fill:#9932CC,color:white
    classDef worker fill:#FF6B6B,color:white
    classDef media fill:#4CAF50,color:white
    classDef aws fill:#FF9900,color:black

    %% Legend
    subgraph Legend
        L1["Flask Components"]:::flask
        L2["Nginx Server"]:::nginx
        L3["Static Assets"]:::static
        L4["Authentication"]:::auth
        L5["Worker Service"]:::worker
        L6["Media Assets"]:::media
        L7["AWS Services"]:::aws
    end
```
