# ravikumar1002/web-video architecture

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

- Interactive diagram: https://gitdiagram.com/ravikumar1002/web-video
- Repository: https://github.com/ravikumar1002/web-video

## Overview

##### Project type and purpose
- This is a front-end single-page application (SPA) built with React and TypeScript that functions as a video library (YouTube-like) client.
- It relies on external services: YouTube Data API (via Axios), Firebase (Authentication and Firestore), and is deployed to Netlify.

##### File structure
- Top-level: index.html, netlify.toml, package.json, tsconfigs, vite.config.js – indicates a Vite-powered React app deployed via Netlify.
- src/ contains:
- components/ – reusable UI pieces (cards, modals, nav bar, protected route)
- pages/ – route-mapped screens (auth, home, single video, playlists, history, watch later, liked, error)
- services/ – API wrappers: YouTube Axios instance, JSON fetchers
- config/ – app constants, Firebase setup, theme definitions
- store/, thunk/ and pages/*Slice.ts – Redux toolkit slices and thunk actions
- dto/ – data-transfer object interfaces for categories, channels, videos
- hooks/ – custom React hooks for formatting dates, document titles, numbers

##### README for additional insights
- Tech stack confirms React, TS, Firebase Auth, React Router, YouTube API, Redux, Material UI, Zod for validation.
- Screens & features align with pages/ folder: listing, detail, playlists, history, liked, watch later, auth.

a. Main components:
- UI Layer (React Components & Pages)
- State Management Layer (Redux Store & Thunks)
- Service Layer (Axios to YouTube API, Firebase SDK)
- External Services (YouTube Data API, Firebase Auth & Firestore)
b. Relationships & interactions:
1. User interacts with React UI (Pages & Components).
2. UI dispatches Redux actions or calls service functions directly.
3. Redux Thunks use Axios Instance or Firebase SDK to fetch/update data.
4. External APIs respond; thunks dispatch success/failure actions.
5. Redux Store updates state; UI re-renders with new data.
c. Architectural patterns & principles:
- Flux pattern via Redux (single source of truth, unidirectional data flow).
- Layered separation: presentation → state → services → external.
- Modular file structure: feature-based (pages + slices), cross-cutting (components, services).
- BaaS approach: Firebase handles auth and persistence, no custom backend.
d. Key technologies & libraries:
- React Router for navigation between pages.
- Redux Toolkit & Redux Thunk for state/actions.
- Axios for HTTP calls to YouTube API.
- Firebase SDK for auth & Firestore.
- Material UI & custom CSS modules for styling.
- Zod for client-side validation.

##### Essential elements to capture
- All screens (pages) as separate components in the UI layer.
- The Redux store with its slices (auth, videos, playlists, history, liked, watchLater, categories).
- The Axios instance pointing at YouTube API plus any interceptors.
- Firebase Auth & Firestore flows (sign-in, CRUD on playlist/history).
- Custom hooks and DTOs can be noted as utilities that UI and services share.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        subgraph "Components"
            Modal["Modal"]:::ui
            AuthRoute["AuthRoute"]:::ui
            VideoCardComp["VideoCard"]:::ui
            VideoCardContent["VideoCardContent"]:::ui
            VideoCardImage["VideoCardImage"]:::ui
            VideoMenu["VideoMenu"]:::ui
            PlaylistMenu["PlaylistMenu"]:::ui
            AsideBar["AsideBar"]:::ui
            NavLink["navigation-link"]:::ui
            CardSkeleton["CardSkeleton"]:::ui
        end
        subgraph "Pages"
            Home["HomePage"]:::ui
            VideoPlay["VideoPlayPage"]:::ui
            Login["LoginPage"]:::ui
            SignUp["SignUpPage"]:::ui
            Playlists["PlaylistsPage"]:::ui
            SinglePlaylist["SinglePlaylistPage"]:::ui
            WatchLater["WatchLaterPage"]:::ui
            Liked["LikedPage"]:::ui
            History["HistoryPage"]:::ui
            Page404["Page404"]:::ui
            VideoNotFound["VideoNotFoundPage"]:::ui
        end
    end

    %% State Management
    subgraph "State Management"
        Store["Redux Store"]:::state
        subgraph "Slices"
            AuthSlice["authSlice"]:::state
            UserSlice["userSlice"]:::state
            VideosSlice["videosSlice"]:::state
        end
        subgraph "Thunks"
            VideosThunk["VideosThunk"]:::state
            AuthThunk["AuthThunk"]:::state
            CategoriesThunk["CategoriesThunk"]:::state
            HistoryThunk["HistoryThunk"]:::state
            LikedThunk["LikedThunk"]:::state
            PlaylistsThunk["PlaylistsThunk"]:::state
            WatchLaterThunk["WatchLaterThunk"]:::state
        end
    end

    %% Service Layer
    subgraph "Service Layer"
        Axios["YouTube Axios Instance"]:::service
        JSONFetcher["GetAsJSON"]:::service
        FirebaseConfig["Firebase Config"]:::service
    end

    %% External Services
    subgraph "External Services"
        YouTubeAPI["YouTube Data API"]:::external
        FirebaseAuth["Firebase Auth SDK"]:::external
        Firestore["Firebase Firestore"]:::external
    end

    %% UI to State
    Home -->|"dispatch fetchVideos"| VideosThunk
    VideoPlay -->|"dispatch fetchVideoById"| VideosThunk
    Login -->|"dispatch signIn"| AuthThunk
    SignUp -->|"dispatch signUp"| AuthThunk
    Playlists -->|"dispatch fetchPlaylists"| PlaylistsThunk
    SinglePlaylist -->|"dispatch fetchSinglePlaylist"| PlaylistsThunk
    WatchLater -->|"dispatch fetchWatchLater"| WatchLaterThunk
    Liked -->|"dispatch fetchLiked"| LikedThunk
    History -->|"dispatch fetchHistory"| HistoryThunk

    %% State to Service
    VideosThunk -->|"GET /search"| Axios
    CategoriesThunk -->|"GET /categories"| Axios
    AuthThunk -->|"firebase.auth() calls"| FirebaseAuth
    PlaylistsThunk -->|"Firestore CRUD"| Firestore
    HistoryThunk -->|"Firestore CRUD"| Firestore
    LikedThunk -->|"Firestore CRUD"| Firestore
    WatchLaterThunk -->|"Firestore CRUD"| Firestore

    %% Service to External
    Axios -->|"HTTP Request"| YouTubeAPI
    FirebaseAuth -->|"Auth Call"| FirebaseAuth
    Firestore -->|"DB Call"| Firestore

    %% Data flow back
    YouTubeAPI -->|"Response"| Axios
    FirebaseAuth -->|"Auth Response"| AuthThunk
    Firestore -->|"Data Response"| PlaylistsThunk

    %% State updates
    VideosThunk -->|"dispatch success/failure"| Store
    AuthThunk -->|"dispatch success/failure"| Store
    PlaylistsThunk -->|"dispatch success/failure"| Store
    HistoryThunk -->|"dispatch success/failure"| Store
    LikedThunk -->|"dispatch success/failure"| Store
    WatchLaterThunk -->|"dispatch success/failure"| Store

    %% Store to UI
    Store -->|"state update"| Home

    %% Click Events
    click Modal "https://github.com/ravikumar1002/web-video/blob/main/src/components/modal/Modal.tsx"
    click AuthRoute "https://github.com/ravikumar1002/web-video/blob/main/src/components/AuthRoute.tsx"
    click VideoCardComp "https://github.com/ravikumar1002/web-video/blob/main/src/components/video-card/VideoCard.tsx"
    click VideoCardContent "https://github.com/ravikumar1002/web-video/blob/main/src/components/video-card/VideoCardContent.tsx"
    click VideoCardImage "https://github.com/ravikumar1002/web-video/blob/main/src/components/video-card/VideoCardImage.tsx"
    click VideoMenu "https://github.com/ravikumar1002/web-video/blob/main/src/components/video-card/VideoMenu.tsx"
    click PlaylistMenu "https://github.com/ravikumar1002/web-video/blob/main/src/components/video-card/PlaylistMenu.tsx"
    click AsideBar "https://github.com/ravikumar1002/web-video/blob/main/src/components/aside-nav/AsideBar.tsx"
    click NavLink "https://github.com/ravikumar1002/web-video/blob/main/src/components/aside-nav/navigation-link.ts"
    click CardSkeleton "https://github.com/ravikumar1002/web-video/blob/main/src/components/sceleton/CardSceleton.tsx"
    click Home "https://github.com/ravikumar1002/web-video/blob/main/src/pages/home/Home.tsx"
    click VideoPlay "https://github.com/ravikumar1002/web-video/blob/main/src/pages/singleVideo/VideoPlayPage.tsx"
    click Login "https://github.com/ravikumar1002/web-video/blob/main/src/pages/auth/Login.tsx"
    click SignUp "https://github.com/ravikumar1002/web-video/blob/main/src/pages/auth/SignUp.tsx"
    click Playlists "https://github.com/ravikumar1002/web-video/blob/main/src/pages/playlists/Playlists.tsx"
    click SinglePlaylist "https://github.com/ravikumar1002/web-video/blob/main/src/pages/playlists/SinglePlaylistPage.tsx"
    click WatchLater "https://github.com/ravikumar1002/web-video/blob/main/src/pages/watch_later/WatchLater.tsx"
    click Liked "https://github.com/ravikumar1002/web-video/blob/main/src/pages/liked/Liked.tsx"
    click History "https://github.com/ravikumar1002/web-video/blob/main/src/pages/history/History.tsx"
    click Page404 "https://github.com/ravikumar1002/web-video/blob/main/src/pages/error/page404.tsx"
    click VideoNotFound "https://github.com/ravikumar1002/web-video/blob/main/src/pages/error/videoNotFound.tsx"
    click Store "https://github.com/ravikumar1002/web-video/blob/main/src/store/index.ts"
    click AuthSlice "https://github.com/ravikumar1002/web-video/blob/main/src/pages/auth/authSlice.ts"
    click UserSlice "https://github.com/ravikumar1002/web-video/blob/main/src/pages/auth/userSlice.ts"
    click VideosSlice "https://github.com/ravikumar1002/web-video/blob/main/src/pages/home/videosSlice.ts"
    click VideosThunk "https://github.com/ravikumar1002/web-video/blob/main/src/thunk/VideosThunk.ts"
    click AuthThunk "https://github.com/ravikumar1002/web-video/blob/main/src/thunk/authThunk.ts"
    click CategoriesThunk "https://github.com/ravikumar1002/web-video/blob/main/src/thunk/categoriesThunk.ts"
    click HistoryThunk "https://github.com/ravikumar1002/web-video/blob/main/src/thunk/historyThunk.ts"
    click LikedThunk "https://github.com/ravikumar1002/web-video/blob/main/src/thunk/likedThunk.ts"
    click PlaylistsThunk "https://github.com/ravikumar1002/web-video/blob/main/src/thunk/playliststhunk.ts"
    click WatchLaterThunk "https://github.com/ravikumar1002/web-video/blob/main/src/thunk/watchlaterThunk.ts"
    click Axios "https://github.com/ravikumar1002/web-video/blob/main/src/services/axiosInstance/youtubeInstance.ts"
    click JSONFetcher "https://github.com/ravikumar1002/web-video/blob/main/src/services/GetAsJSON.ts"
    click FirebaseConfig "https://github.com/ravikumar1002/web-video/blob/main/src/config/firebase.ts"
    click appConfigs "https://github.com/ravikumar1002/web-video/blob/main/src/config/appConfigs.ts"
    click configTs "https://github.com/ravikumar1002/web-video/blob/main/src/config/config.ts"
    click theme "https://github.com/ravikumar1002/web-video/blob/main/src/config/theme.ts"
    click categoriesDto "https://github.com/ravikumar1002/web-video/blob/main/src/dto/categories.ts"
    click channelsDto "https://github.com/ravikumar1002/web-video/blob/main/src/dto/channels.ts"
    click videosDto "https://github.com/ravikumar1002/web-video/blob/main/src/dto/videos.ts"
    click reduxCallDto "https://github.com/ravikumar1002/web-video/blob/main/src/dto/redux_call.ts"
    click useDateFormat "https://github.com/ravikumar1002/web-video/blob/main/src/hooks/useDateFormat.ts"
    click useDocumentTitle "https://github.com/ravikumar1002/web-video/blob/main/src/hooks/useDocumentTitle.ts"
    click useNumberFormat "https://github.com/ravikumar1002/web-video/blob/main/src/hooks/useNumberFormat.ts"

    %% Styles
    classDef ui fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef state fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20
    classDef service fill:#FFE0B2,stroke:#E65100,color:#E65100
    classDef external fill:#FFCDD2,stroke:#B71C1C,color:#B71C1C
```
