# adrianhajdin/project_corona_tracker architecture

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

- Interactive diagram: https://gitdiagram.com/adrianhajdin/project_corona_tracker
- Repository: https://github.com/adrianhajdin/project_corona_tracker

## Overview

##### Project Type and Purpose
- This is a single-page React application (front-end only) called “COVID-19 Tracker.”
- Its sole purpose is to fetch real-time COVID-19 statistics from an external REST API (https://covid19.mathdro.id/api) and render them in a browser using React, Hooks, Chart.js, and Material UI.

##### File Structure
- Top level:
- public/ – static HTML (index.html) and assets loaded at runtime
- src/ – all React source code
– src/index.js → app entry point (renders `<App/>` into DOM)
– src/App.js (+ CSS module) → root React component orchestrating data fetch and child components
– src/api/index.js → wrapper around fetch calls to the COVID-19 REST API
– src/components/ → reusable UI components:
- Cards/ → Info cards for confirmed, recovered, deaths
- Chart/ → line/bar chart plotting historical data
- CountryPicker/ → dropdown to select country
- Config & tooling:
- .eslintrc.js, package.json / package-lock.json (dependencies: react, chart.js, material-ui)
- Deployment implied via Netlify (see README “Live Site” link)

##### Key Insights from the README
- Tech stack: React + Hooks, Chart.js, Material UI
- Data source: covid19.mathdro.id API
- Developer workflow: “npm i && npm start,” implying Create React App or similar bundler/webpack setup
- No backend code—purely client-side

##### Main Components and Their Interactions
a. Browser/Client (User’s device)
– Hosts the React single-page app
b. React Application
– App Component
- Manages state (global vs. country) via React Hooks
- Delegates rendering to child components
– API Service (src/api/index.js)
- Encapsulates HTTP GET calls to the external API
– UI Components
- Cards – display current statistics
- Chart – render historical trends
- CountryPicker – let user choose a country
c. External COVID-19 REST API
– Provides JSON payloads for global and country-specific data
d. Deployment Platform (e.g., Netlify)
– Builds and serves static JS/CSS assets to end users

##### Architectural Patterns and Design Principles
- Component-based UI: each folder under src/components maps to a single React component or logical group
- Single Responsibility: API calls are abstracted in src/api; data presentation is handled in Cards/Chart
- Unidirectional Data Flow: App pulls data, passes it down as props to child components
- Separation of Concerns: CSS modules colocated with each component

a. Components (use rectangles with labels):
– Browser / React SPA (Client)
– App Component
– API Service Module
– Cards Component
– Chart Component
– CountryPicker Component
– External COVID-19 REST API
– Deployment / CDN layer (optional)
– Browser → App Component (initial load)
– App Component → API Service (fetchGlobalData, fetchCountryData)
– API Service → External API (HTTPS GET)
– External API → API Service (JSON response)
– API Service → App Component (returns JS objects)
– App Component → Cards/Chart/CountryPicker (passes props)
– User Interaction (CountryPicker) → App Component (state update) → API Service → Components
– External systems (REST API, CDN) in another (e.g., green)
d. Deployment Considerations:
– Show build step (Webpack/CRA) → static artifacts → CDN/Netlify → Browser

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Deployment Layer
    subgraph "Build & Deployment"
        Build["Webpack/CRA Build"]:::deployment
        CDN["CDN / Netlify"]:::deployment
    end

    %% Static Assets
    subgraph "Static Assets"
        HTML["public/index.html"]:::frontend
        entry["src/index.js"]:::frontend
    end

    %% Browser
    Browser["User's Browser"]:::frontend

    %% React Application
    subgraph "React Application"
        App["App Component"]:::frontend
        AppStyle["App.module.css"]:::frontend
        subgraph "UI Components"
            Cards["Cards Component"]:::frontend
            Chart["Chart Component\n(Chart.js)"]:::frontend
            Picker["CountryPicker Component"]:::frontend
        end
        APIService["src/api Service"]:::service
    end

    %% External API
    APIExt["External COVID-19 API\n(covid19.mathdro.id)"]:::external

    %% Flow
    Browser -->|"Request HTML"| CDN
    CDN -->|"Serve index.html"| Browser
    HTML --> entry --> Build --> CDN
    Browser -->|"Load SPA"| App
    App -->|"uses styles"| AppStyle
    App -->|"props: data"| Cards
    App -->|"props: data"| Chart
    App -->|"props: country"| Picker
    App -->|"calls fetchGlobalData\nfetchCountryData"| APIService
    APIService -->|"GET /api"| APIExt
    APIExt -->|"JSON response"| APIService
    APIService -->|"return data"| App
    Picker -->|"onChange country"| App
    App -->|"re-render"| Cards
    App -->|"re-render"| Chart

    %% Click Events
    click App "https://github.com/adrianhajdin/project_corona_tracker/blob/master/src/App.js"
    click AppStyle "https://github.com/adrianhajdin/project_corona_tracker/blob/master/src/App.module.css"
    click APIService "https://github.com/adrianhajdin/project_corona_tracker/blob/master/src/api/index.js"
    click Cards "https://github.com/adrianhajdin/project_corona_tracker/blob/master/src/components/Cards/Cards.jsx"
    click Chart "https://github.com/adrianhajdin/project_corona_tracker/blob/master/src/components/Chart/Chart.jsx"
    click Picker "https://github.com/adrianhajdin/project_corona_tracker/blob/master/src/components/CountryPicker/CountryPicker.jsx"
    click entry "https://github.com/adrianhajdin/project_corona_tracker/blob/master/src/index.js"
    click HTML "https://github.com/adrianhajdin/project_corona_tracker/blob/master/public/index.html"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1,stroke-width:1px;
    classDef service fill:#FFE0B2,stroke:#E65100,color:#E65100,stroke-width:1px;
    classDef external fill:#C8E6C9,stroke:#2E7D32,color:#2E7D32,stroke-width:1px;
    classDef deployment fill:#E1BEE7,stroke:#6A1B9A,color:#6A1B9A,stroke-width:1px;
```
