# joaovictorgi/youtube-clone architecture

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

- Interactive diagram: https://gitdiagram.com/joaovictorgi/youtube-clone
- Repository: https://github.com/joaovictorgi/youtube-clone

## Overview

##### Main Components

A. Frontend (Client Layer):
- React Application (Vite-based)
- Key Components:
- User Interface Components (Header, Menu, Categories, Video Components)
- Pages (Home, Login, Sign-up, Upload, History, Library)
- Context Management (UserContext)
- API Integration Layer

B. Backend (Server Layer):
- Express.js Server
- Middleware Layer (Authentication)
- Module-based Architecture:
- User Module
- Videos Module
- Database Repositories

C. Database Layer:
- MySQL Database
- Two main entities:
- Users
- Videos

**[Client Tier] → [Server Tier] → [Database Tier]**

##### Connection and Flow Representation

- Blue: Frontend components
- Green: Backend services
- Yellow: Database layer
- Red: Authentication/Security components

##### Additional Elements

- Version/environment indicators (dev/preview/production)

##### Specific Implementation Details

Frontend:
**[React App (Vite)]**
- Pages
- Home
- Login/Sign-up
- Upload
- History/Library
- Components
- Header
- Menu
- Video Components
- Context & API Layer

Backend:
**[Express.js Server]**
- Authentication Middleware
- User Module
- User Repository
- Videos Module
- Video Repository
- Routes
- user.routes
- videos.routes

##### Technical Stack Indicators

- TypeScript
- React
- Express.js
- MySQL
- Docker
- Material-UI
- Vite

Remember to indicate the development workflow (dev, build, preview) as mentioned in the README, as this is important for understanding the deployment architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        App["React App (Vite)"]:::frontend
        click App "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/App.tsx"
        
        subgraph Components
            Header["Header"]:::frontend
            click Header "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/components/header/index.tsx"
            Menu["Menu"]:::frontend
            click Menu "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/components/menu/index.tsx"
            Categories["Categories"]:::frontend
            click Categories "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/components/categories/index.tsx"
            VideoComp["Video Component"]:::frontend
            click VideoComp "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/components/videoComponent/index.tsx"
        end
        
        subgraph Pages
            Home["Home"]:::frontend
            click Home "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/pages/home/index.tsx"
            Login["Login"]:::frontend
            click Login "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/pages/login/index.tsx"
            SignUp["Sign-up"]:::frontend
            click SignUp "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/pages/sign-up/index.tsx"
            Upload["Upload"]:::frontend
            click Upload "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/pages/upload/index.tsx"
            History["History"]:::frontend
            click History "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/pages/history/index.tsx"
            Library["Library"]:::frontend
            click Library "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/pages/library/index.tsx"
        end
        
        UserContext["User Context"]:::frontend
        click UserContext "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/context/userContext.tsx"
        APILayer["API Integration Layer"]:::frontend
        click APILayer "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/client/src/api.ts"
    end
    
    subgraph Server
        ExpressServer["Express.js Server"]:::backend
        click ExpressServer "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/src/server.ts"
        
        AuthMiddleware["Authentication Middleware"]:::security
        click AuthMiddleware "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/src/middleware/auth.ts"
        
        subgraph Modules
            UserModule["User Module"]:::backend
            click UserModule "https://github.com/JoaoVictorGI/Youtube-Clone/tree/master/server/src/modules/user"
            VideosModule["Videos Module"]:::backend
            click VideosModule "https://github.com/JoaoVictorGI/Youtube-Clone/tree/master/server/src/modules/videos"
        end
        
        subgraph Repositories
            UserRepo["User Repository"]:::backend
            click UserRepo "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/src/modules/user/repositories/UserRepository.ts"
            VideoRepo["Video Repository"]:::backend
            click VideoRepo "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/src/modules/videos/repositories/VideoRepository.ts"
        end
        
        subgraph Routes
            UserRoutes["User Routes"]:::backend
            click UserRoutes "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/src/routes/user.routes.ts"
            VideoRoutes["Video Routes"]:::backend
            click VideoRoutes "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/src/routes/videos.routes.ts"
        end
        
        DBConnection["Database Connection"]:::backend
        click DBConnection "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/src/mysql.ts"
    end
    
    subgraph Database
        MySQL["MySQL Database"]:::database
        Users["Users Table"]:::database
        click Users "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/database/users.sql"
        Videos["Videos Table"]:::database
        click Videos "https://github.com/JoaoVictorGI/Youtube-Clone/blob/master/server/database/videos.sql"
    end
    
    %% Connections
    App --> Components
    App --> Pages
    App --> UserContext
    App --> APILayer
    APILayer --> ExpressServer
    ExpressServer --> AuthMiddleware
    AuthMiddleware --> Modules
    UserModule --> UserRepo
    VideosModule --> VideoRepo
    UserRepo --> DBConnection
    VideoRepo --> DBConnection
    DBConnection --> MySQL
    MySQL --> Users
    MySQL --> Videos
    UserRoutes --> UserModule
    VideoRoutes --> VideosModule
    
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    
    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        DB["Database Component"]:::database
        Security["Security Component"]:::security
    end
```
