# prem528/ai-short-video-generator-ii architecture

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

- Interactive diagram: https://gitdiagram.com/prem528/ai-short-video-generator-ii
- Repository: https://github.com/prem528/ai-short-video-generator-ii

## Overview

##### Main System Components

a) Client Layer:
- Public Pages (Landing, About)
- Auth Pages (Sign-in, Sign-up)
- Dashboard Interface
- Admin Interface

b) Application Layer:
- Next.js Server Components
- API Routes
- Authentication System
- Video Processing Pipeline

c) Service Layer:
- Video Generation Service (Remotion)
- Payment Processing (Razorpay)
- AI Services (Caption/Audio Generation)
- Data Scraping Service

d) Data Layer:
- Database (SQL, indicated by Drizzle ORM)
- Firebase Integration
- File Storage (for media)

##### Component Relationships

a) Client-Server Communication:
- API Routes (/api/*)
- Server-Side Rendering Paths
- Client-Side Data Fetching

b) Service Integration:
- Video Processing Flow
- Payment Processing Flow
- AI Service Integration

##### Specific Implementation Details

Technical elements:

a) Frontend Architecture:
- Next.js App Router Structure
- Context Providers (VideoDataContext, UserDataContext)
- UI Component Library

b) Backend Services:
- API Routes for Various Functions
- Authentication Flow
- Payment Processing Pipeline
- Video Generation Pipeline

##### Key Workflows to Highlight

Main processes:

a) Video Creation Flow:
##### Storage/Delivery

b) User Management Flow:
##### Credits System

c) Payment Processing Flow:

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        PUB[Public Pages]
        AUTH[Authentication Pages]
        DASH[Dashboard Interface]
        ADMIN[Admin Interface]
    end

    subgraph AppLayer
        NEXT[Next.js Server Components]
        API[API Routes]
        AUTHSYS[Authentication System]
        VIDPROC[Video Processing Pipeline]
    end

    subgraph Services
        VGS[Video Generation Service]
        PAY[Payment Processing]
        AI[AI Services]
        SCRAPE[Data Scraping Service]
    end

    subgraph Data
        DB[(Database)]
        FB[(Firebase)]
        STORE[(File Storage)]
    end

    subgraph Context
        VCTX[Video Data Context]
        UCTX[User Data Context]
    end

    %% Client Layer Connections
    PUB --> NEXT
    AUTH --> AUTHSYS
    DASH --> API
    ADMIN --> API

    %% App Layer Connections
    NEXT --> API
    API --> VIDPROC
    API --> Services
    AUTHSYS --> FB

    %% Service Layer Connections
    VGS --> STORE
    PAY --> DB
    AI --> STORE
    SCRAPE --> DB

    %% Data Layer Connections
    DB --> API
    FB --> AUTHSYS
    STORE --> VIDPROC

    %% Context Connections
    VCTX --> DASH
    UCTX --> DASH

    %% Styling
    classDef frontend fill:#a8d1ff
    classDef backend fill:#90EE90
    classDef service fill:#FFE5B4
    classDef data fill:#DDA0DD
    classDef context fill:#FFB6C1

    class PUB,AUTH,DASH,ADMIN frontend
    class NEXT,API,AUTHSYS,VIDPROC backend
    class VGS,PAY,AI,SCRAPE service
    class DB,FB,STORE data
    class VCTX,UCTX context

    %% Click Events
    click PUB "https://github.com/prem528/ai-short-video-generator-II/blob/master/app/page.js"
    click AUTH "https://github.com/prem528/ai-short-video-generator-II/blob/master/app/(auth)/sign-in/[[...sign-in]]/page.jsx"
    click DASH "https://github.com/prem528/ai-short-video-generator-II/tree/master/app/dashboard/"
    click ADMIN "https://github.com/prem528/ai-short-video-generator-II/tree/master/app/admin/"
    click AUTHSYS "https://github.com/prem528/ai-short-video-generator-II/blob/master/middleware.js"
    click VIDPROC "https://github.com/prem528/ai-short-video-generator-II/blob/master/app/api/render-video/route.jsx"
    click PAY "https://github.com/prem528/ai-short-video-generator-II/blob/master/app/api/razorpay/route.jsx"
    click AI "https://github.com/prem528/ai-short-video-generator-II/blob/master/configs/AiModel.js"
    click SCRAPE "https://github.com/prem528/ai-short-video-generator-II/blob/master/app/api/scrape-site-data/route.jsx"
    click DB "https://github.com/prem528/ai-short-video-generator-II/blob/master/configs/db.js"
    click FB "https://github.com/prem528/ai-short-video-generator-II/blob/master/configs/FirebaseConfig.js"
    click VCTX "https://github.com/prem528/ai-short-video-generator-II/blob/master/app/_context/VideoDataContext.jsx"
    click UCTX "https://github.com/prem528/ai-short-video-generator-II/blob/master/app/_context/userDataContext.jsx"
```
