# covid19india/covid19india-react architecture

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

- Interactive diagram: https://gitdiagram.com/covid19india/covid19india-react
- Repository: https://github.com/covid19india/covid19india-react

## Overview

##### Project type and purpose
- This is a single-page React application that visualizes COVID-19 data for India.
- It pulls data from an external API (https://api.covid19india.org) and renders maps and charts in the browser.

##### File structure
- Top-level “public” directory holds static assets: index.html, manifest, robots.txt, raw and projected map JSON files.
- “src” is the React codebase, including components, hooks, utilities, i18n, service worker setup, and web workers.
- Build configuration is in rollup.config.js; service-worker templates and build script (swTemplate.js, swBuild.js) set up offline caching.
- Scripts folder has a shell script to process project maps.
- CI/CD and contribution workflows live under .github and Husky hooks manage pre-commit linting/tests.

##### README for additional insights
- Confirms that it’s purely a front-end project that consumes a public API.
- No backend code is included, so the “system” is primarily the browser and external services.

##### Detail
- Piece: public maps JSON, sw registration, worker scripts, i18n subsystem, component tree, static-host, API, CI.
- Don’t conflate all front-end code into “Client”—break it out into React vs caching vs worker.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser and Components
    subgraph "Client Browser" 
        direction TB
        Browser["Browser"]:::frontend
        Browser -->|loads| CDN["Static Host (CDN)"]:::external
        Browser -->|registers| SW["Service Worker"]:::worker
        Browser -->|spawns| WW["Web Worker"]:::worker
        Browser -->|runs| ReactApp["React SPA"]:::frontend
    end

    %% React Application Breakdown
    subgraph "React SPA" 
        direction TB
        Index["index.js"]:::frontend
        AppJS["App.js"]:::frontend
        AppSCSS["App.scss"]:::frontend
        Components["UI Components\n(src/components/)"]:::frontend
        Hooks["useStickySWR.js"]:::frontend
        Utils["commonFunctions.js"]:::frontend
        i18nSub["i18n\n(src/i18n/)"]:::frontend
        LocalesAll["locales/all_locales.json"]:::frontend
        LocalesMiss["locales/missing_locales.json"]:::frontend
        Tests["Tests\n(src/setupTests.js & src/tests/)"]:::infra

        ReactApp --> Index
        ReactApp --> AppJS
        ReactApp --> AppSCSS
        ReactApp --> Components
        ReactApp --> Hooks
        ReactApp --> Utils
        ReactApp --> i18nSub
        ReactApp --> LocalesAll
        ReactApp --> LocalesMiss
        ReactApp --> Tests
    end

    %% Service Worker & Build Config
    subgraph "Service Worker & Build" 
        direction TB
        SWTemplate["swTemplate.js"]:::worker
        SWBuild["swBuild.js"]:::worker
        SWFile["serviceWorker.js"]:::worker
        Rollup["rollup.config.js"]:::infra

        SW --> SWFile
        SWFile --> SWTemplate
        SWFile --> SWBuild
        Rollup --> SWBuild
    end

    %% Web Worker Processing
    subgraph "Web Worker" 
        direction TB
        Districts["getDistricts.js"]:::worker
        WW --> Districts
    end

    %% Static Assets
    subgraph "Static Assets (public)" 
        direction TB
        HTML["index.html"]:::external
        Manifest["manifest.json"]:::external
        Robots["robots.txt"]:::external
        RawMaps["maps/"]:::external
        Projected["projected_maps/"]:::external

        CDN --> HTML
        CDN --> Manifest
        CDN --> Robots
        CDN --> RawMaps
        CDN --> Projected
    end

    %% External API
    API["COVID-19 Data API\n(api.covid19india.org)"]:::external

    ReactApp -->|fetch data via SW| API
    SW -->|intercepts| API

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        direction TB
        CI1[".github/workflows/ci.yml"]:::infra
        CI2["nodejs.yml"]:::infra
        CI3["project-card-moved.yml"]:::infra
        CI4["claim.yml"]:::infra
        CI5["mod.yml"]:::infra
        Hooks[".husky/pre-commit"]:::infra
        ESLint[".eslintrc.js"]:::infra
        Prettier[".prettierrc"]:::infra
        SassLint[".sass-lint.yml"]:::infra

        CI1 --> CI2
        CI2 --> CI3
        CI3 --> CI4
        CI4 --> CI5
        CI1 --> Hooks
        CI1 --> ESLint
        CI1 --> Prettier
        CI1 --> SassLint
        CI1 -->|deploy| CDN
    end

    %% Map Processing Scripts
    Scripts["scripts/project-maps.sh"]:::infra
    Scripts --> RawMaps
    Scripts --> Projected

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef worker fill:#E8D0FF,stroke:#333,stroke-width:1px
    classDef external fill:#D0FFD8,stroke:#333,stroke-width:1px
    classDef infra fill:#F0F0F0,stroke:#333,stroke-width:1px

    %% Click Events
    click Index "https://github.com/covid19india/covid19india-react/blob/master/src/index.js"
    click AppJS "https://github.com/covid19india/covid19india-react/blob/master/src/App.js"
    click AppSCSS "https://github.com/covid19india/covid19india-react/blob/master/src/App.scss"
    click Components "https://github.com/covid19india/covid19india-react/tree/master/src/components/"
    click Hooks "https://github.com/covid19india/covid19india-react/blob/master/src/hooks/useStickySWR.js"
    click Utils "https://github.com/covid19india/covid19india-react/blob/master/src/utils/commonFunctions.js"
    click i18nSub "https://github.com/covid19india/covid19india-react/blob/master/src/i18n/index.js"
    click LocalesAll "https://github.com/covid19india/covid19india-react/blob/master/locales/all_locales.json"
    click LocalesMiss "https://github.com/covid19india/covid19india-react/blob/master/locales/missing_locales.json"
    click SWFile "https://github.com/covid19india/covid19india-react/blob/master/src/serviceWorker.js"
    click SWTemplate "https://github.com/covid19india/covid19india-react/blob/master/src/swTemplate.js"
    click SWBuild "https://github.com/covid19india/covid19india-react/blob/master/src/swBuild.js"
    click Rollup "https://github.com/covid19india/covid19india-react/blob/master/rollup.config.js"
    click Districts "https://github.com/covid19india/covid19india-react/blob/master/src/workers/getDistricts.js"
    click HTML "https://github.com/covid19india/covid19india-react/blob/master/public/index.html"
    click Manifest "https://github.com/covid19india/covid19india-react/blob/master/public/manifest.json"
    click Robots "https://github.com/covid19india/covid19india-react/blob/master/public/robots.txt"
    click RawMaps "https://github.com/covid19india/covid19india-react/tree/master/public/maps/"
    click Projected "https://github.com/covid19india/covid19india-react/tree/master/public/projected_maps/"
    click Scripts "https://github.com/covid19india/covid19india-react/blob/master/scripts/project-maps.sh"
    click CI1 "https://github.com/covid19india/covid19india-react/blob/master/.github/workflows/ci.yml"
    click CI2 "https://github.com/covid19india/covid19india-react/blob/master/.github/workflows/nodejs.yml"
    click CI3 "https://github.com/covid19india/covid19india-react/blob/master/.github/workflows/project-card-moved.yml"
    click CI4 "https://github.com/covid19india/covid19india-react/blob/master/.github/workflows/claim.yml"
    click CI5 "https://github.com/covid19india/covid19india-react/blob/master/.github/workflows/mod.yml"
    click Hooks "https://github.com/covid19india/covid19india-react/tree/master/.husky/pre-commit"
    click ESLint "https://github.com/covid19india/covid19india-react/blob/master/.eslintrc.js"
    click Prettier "https://github.com/covid19india/covid19india-react/blob/master/.prettierrc"
    click SassLint "https://github.com/covid19india/covid19india-react/blob/master/.sass-lint.yml"
    click Tests "https://github.com/covid19india/covid19india-react/blob/master/src/setupTests.js"
```
