# detopall/brainrottok architecture

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

- Interactive diagram: https://gitdiagram.com/detopall/brainrottok
- Repository: https://github.com/detopall/brainrottok

## Overview

##### Project Type and Purpose
- This is a full-stack application that allows users to generate TikTok-style videos with subtitles. The project consists of a client (built with React, TypeScript, and Tailwind CSS) and a server (built in Python using FastAPI and various multimedia processing utilities such as FFmpeg, Whisper from OpenAI, and ImageMagick).
- The README clearly explains that the system supports multiple video types (Basic, Subway Surfers, Minecraft Reddit, Rumble Video) by handling video uploads, subtitle generation, and text-to-speech processing.

##### File Structure
- Top-Level Separation: There are distinct directories for the client ("brain-rot-tok-client") and the server ("brain-rot-tok-server"). This separation signals clear boundaries between frontend and backend concerns.
- Client (Frontend):
- Contains typical assets like HTML, CSS, and images.
- The "src" folder holds components, hooks, layouts, and pages that likely adhere to a modular component-based architecture.
- Configuration files such as vite.config.ts, tailwind.config.js, and TypeScript configs indicate a modern web development stack.
- Server (Backend):
- Contains endpoints with Python scripts that implement various video generation functionalities, and utilities for tasks like file creation, subtitle generation, text-to-speech, and audio/video conversion.
- There is also a main server script (server.py) and additional helper scripts.
- Project-level files (Dockerfile, docker-compose.yaml, run.sh) indicate containerization and orchestration for deployment.

a. Main Components:
- Frontend (BrainRotTok Client): Represented as a module built with React/TypeScript. Include subcomponents, pages, and layout modules.
- Backend (BrainRotTok Server): A Python-based service, likely built with FastAPI. Break down the various endpoints (for basic videos, Minecraft videos, Rumble clips, subway videos) into separate modules.
- Supporting Processing Utilities: Components for video processing (FFmpeg), audio transcription (OpenAI’s Whisper), text-to-speech conversion, and web scraping for Rumble links.

b. Relationships and Data Flow:
- If applicable, show how configuration files (like Dockerfile, docker-compose.yaml) coordinate deployment, illustrating the container environment.

c. Architectural Patterns & Design Principles:
- Separation of concerns: The client handles UI/UX with React components and the server encapsulates business logic and multimedia processing.
- Modular design by identifying distinct endpoints and utility scripts within the server directory.
- For the full-stack setup, emphasize standard RESTful communication or API calls that bind the frontend and backend.

d. Relevant Technologies & Frameworks:
- Client: React, Vite, TypeScript, Tailwind CSS, HeroUI.
- Server: Python, FastAPI, FFmpeg, OpenAI Whisper, ImageMagick.
- Additional: Docker (Dockerfile, docker-compose.yaml) for containerization and deployment support.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Docker Container Environment"
        direction TB
        subgraph "BrainRotTok Client"
            direction TB
            ClientMain["Main App (React, TypeScript)"]:::client
            Components["Components (UI Elements)"]:::client
            Pages["Pages (UI Views)"]:::client
            Layouts["Layouts (UI Layouts)"]:::client
            ClientMain -->|"contains"| Components
            Components -->|"navigates_to"| Pages
            Pages -->|"embedded_in"| Layouts
        end
        subgraph "BrainRotTok Server"
            direction TB
            APIServer["FastAPI Server"]:::server
            subgraph "Endpoints"
                direction TB
                Basic["Basic Video Endpoint"]:::serverEndpoint
                Minecraft["Minecraft Video Endpoint"]:::serverEndpoint
                Rumble["Rumble Video Endpoint"]:::serverEndpoint
                Subway["Subway Video Endpoint"]:::serverEndpoint
            end
            subgraph "Processing Utilities"
                direction TB
                GeneralUtils["General Utility Scripts"]:::utility
                AdditionalUtils["Additional Endpoint Utilities"]:::utility
            end
            APIServer -->|"routes_to"| Basic
            APIServer -->|"routes_to"| Minecraft
            APIServer -->|"routes_to"| Rumble
            APIServer -->|"routes_to"| Subway
            Basic -->|"utilizes"| GeneralUtils
            Minecraft -->|"utilizes"| GeneralUtils
            Rumble -->|"utilizes"| AdditionalUtils
            Subway -->|"utilizes"| GeneralUtils
        end
        subgraph "Container Deployment"
            direction TB
            DeployDockerfile["Dockerfile"]:::infrastructure
            DeployCompose["docker-compose.yaml"]:::infrastructure
            DeployRun["run.sh"]:::infrastructure
        end
    end

    ClientMain -->|"API_Request"| APIServer

    DeployDockerfile ---|"deploys"| ClientMain
    DeployDockerfile ---|"deploys"| APIServer
    DeployCompose ---|"orchestrates"| ClientMain
    DeployCompose ---|"orchestrates"| APIServer
    DeployRun ---|"initializes"| ClientMain
    DeployRun ---|"initializes"| APIServer

    classDef client fill:#a0d8ef,stroke:#000,stroke-width:2px;
    classDef server fill:#f7b2ad,stroke:#000,stroke-width:2px;
    classDef serverEndpoint fill:#f7d6ad,stroke:#000,stroke-width:2px;
    classDef utility fill:#d3f7a2,stroke:#000,stroke-width:2px;
    classDef infrastructure fill:#e2d7f7,stroke:#000,stroke-width:2px;

    click ClientMain "https://github.com/detopall/brainrottok/tree/main/brain-rot-tok-client/"
    click Components "https://github.com/detopall/brainrottok/tree/main/brain-rot-tok-client/src/components/"
    click Pages "https://github.com/detopall/brainrottok/tree/main/brain-rot-tok-client/src/pages/"
    click Layouts "https://github.com/detopall/brainrottok/tree/main/brain-rot-tok-client/src/layouts/"
    click APIServer "https://github.com/detopall/brainrottok/tree/main/brain-rot-tok-server/"
    click Basic "https://github.com/detopall/brainrottok/blob/main/brain-rot-tok-server/endpoints/basic.py"
    click Minecraft "https://github.com/detopall/brainrottok/blob/main/brain-rot-tok-server/endpoints/minecraft.py"
    click Rumble "https://github.com/detopall/brainrottok/blob/main/brain-rot-tok-server/endpoints/rumble.py"
    click Subway "https://github.com/detopall/brainrottok/blob/main/brain-rot-tok-server/endpoints/subway.py"
    click GeneralUtils "https://github.com/detopall/brainrottok/tree/main/brain-rot-tok-server/utils/"
    click AdditionalUtils "https://github.com/detopall/brainrottok/tree/main/brain-rot-tok-server/endpoints/utils/"
    click DeployDockerfile "https://github.com/detopall/brainrottok/tree/main/Dockerfile"
    click DeployCompose "https://github.com/detopall/brainrottok/blob/main/docker-compose.yaml"
    click DeployRun "https://github.com/detopall/brainrottok/blob/main/run.sh"
```
