How adrianhajdin/project_corona_tracker works
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