# atulguptag/video-subtitle-generator architecture

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

- Interactive diagram: https://gitdiagram.com/atulguptag/video-subtitle-generator
- Repository: https://github.com/atulguptag/video-subtitle-generator

## Overview

##### Main components
- Frontend: The React application (located in the “frontend” directory) manages user interactions, video uploads, subtitle customization, and communicates with the backend APIs.
- Backend API Server: The Django project (under “backend/subtitle_generator”) acts as a central point for processing API requests. Within this, you have separate Django apps:
– Authentication (user registration, login, social authentication via Google/Facebook)
– Videos (video uploads and processing tasks)
– Subtitles (subtitle generation, styling, export options)
- Asynchronous Task Worker: The Celery worker (configured in backend/subtitle_generator/celery.py) handles long-running tasks such as generating subtitles in the background. This interacts with RabbitMQ as the message broker.
- Database: Although default SQLite may be used, PostgreSQL is preferred. This stores user data, video metadata, subtitles, and application configurations.
- External Services: Include the social authentication providers (OAuth via Google and Facebook) and RabbitMQ (for the task queue).

##### Establish interactions and data flow
- The frontend sends API requests (using Axios) to the Django backend’s endpoints such as /api for authentication, video submissions, and subtitle fetching.
- The backend receives and processes these requests, using its MVC (albeit Django’s MTV pattern) structure, where views handle business logic and models manage data.
- Upon submitting a video for subtitle generation, the backend enqueues tasks for the Celery worker (which communicates via RabbitMQ). The worker processes and returns results asynchronously.
- The Django backend then updates the database with processed subtitle data. The frontend periodically polls or waits for notification of completion.

##### Important architectural patterns and technologies
- Separation of concerns: Frontend and backend are clearly separated. Each Django app (authentication, subtitles, videos) is modular, aiding maintainability.
- Asynchronous Processing: Use of Celery (with RabbitMQ) introduces task queuing for processing-intensive operations like AI-based transcription.
- API-Driven Communication: The React frontend interacts with the backend via REST API endpoints.
- Security and Authentication: JWT authentication and social OAuth integration are key to user identity management.

- Clear and distinct labels for every component (e.g., “React Frontend”, “Django Authentication API”, “Celery Worker”, “PostgreSQL Database”, “RabbitMQ Message Broker”).

##### Final recommended approach
- Expand the backend layer to detail each Django app (Authentication, Subtitles, Videos) as individual components under the main Django project.
- Ancillary services (Database, RabbitMQ, and Celery) and indicate how they integrate with the main backend logic.
- Annotations that call out relevant technologies: React with TypeScript, Django REST Framework, PostgreSQL (or SQLite by default), RabbitMQ, and Celery.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["React Frontend (User Interface)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        DPS["Django Project (subtitle_generator)"]:::backendConf
        Auth["Django Authentication API"]:::backendApp
        Videos["Django Videos API"]:::backendApp
        Subs["Django Subtitles API"]:::backendApp
    end

    %% External and Ancillary Services
    Database["PostgreSQL Database"]:::database
    RabbitMQ["RabbitMQ Message Broker"]:::externalService
    Celery["Celery Worker"]:::worker
    Google["Google OAuth"]:::externalService
    Facebook["Facebook OAuth"]:::externalService

    %% Interactions and Data Flow
    FE -->|"HTTP_API"| DPS
    DPS -->|"RoutesTo|Auth"| Auth
    DPS -->|"RoutesTo|Videos"| Videos
    DPS -->|"RoutesTo|Subs"| Subs
    DPS -->|"CRUD"| Database
    Auth -->|"OAuth"| Google
    Auth -->|"OAuth"| Facebook
    Videos -->|"EnqueueTask"| RabbitMQ
    RabbitMQ -->|"DispatchTask"| Celery
    Celery -->|"ReturnResult"| Subs

    %% Click Events for Component Mapping
    click FE "https://github.com/atulguptag/video-subtitle-generator/tree/master/frontend/"
    click DPS "https://github.com/atulguptag/video-subtitle-generator/tree/master/backend/subtitle_generator/"
    click Auth "https://github.com/atulguptag/video-subtitle-generator/tree/master/backend/authentication/"
    click Videos "https://github.com/atulguptag/video-subtitle-generator/tree/master/backend/videos/"
    click Subs "https://github.com/atulguptag/video-subtitle-generator/tree/master/backend/subtitles/"
    click Celery "https://github.com/atulguptag/video-subtitle-generator/blob/master/backend/subtitle_generator/celery.py"

    %% Styles
    classDef frontend fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef backendConf fill:#f9d57a,stroke:#333,stroke-width:2px;
    classDef backendApp fill:#f4a460,stroke:#333,stroke-width:2px;
    classDef database fill:#add8e6,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef worker fill:#ffcccb,stroke:#333,stroke-width:2px,stroke-dasharray: 2 2;
    classDef externalService fill:#d3d3d3,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
```
