# rahul-bhati/ai-short-video-genrator architecture

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

- Interactive diagram: https://gitdiagram.com/rahul-bhati/ai-short-video-genrator
- Repository: https://github.com/rahul-bhati/ai-short-video-genrator

## Overview

##### Project's Main Components
- Frontend Components:
- Pages and Routes: From the “app” directory, clearly separate authentication pages (sign-in, sign-up), the landing page, and the main dashboard (including create-new pages and layout management).
- UI and Shared Components: Located under “components/ui” and the dashboard subcomponents (e.g., Header, SideNav, VideoList, etc.). Also, note provider components within “app/_context” that handle global state (UserDetailContext, VideoDataContext).
- Remotion Integration: Under the “remotion” directory, indicating a specialized part of the system handling video rendering.
- Backend/API Components:
- API Routes: Under “app/api” for generating audio, captions, images, and obtaining video scripts.
- External Configuration Files: The “config” directory holds setup details for AI models, Firebase, database configuration, and schema definitions—a part of the backend logic.
- Shared Libraries and Utilities:
- Utility Functions: Under “lib” (e.g., template, utils, videoAPI) which encapsulate key functionalities shared across the system.
- Infrastructure & Configuration:
- Next.js configuration files (next.config.mjs), middleware, and build-related files (drizzle.config.js, tailwind.config.js, postcss.config.mjs) that indicate deployment and build processes.

##### Relationships and Interactions
- User Interaction Flow:
- Users start at the landing page (app/page.js) and can access authentication pages (app/(auth)/...) to log in or sign up.
- Once authenticated, users navigate to the dashboard where they can view or create new video projects.
- Data Flow and API Communication:
- Within the dashboard, the UI components interact with underlying API routes (via fetch calls in the Next.js API routes) to generate media components (audio, captions, etc.) and video scripts based on user inputs.
- Global state is managed through the context providers (UserDetailContext and VideoDataContext) that make user and video-related data available throughout the app.
- Remotion for Video Processing:
- A separate component (in the “remotion” directory) handles the rendering of videos using the Remotion library. This component integrates with the rest of the system by processing video data received from the dashboard/API.

##### Architectural Patterns and Key Design Choices
- Component-Based Architecture: Leveraging Next.js’s file-based routing and React components for modularity.
- API Layer: Serverless functions (Next.js API routes) separating business logic for media generation from UI rendering.
- Global State Management: Use of React Context across components for state consistency, particularly for user details and video data.
- Separation of Concerns: The UI (in “app” and “components”), business logic (API endpoints and utilities in “lib”), and video processing (Remotion integrations) are well separated.

##### Technologies and Frameworks
- Next.js for full-stack development.
- Remotion for video rendering.
- Firebase (as per the config file) and possibly other external services for authentication or data storage.
- Tailwind CSS and PostCSS for styling.
- Additional libraries for UI (as seen in components/ui) and API interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::user

    subgraph "Frontend Components"
        Landing("Landing Page (app/page.js)"):::frontend
        subgraph "Authentication Module"
            SignIn("Sign In Page"):::frontend
            SignUp("Sign Up Page"):::frontend
        end
        subgraph "Dashboard Module"
            DashLayout("Dashboard Layout"):::frontend
            DashPage("Dashboard Page"):::frontend
            CreateNew("Create New Page"):::frontend
        end
        subgraph "UI Components"
            Alert("Alert Dialog"):::frontend
            Btn("Button"):::frontend
            Card("Card"):::frontend
            Dialog("Dialog"):::frontend
            Input("Input"):::frontend
            Select("Select"):::frontend
            Sonner("Sonner"):::frontend
            Tabs("Tabs"):::frontend
            Textarea("Textarea"):::frontend
        end
        subgraph "Global State Management"
            UContext("UserDetailContext"):::state
            VContext("VideoDataContext"):::state
        end
    end

    subgraph "Backend/API and Utilities"
        subgraph "API Service Layer"
            GenAudio("Generate Audio API"):::backend
            GenCaption("Generate Caption API"):::backend
            GenImage("Generate Image API"):::backend
            GetVideoScript("Get Video Script API"):::backend
        end
        subgraph "Shared Libraries and Utilities"
            Template("Template"):::util
            Utils("Utils"):::util
            VideoAPI("VideoAPI"):::util
        end
    end

    subgraph "Video Processing Engine"
        RemotionRoot("Remotion Root"):::processing
        RemotionIndex("Remotion Index"):::processing
    end

    subgraph "External Configuration"
        AiModel("AiModel"):::config
        FirebaseConfig("FirebaseConfig"):::config
        Db("db"):::config
        Schema("schema"):::config
        NextConfig("next.config.mjs"):::config
        DrizzleConfig("drizzle.config.js"):::config
        TailwindConfig("tailwind.config.js"):::config
        PostcssConfig("postcss.config.mjs"):::config
    end

    %% Relationships
    User --> Landing
    Landing -->|"redirects"| SignIn
    Landing -->|"redirects"| SignUp
    SignIn -->|"authenticates"| DashLayout
    SignUp -->|"authenticates"| DashLayout
    DashLayout -->|"renders"| DashPage
    DashPage -->|"includes"| CreateNew

    DashPage -->|"uses"| Alert
    DashPage -->|"uses"| Btn
    DashPage -->|"uses"| Card
    DashPage -->|"uses"| Dialog
    DashPage -->|"uses"| Input
    DashPage -->|"uses"| Select
    DashPage -->|"uses"| Sonner
    DashPage -->|"uses"| Tabs
    DashPage -->|"uses"| Textarea

    DashPage -->|"manages"| UContext
    DashPage -->|"manages"| VContext

    DashPage -->|"calls"| GenAudio
    DashPage -->|"calls"| GenCaption
    DashPage -->|"calls"| GenImage
    DashPage -->|"calls"| GetVideoScript

    GenAudio -->|"utilizes"| Template
    GenAudio -->|"utilizes"| Utils
    GenAudio -->|"utilizes"| VideoAPI

    GenCaption -->|"utilizes"| Template
    GenCaption -->|"utilizes"| Utils
    GenCaption -->|"utilizes"| VideoAPI

    GenImage -->|"utilizes"| Template
    GenImage -->|"utilizes"| Utils
    GenImage -->|"utilizes"| VideoAPI

    GetVideoScript -->|"utilizes"| Template
    GetVideoScript -->|"utilizes"| Utils
    GetVideoScript -->|"utilizes"| VideoAPI

    ExternalConfiguration --- AiModel
    ExternalConfiguration --- FirebaseConfig
    ExternalConfiguration --- Db
    ExternalConfiguration --- Schema
    ExternalConfiguration --- NextConfig
    ExternalConfiguration --- DrizzleConfig
    ExternalConfiguration --- TailwindConfig
    ExternalConfiguration --- PostcssConfig
    AiModel --- GenAudio
    FirebaseConfig --- GenAudio
    Db --- GenAudio
    Schema --- GenAudio
    NextConfig --- GenAudio
    DrizzleConfig --- GenAudio
    TailwindConfig --- GenAudio
    PostcssConfig --- GenAudio
    AiModel --- GenCaption
    FirebaseConfig --- GenCaption
    Db --- GenCaption
    Schema --- GenCaption
    NextConfig --- GenCaption
    DrizzleConfig --- GenCaption
    TailwindConfig --- GenCaption
    PostcssConfig --- GenCaption
    AiModel --- GenImage
    FirebaseConfig --- GenImage
    Db --- GenImage
    Schema --- GenImage
    NextConfig --- GenImage
    DrizzleConfig --- GenImage
    TailwindConfig --- GenImage
    PostcssConfig --- GenImage
    AiModel --- GetVideoScript
    FirebaseConfig --- GetVideoScript
    Db --- GetVideoScript
    Schema --- GetVideoScript
    NextConfig --- GetVideoScript
    DrizzleConfig --- GetVideoScript
    TailwindConfig --- GetVideoScript
    PostcssConfig --- GetVideoScript

    DashPage -->|"rendersVideo"| RemotionRoot
    DashPage -->|"rendersVideo"| RemotionIndex

    %% Click Events
    click SignIn "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/(auth)/sign-in/[[...sign-in]]/page.jsx"
    click SignUp "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/(auth)/sign-up/[[...sign-up]]/page.jsx"
    click DashPage "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/dashboard/page.jsx"
    click DashLayout "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/dashboard/layout.jsx"
    click CreateNew "https://github.com/rahul-bhati/ai-short-video-genrator/tree/main/app/dashboard/create-new"
    click UContext "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/_context/UserDetailContext.jsx"
    click VContext "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/_context/VideoDataContext.jsx"
    click Alert "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/alert-dialog.jsx"
    click Btn "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/button.jsx"
    click Card "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/card.jsx"
    click Dialog "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/dialog.jsx"
    click Input "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/input.jsx"
    click Select "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/select.jsx"
    click Sonner "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/sonner.jsx"
    click Tabs "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/tabs.jsx"
    click Textarea "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/components/ui/textarea.jsx"
    click GenAudio "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/api/generate-audio/route.jsx"
    click GenCaption "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/api/generate-caption/route.jsx"
    click GenImage "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/api/generate-image/route.jsx"
    click GetVideoScript "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/app/api/get-video-script/route.jsx"
    click RemotionRoot "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/remotion/Root.jsx"
    click RemotionIndex "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/remotion/index.jsx"
    click AiModel "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/config/AiModel.js"
    click FirebaseConfig "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/config/FirebaseConfig.js"
    click Db "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/config/db.js"
    click Schema "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/config/schema.js"
    click NextConfig "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/next.config.mjs"
    click DrizzleConfig "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/drizzle.config.js"
    click TailwindConfig "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/tailwind.config.js"
    click PostcssConfig "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/postcss.config.mjs"
    click Template "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/lib/template.js"
    click Utils "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/lib/utils.js"
    click VideoAPI "https://github.com/rahul-bhati/ai-short-video-genrator/blob/main/lib/videoAPI.js"

    %% Styles
    classDef user fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef frontend fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef backend fill:#ccccff,stroke:#000099,stroke-width:2px;
    classDef processing fill:#fff2cc,stroke:#cc9900,stroke-width:2px;
    classDef state fill:#e6ccff,stroke:#660066,stroke-width:2px;
    classDef util fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef config fill:#eddcd2,stroke:#b38600,stroke-width:2px;
```
