# b0llu/stormplay architecture

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

- Interactive diagram: https://gitdiagram.com/b0llu/stormplay
- Repository: https://github.com/b0llu/stormplay

## Overview

##### Project type and purpose
- This is a full-stack video streaming SPA (“StormPlay”) built with React on the frontend and Node/Express on the backend.
- Purpose: allow PC enthusiasts to browse, like, save, and organize video tutorials into playlists, with user authentication via JWT.

##### File structure
- Top-level directories:
- public – static assets and the SPA entrypoint (index.html, redirects, manifest).
- src – React application code (App.js, Components, Context, Pages, Hooks, etc.).
- src/backend – Node/Express server code with controllers, mock “db” modules, and auth utilities.
- Key files:
- src/server.js – Express app setup and route registration.
- src/index.js – ReactDOM rendering of the App.
- Context/ & Reducer – client-side state management.
- controllers/ – REST API handlers (Auth, Video, Category, Playlist, Like, WatchLater, History).
- db/*.js – stubbed data stores.
- utils/authUtils.js – JWT generation and verification helpers.

##### README for additional insights
- Auth uses JWT_SECRET from env.
- The server and client are started together via `npm start` (likely using concurrently).
- No external DB—uses mock JS modules, so this is ideal for prototyping or testing.

##### Detail
- Context providers wrapping the App tree.
- On the server side, list each controller by name and attach the corresponding route path.
- Auth flow: Login/Signup endpoints → returns JWT → stored in client (localStorage/context) → attached as Bearer token on subsequent requests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User"]:::user

    %% Client Side
    subgraph "Client (Browser)" 
        direction TB
        subgraph "Static Assets"
            HTML["index.html"]:::frontend
            Manifest["manifest.json"]:::frontend
            Redirects["_redirects"]:::frontend
        end
        subgraph "SPA Entry"
            Index["index.js"]:::frontend
            App["App.js"]:::frontend
        end
        subgraph "Components"
            ComponentsDir["Components"]:::frontend
        end
        subgraph "Pages"
            PagesDir["Pages"]:::frontend
        end
        subgraph "Context"
            AuthContext["Auth.context.js"]:::frontend
            ThemeContext["Theme.context.js"]:::frontend
            LikeContext["Like.context.js"]:::frontend
            WatchLaterContext["WatchLater.context.js"]:::frontend
            HistoryContext["History.context.js"]:::frontend
            PlaylistContext["Playlist.context.js"]:::frontend
            ReducerContext["Reducer.context.js"]:::frontend
            ContextIndex["index.js"]:::frontend
        end
        subgraph "Hooks"
            UseFunction["useFunction.js"]:::frontend
            UseTitle["useTitle.js"]:::frontend
        end
        Mockman["Mockman.js"]:::frontend
    end

    %% API Call proxy
    FetchCalls["API Calls\n(fetch/axios)"]:::api

    %% Server Side
    subgraph "Server (Express API)"
        direction TB
        ServerEntry["server.js"]:::backend
        subgraph "Controllers"
            AuthCtrl["AuthController.js"]:::backend
            VideoCtrl["VideoController.js"]:::backend
            CategoryCtrl["CategoryController.js"]:::backend
            PlaylistCtrl["PlaylistController.js"]:::backend
            LikeCtrl["LikeController.js"]:::backend
            WatchLaterCtrl["WatchLaterController.js"]:::backend
            HistoryCtrl["HistoryController.js"]:::backend
        end
        AuthUtil["authUtils.js"]:::util
        subgraph "Data Store"
            UsersDB["users.js"]:::datastore
            VideosDB["videos.js"]:::datastore
            CategoriesDB["categories.js"]:::datastore
        end
    end

    %% Relationships
    User -->|"interacts with"| Index
    Index -->|"renders"| ComponentsDir
    PagesDir -->|"renders"| ComponentsDir
    ComponentsDir -->|"dispatches actions to"| ContextIndex
    ContextIndex -->|"provides state to"| ComponentsDir
    UseFunction -.-> ComponentsDir
    UseTitle -.-> ComponentsDir
    Mockman -->|"mocks API"| FetchCalls

    ComponentsDir -->|"HTTP requests"| FetchCalls
    PagesDir -->|"HTTP requests"| FetchCalls
    FetchCalls -->|"calls routes"| ServerEntry

    ServerEntry -->|"routes to"| AuthCtrl
    ServerEntry -->|"routes to"| VideoCtrl
    ServerEntry -->|"routes to"| CategoryCtrl
    ServerEntry -->|"routes to"| PlaylistCtrl
    ServerEntry -->|"routes to"| LikeCtrl
    ServerEntry -->|"routes to"| WatchLaterCtrl
    ServerEntry -->|"routes to"| HistoryCtrl

    AuthCtrl -->|"uses"| AuthUtil
    AuthCtrl -->|"reads/writes"| UsersDB

    VideoCtrl -->|"reads/writes"| VideosDB
    CategoryCtrl -->|"reads/writes"| CategoriesDB
    PlaylistCtrl -->|"reads/writes"| UsersDB
    PlaylistCtrl -->|"reads/writes"| VideosDB
    LikeCtrl -->|"reads/writes"| UsersDB
    LikeCtrl -->|"reads/writes"| VideosDB
    WatchLaterCtrl -->|"reads/writes"| UsersDB
    WatchLaterCtrl -->|"reads/writes"| VideosDB
    HistoryCtrl -->|"reads/writes"| UsersDB
    HistoryCtrl -->|"reads/writes"| VideosDB

    ServerEntry -->|"serves static"| HTML

    %% Click Events
    click Index "https://github.com/b0llu/stormplay/blob/developer/src/index.js"
    click App "https://github.com/b0llu/stormplay/blob/developer/src/App.js"
    click HTML "https://github.com/b0llu/stormplay/blob/developer/public/index.html"
    click Manifest "https://github.com/b0llu/stormplay/blob/developer/public/manifest.json"
    click Redirects "https://github.com/b0llu/stormplay/tree/developer/public/_redirects"
    click ComponentsDir "https://github.com/b0llu/stormplay/tree/developer/src/Components"
    click PagesDir "https://github.com/b0llu/stormplay/tree/developer/src/Pages"
    click AuthContext "https://github.com/b0llu/stormplay/blob/developer/src/Context/Auth.context.js"
    click ThemeContext "https://github.com/b0llu/stormplay/blob/developer/src/Context/Theme.context.js"
    click LikeContext "https://github.com/b0llu/stormplay/blob/developer/src/Context/Like.context.js"
    click WatchLaterContext "https://github.com/b0llu/stormplay/blob/developer/src/Context/WatchLater.context.js"
    click HistoryContext "https://github.com/b0llu/stormplay/blob/developer/src/Context/History.context.js"
    click PlaylistContext "https://github.com/b0llu/stormplay/blob/developer/src/Context/Playlist.context.js"
    click ReducerContext "https://github.com/b0llu/stormplay/blob/developer/src/Context/Reducer.context.js"
    click ContextIndex "https://github.com/b0llu/stormplay/blob/developer/src/Context/index.js"
    click UseFunction "https://github.com/b0llu/stormplay/blob/developer/src/Hook/useFunction.js"
    click UseTitle "https://github.com/b0llu/stormplay/blob/developer/src/Hook/useTitle.js"
    click Mockman "https://github.com/b0llu/stormplay/blob/developer/src/Mockman.js"
    click ServerEntry "https://github.com/b0llu/stormplay/blob/developer/src/server.js"
    click AuthCtrl "https://github.com/b0llu/stormplay/blob/developer/src/backend/controllers/AuthController.js"
    click VideoCtrl "https://github.com/b0llu/stormplay/blob/developer/src/backend/controllers/VideoController.js"
    click CategoryCtrl "https://github.com/b0llu/stormplay/blob/developer/src/backend/controllers/CategoryController.js"
    click PlaylistCtrl "https://github.com/b0llu/stormplay/blob/developer/src/backend/controllers/PlaylistController.js"
    click LikeCtrl "https://github.com/b0llu/stormplay/blob/developer/src/backend/controllers/LikeController.js"
    click WatchLaterCtrl "https://github.com/b0llu/stormplay/blob/developer/src/backend/controllers/WatchLaterController.js"
    click HistoryCtrl "https://github.com/b0llu/stormplay/blob/developer/src/backend/controllers/HistoryController.js"
    click AuthUtil "https://github.com/b0llu/stormplay/blob/developer/src/backend/utils/authUtils.js"
    click UsersDB "https://github.com/b0llu/stormplay/blob/developer/src/backend/db/users.js"
    click VideosDB "https://github.com/b0llu/stormplay/blob/developer/src/backend/db/videos.js"
    click CategoriesDB "https://github.com/b0llu/stormplay/blob/developer/src/backend/db/categories.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,color:#000
    classDef backend fill:#90EE90,stroke:#000,color:#000
    classDef datastore fill:#FFA500,stroke:#000,color:#000
    classDef util fill:#DDA0DD,stroke:#000,color:#000
    classDef api fill:#D3D3D3,stroke:#000,color:#000
    classDef user fill:#FFC0CB,stroke:#000,color:#000
```
