# kafle1/drs architecture

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

- Interactive diagram: https://gitdiagram.com/kafle1/drs
- Repository: https://github.com/kafle1/drs

## Overview

##### Project type and purpose
- This is a client-only Progressive Web App (PWA) for a cricket Decision Review System.
- Built with React + Vite + MUI, it performs video-based analyses (No-Ball, Run Out, LBW) entirely in the browser, with offline support via a service worker.

##### File structure
- Top-level:
- index.html, manifest.json, _redirects, sw.js
- vite.config.js (build config)
- package.json / package-lock.json (dependencies)
- src/ directory:
- main.jsx – renders the root React tree
- App.jsx – application shell & router
- components/ – feature pages (Home, Lbw, Runout, Footer)
- serviceWorker.js – registration logic for PWA
- No backend folder: all logic, including video processing, runs client-side.

##### README for additional insights
- Confirms PWA, offline support, tech stack (React + Vite + MUI).
- Use cases: upload raw video files, run umpire-assist algorithms in the browser.

a. Main components
1. Browser sandbox (the overall runtime)
2. Application Shell (App.jsx + index.html)
3. UI Components – Home, Lbw, Runout, Footer (React/MUI)
4. Video-Processing Modules – the JS functions handling No-Ball, Run Out, LBW analysis
5. Service Worker (sw.js + serviceWorker.js)
6. Cache Storage / Workbox (for offline assets)
7. External Network (for first-time asset fetch & PWA manifest)
b. Relationships & interactions
- On load, index.html → App.jsx initialized by main.jsx
- App.jsx routes to Home or analysis pages
- User uploads video (UI Component) → passed to Video-Processing Module → analysis results displayed
- Service Worker intercepts asset requests (HTML, JS bundles, MUI assets) and serves from cache when offline
- Manifest.json & _redirects allow “install as PWA” behavior
c. Key architectural patterns
- Application Shell pattern: core assets cached on first load, subsequent loads instantly functional offline.
- Component-based UI (React + MUI).
- Single-Page Application (SPA) routing within App.jsx.
- Client-side video analysis (no backend).
d. Important technologies
- React (component tree)
- Vite (build & dev server)
- MUI (styling & UI library)
- Service Worker API (sw.js) & Workbox strategies (cache-first for shell, network-first for updates)
- Browser Cache Storage

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Runtime
    subgraph "Client Runtime (Browser Sandbox)"
        direction TB
        subgraph "Application Shell"
            direction TB
            HTML["index.html"]:::file
            Main["main.jsx"]:::file
            App["App.jsx"]:::file
        end
        subgraph "UI Components"
            direction TB
            Home["Home Page"]:::ui
            Lbw["LBW Analysis Page"]:::ui
            Runout["Run Out Analysis Page"]:::ui
            Footer["Footer Component"]:::ui
        end
        Video["Video-Processing Engine"]:::module
    end

    SW["Service Worker"]:::sw
    Cache["Cache Storage"]:::cache
    Network["External Network"]:::network
    Manifest["manifest.json"]:::file
    Redirect["_redirects"]:::file

    subgraph "Dev & Config"
        direction TB
        Vite["vite.config.js"]:::config
        Package["package.json / package-lock.json"]:::config
    end

    %% Flows
    HTML --> Main --> App
    App --> Home
    App --> Lbw
    App --> Runout
    App --> Footer

    Home -->|"upload video"| Video
    Lbw -->|"upload video"| Video
    Runout -->|"upload video"| Video
    Video -->|"analysis results"| App

    Network -->|"first-time fetch"| SW
    SW -->|"cache assets"| Cache
    SW -->|"serve from cache"| App
    SW -->|"network fallback"| Network

    Network --> Manifest
    Network --> Redirect
    Manifest --> App
    Redirect --> App

    %% Click Events
    click HTML "https://github.com/kafle1/drs/blob/master/index.html"
    click Main "https://github.com/kafle1/drs/blob/master/src/main.jsx"
    click App "https://github.com/kafle1/drs/blob/master/src/App.jsx"
    click Home "https://github.com/kafle1/drs/blob/master/src/components/Home.jsx"
    click Lbw "https://github.com/kafle1/drs/blob/master/src/components/Lbw.jsx"
    click Runout "https://github.com/kafle1/drs/blob/master/src/components/Runout.jsx"
    click Footer "https://github.com/kafle1/drs/blob/master/src/components/Footer.jsx"
    click SW "https://github.com/kafle1/drs/blob/master/src/serviceWorker.js"
    click SW "https://github.com/kafle1/drs/blob/master/sw.js"
    click Manifest "https://github.com/kafle1/drs/blob/master/manifest.json"
    click Redirect "https://github.com/kafle1/drs/tree/master/_redirects"
    click Vite "https://github.com/kafle1/drs/blob/master/vite.config.js"
    click Package "https://github.com/kafle1/drs/blob/master/package.json"

    %% Styles
    classDef file fill:#E8F1F2,stroke:#333;
    classDef ui fill:#CDEAC0,stroke:#333;
    classDef module fill:#FEE4E2,stroke:#333;
    classDef sw fill:#FFD8A9,stroke:#333;
    classDef cache fill:#D0E6A5,stroke:#333;
    classDef network fill:#A0E7E5,stroke:#333;
    classDef config fill:#F4B6C2,stroke:#333;
```
