# piyushsangale13/youtubeclone architecture

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

- Interactive diagram: https://gitdiagram.com/piyushsangale13/youtubeclone
- Repository: https://github.com/piyushsangale13/youtubeclone

## Overview

##### Project Type and Purpose
- This is a client-side single-page application (SPA) built with ReactJS that mimics YouTube’s core features (home page, search page, video playback).
- It’s deployed as a static website on Firebase Hosting and integrates with external services (e.g., YouTube Data API).

##### File Structure Analysis
- Top level:
- Configuration & CI/CD: .firebaserc, firebase.json, .github/workflows/*.yml
- Package management: package.json / package-lock.json
- Source vs. public assets: public/ (index.html, manifest, robots.txt) and src/ (React components, firebase.js, tests, CSS)
- src/:
- Entry point: index.js → App.js
- UI components: Header, Sidebar, ChannelRow, VideoRow, RecommendedVideos, VideoPlayerPage, SearchPage, etc.
- Styles: one .css file per component
- firebase.js: Firebase app initialization

##### Key Insights from README
- Features: search videos, suggestions, responsive design
- Tech stack: ReactJS, npm, Firebase Hosting
- No custom backend code—uses client-side API calls

##### Main Components
a. Developer & Source Control
- Local dev environment (Node.js, npm)
- GitHub repository & branches
- GitHub Actions (PR workflow, merge workflow)
b. CI/CD & Hosting
- GitHub Actions triggers → Firebase CLI
- Firebase Hosting serving static build
c. Client Application
- Browser / SPA runtime
- React component tree (App → Header, Sidebar, Content pages)
- HTTP client module for YouTube Data API calls
- Firebase SDK (from src/firebase.js) for any analytics/auth (if used)
d. External Services
- YouTube Data API (video search, metadata)
- (Optional) Firebase services if reads/writes to database or analytics

##### Relationships and Data Flows
- Developer pushes code → GitHub → GitHub Actions CI → Firebase deploy
- User navigates to URL → Firebase Hosting serves index.html + bundle.js/css
- Browser loads React SPA → React router loads Home or Search page
- SPA issues HTTPS requests to YouTube Data API → receives JSON → renders VideoRows/VideoCards
- Firebase SDK initializes on load (for any analytics/auth operations)

##### Architectural Patterns & Principles
- Component-based UI (React)
- Single Page Application with client-side routing
- CI/CD pipeline automated via GitHub Actions → Infrastructure as Code via firebase.json
- Separation of concerns:
- Build/deploy pipeline
- Static asset hosting
- Client business logic (React)
- External data sources

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer & Source Control"
        GHRepo["GitHub Repository"]:::dev
        ActionsPR["GitHub Actions PR Workflow"]:::dev
        ActionsMerge["GitHub Actions Merge Workflow"]:::dev
    end
    click ActionsPR "https://github.com/piyushsangale13/youtubeclone/blob/master/.github/workflows/firebase-hosting-pull-request.yml"
    click ActionsMerge "https://github.com/piyushsangale13/youtubeclone/blob/master/.github/workflows/firebase-hosting-merge.yml"

    subgraph "CI/CD & Hosting Configuration"
        PackageJSON["package.json"]:::infra
        PackageLock["package-lock.json"]:::infra
        FirebaseRC[".firebaserc"]:::infra
        FirebaseJSON["firebase.json"]:::infra
        Hosting["Firebase Hosting"]:::infra
    end
    click PackageJSON "https://github.com/piyushsangale13/youtubeclone/blob/master/package.json"
    click PackageLock "https://github.com/piyushsangale13/youtubeclone/blob/master/package-lock.json"
    click FirebaseRC "https://github.com/piyushsangale13/youtubeclone/blob/master/.firebaserc"
    click FirebaseJSON "https://github.com/piyushsangale13/youtubeclone/blob/master/firebase.json"

    GHRepo -->|"git push"| ActionsPR
    ActionsPR --> ActionsMerge
    ActionsMerge -->|"deploy via Firebase CLI"| Hosting

    subgraph "Public Assets & SPA Shell"
        IndexHTML["public/index.html"]:::infra
        Manifest["public/manifest.json"]:::infra
        Robots["public/robots.txt"]:::infra
    end
    click IndexHTML "https://github.com/piyushsangale13/youtubeclone/blob/master/public/index.html"
    click Manifest "https://github.com/piyushsangale13/youtubeclone/blob/master/public/manifest.json"
    click Robots "https://github.com/piyushsangale13/youtubeclone/blob/master/public/robots.txt"

    Hosting -->|"serves static files"| IndexHTML
    Hosting -->|"serves static files"| Manifest
    Hosting -->|"serves static files"| Robots

    User["End User"]:::external
    Browser["Web Browser"]:::client

    User -->|"navigates to URL"| Hosting
    Hosting -->|"HTTP GET /bundle.js, /index.html"| Browser

    subgraph "Client Application"
        subgraph "Entry Point & App Bootstrap"
            IndexJS["src/index.js"]:::client
            ReportWV["src/reportWebVitals.js"]:::client
            SetupTests["src/setupTests.js"]:::client
            IndexCSS["src/index.css"]:::client
        end
        subgraph "Core Application Container"
            AppJS["src/App.js"]:::client
            AppCSS["src/App.css"]:::client
            AppTest["src/App.test.js"]:::client
        end
        FirebaseInit["src/firebase.js"]:::client
        subgraph "Layout & Navigation"
            Header["src/Header.js"]:::client
            HeaderCSS["src/Header.css"]:::client
            Sidebar["src/Sidebar.js"]:::client
            SidebarCSS["src/Sidebar.css"]:::client
            SidebarRow["src/SidebarRow.js"]:::client
            SidebarRowCSS["src/SidebarRow.css"]:::client
        end
        subgraph "Content Pages & Widgets"
            RecVids["src/RecommendedVideos.js"]:::client
            RecVidsCSS["src/RecommendedVideos.css"]:::client
            SearchPage["src/SearchPage.js"]:::client
            SearchPageCSS["src/SearchPage.css"]:::client
            ChannelRow["src/ChannelRow.js"]:::client
            ChannelRowCSS["src/ChannelRow.css"]:::client
            VideoRow["src/VideoRow.js"]:::client
            VideoRowCSS["src/VideoRow.css"]:::client
            VideoPlayerPage["src/VideoPlayerPage.jsx"]:::client
            VideoPlayerPageCSS["src/VideoPlayerPage.css"]:::client
            VideoPlayer["src/VideoPlayer.js"]:::client
            VideoCard["src/VideoCard.js"]:::client
            VideoCardCSS["src/VideoCard.css"]:::client
        end
        subgraph "Testing & Tooling"
            AppTest2["src/App.test.js"]:::client
            SetupTests2["src/setupTests.js"]:::client
        end
    end
    click IndexJS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/index.js"
    click ReportWV "https://github.com/piyushsangale13/youtubeclone/blob/master/src/reportWebVitals.js"
    click SetupTests "https://github.com/piyushsangale13/youtubeclone/blob/master/src/setupTests.js"
    click IndexCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/index.css"
    click AppJS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/App.js"
    click AppCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/App.css"
    click AppTest "https://github.com/piyushsangale13/youtubeclone/blob/master/src/App.test.js"
    click FirebaseInit "https://github.com/piyushsangale13/youtubeclone/blob/master/src/firebase.js"
    click Header "https://github.com/piyushsangale13/youtubeclone/blob/master/src/Header.js"
    click HeaderCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/Header.css"
    click Sidebar "https://github.com/piyushsangale13/youtubeclone/blob/master/src/Sidebar.js"
    click SidebarCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/Sidebar.css"
    click SidebarRow "https://github.com/piyushsangale13/youtubeclone/blob/master/src/SidebarRow.js"
    click SidebarRowCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/SidebarRow.css"
    click RecVids "https://github.com/piyushsangale13/youtubeclone/blob/master/src/RecommendedVideos.js"
    click RecVidsCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/RecommendedVideos.css"
    click SearchPage "https://github.com/piyushsangale13/youtubeclone/blob/master/src/SearchPage.js"
    click SearchPageCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/SearchPage.css"
    click ChannelRow "https://github.com/piyushsangale13/youtubeclone/blob/master/src/ChannelRow.js"
    click ChannelRowCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/ChannelRow.css"
    click VideoRow "https://github.com/piyushsangale13/youtubeclone/blob/master/src/VideoRow.js"
    click VideoRowCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/VideoRow.css"
    click VideoPlayerPage "https://github.com/piyushsangale13/youtubeclone/blob/master/src/VideoPlayerPage.jsx"
    click VideoPlayerPageCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/VideoPlayerPage.css"
    click VideoPlayer "https://github.com/piyushsangale13/youtubeclone/blob/master/src/VideoPlayer.js"
    click VideoCard "https://github.com/piyushsangale13/youtubeclone/blob/master/src/VideoCard.js"
    click VideoCardCSS "https://github.com/piyushsangale13/youtubeclone/blob/master/src/VideoCard.css"
    click AppTest2 "https://github.com/piyushsangale13/youtubeclone/blob/master/src/App.test.js"
    click SetupTests2 "https://github.com/piyushsangale13/youtubeclone/blob/master/src/setupTests.js"

    Browser -->|"loads bundle"| IndexJS
    IndexJS -->|"renders"| AppJS
    IndexJS --> FirebaseInit
    AppJS --> Header
    AppJS --> Sidebar
    AppJS --> RecVids
    AppJS --> SearchPage
    AppJS --> VideoPlayerPage

    subgraph "External Services"
        YouTubeAPI["YouTube Data API"]:::external
        FirebaseServices["Firebase Analytics/Auth"]:::external
    end

    RecVids -->|"API request → JSON"| YouTubeAPI
    SearchPage -->|"API request → JSON"| YouTubeAPI
    VideoPlayerPage -->|"API request → JSON"| YouTubeAPI
    FirebaseInit -->|"initialize & calls"| FirebaseServices

    Browser -->|"HTTPS API Requests"| YouTubeAPI

    classDef dev fill:#ccffcc,stroke:#2f6627;
    classDef infra fill:#cce5ff,stroke:#224a5c;
    classDef client fill:#ffe0b3,stroke:#ff9400;
    classDef external fill:#e0e0e0,stroke:#8c8c8c;
```
