Skip to content

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Global Disease Tracker 🌍

A modern, interactive dashboard for tracking multiple global diseases including COVID-19, Influenza, Mpox, Malaria, and Dengue. Built with React 19, TypeScript, and real-time data integration.

Global Disease Tracker TypeScript Vite License

πŸš€ Live Demo

Production URL: https://global-disease-tracker-ws0794eak-pranoybasus-projects.vercel.app

View the live application deployed on Vercel with automatic HTTPS, CDN distribution, and global edge network.

✨ Features

Multi-Disease Support

  • COVID-19: Real-time data from disease.sh API
  • Influenza: Mock data with realistic patterns
  • Mpox: Simulated outbreak tracking
  • Malaria: Endemic disease monitoring
  • Dengue: Seasonal outbreak data

Interactive Visualizations

  • πŸ—ΊοΈ Interactive Leaflet Map with disease-specific markers
  • πŸ“Š Real-time Statistics with animated stat cards
  • 🎨 Disease-Specific Color Schemes for visual clarity
  • πŸ”„ Smooth Animations using Framer Motion
  • πŸ“± Responsive Design for mobile, tablet, and desktop

Advanced Features

  • Momentum Tracking: 24-hour, 3-day, and 7-day case trends
  • Population Normalization: Per-million population metrics
  • Projected Cases: AI-powered case projections
  • Multiple Map Styles: Light, color, and dark themes
  • Logarithmic/Linear Scaling: Flexible data visualization
  • Collapsible Control Panel: Clean, organized interface
  • Detailed Statistics Pages: In-depth analysis with charts and tables
  • Multi-Format Export: Export data as PDF, PNG, CSV, or JSON
  • Advanced Filtering: Search, sort, and filter country data
  • Interactive Charts: Bar, line, and area charts with Recharts
  • Shareable URLs: Copy links to specific disease metrics

πŸ—οΈ Architecture

Technology Stack

Category Technology Version Purpose
Framework React 19 UI library with concurrent features
Language TypeScript 5.9 Type-safe development
Build Tool Vite 7.1 Fast HMR and optimized builds
Styling Tailwind CSS v4 Utility-first CSS with custom theme
UI Components Shadcn/ui Latest Accessible Radix UI components
State Management Zustand 5.0 Client state with localStorage
Server State TanStack Query 5.90 Data fetching and caching
Animations Framer Motion 12.23 Declarative animations
Maps Leaflet + React-Leaflet 1.9.4 / 5.0.0 Interactive mapping
HTTP Client Axios 1.13 API requests with retry logic
Routing React Router 7.9 Client-side routing
Charts Recharts 2.15 Composable charting library
PDF Export jsPDF 2.5 PDF document generation
Image Export html2canvas 1.4 DOM to canvas conversion
Notifications Sonner 1.7 Toast notifications
Testing Vitest 4.0.6 Unit testing framework
Icons Lucide React 0.552.0 Beautiful icon library

Project Structure

global-disease-tracker/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/           # React components
β”‚   β”‚   β”œβ”€β”€ ui/              # Shadcn UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ card.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ select.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ toggle.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ slider.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ skeleton.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ button.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ input.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ table.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ dialog.tsx
β”‚   β”‚   β”‚   └── tabs.tsx
β”‚   β”‚   β”œβ”€β”€ DiseaseMap.tsx                # Interactive Leaflet map
β”‚   β”‚   β”œβ”€β”€ DiseaseStatsCard.tsx          # Animated statistics cards
β”‚   β”‚   β”œβ”€β”€ DiseaseSelector.tsx           # Disease selection dropdown
β”‚   β”‚   β”œβ”€β”€ CollapsibleControlPanel.tsx   # Collapsible sidebar
β”‚   β”‚   β”œβ”€β”€ CountryDataTable.tsx          # Sortable data table
β”‚   β”‚   β”œβ”€β”€ CountryComparisonChart.tsx    # Bar/Line/Area charts
β”‚   β”‚   β”œβ”€β”€ MetricDistributionChart.tsx   # Pie/Donut charts
β”‚   β”‚   β”œβ”€β”€ ExportModal.tsx               # Multi-format export dialog
β”‚   β”‚   └── ErrorBoundary.tsx             # Error handling component
β”‚   β”‚
β”‚   β”œβ”€β”€ pages/               # Route pages
β”‚   β”‚   └── DetailedStatsPage.tsx   # Detailed statistics view
β”‚   β”‚
β”‚   β”œβ”€β”€ config/              # Configuration files
β”‚   β”‚   β”œβ”€β”€ diseases.ts      # Disease metadata and color schemes
β”‚   β”‚   └── routes.tsx       # React Router configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ services/            # Business logic and APIs
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ diseaseApi.ts      # Unified disease API (Adapter Pattern)
β”‚   β”‚   β”‚   β”œβ”€β”€ covidApi.ts        # COVID-19 API integration
β”‚   β”‚   β”‚   β”œβ”€β”€ apiClient.ts       # Axios client with retry logic
β”‚   β”‚   β”‚   └── queryClient.ts     # TanStack Query configuration
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ algorithms/
β”‚   β”‚   β”‚   β”œβ”€β”€ momentumCalculations.ts   # Trend calculations
β”‚   β”‚   β”‚   β”œβ”€β”€ containmentScore.ts       # Disease metrics
β”‚   β”‚   β”‚   └── __tests__/                # Algorithm tests
β”‚   β”‚   β”‚
β”‚   β”‚   └── mockData/
β”‚   β”‚       β”œβ”€β”€ influenzaMockData.ts
β”‚   β”‚       β”œβ”€β”€ mpoxMockData.ts
β”‚   β”‚       β”œβ”€β”€ malariaMockData.ts
β”‚   β”‚       └── dengueMockData.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ store/               # State management
β”‚   β”‚   └── appStore.ts      # Zustand store with persistence
β”‚   β”‚
β”‚   β”œβ”€β”€ types/               # TypeScript definitions
β”‚   β”‚   └── index.ts         # Shared type definitions
β”‚   β”‚
β”‚   β”œβ”€β”€ test/                # Test utilities
β”‚   β”‚   └── setup.ts         # Vitest configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ App.tsx              # Main application component
β”‚   β”œβ”€β”€ main.tsx             # Application entry point
β”‚   └── index.css            # Global styles and Tailwind imports
β”‚
β”œβ”€β”€ public/                  # Static assets
β”œβ”€β”€ docs/                    # Documentation
β”‚   β”œβ”€β”€ API_INTEGRATION.md   # API integration guide
β”‚   └── DISEASE_DATA_SOURCES.md  # Data source documentation
β”‚
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json            # TypeScript configuration
β”œβ”€β”€ vite.config.ts           # Vite configuration
β”œβ”€β”€ tailwind.config.js       # Tailwind CSS configuration
β”œβ”€β”€ postcss.config.js        # PostCSS configuration
└── vitest.config.ts         # Vitest test configuration

Key Design Patterns

1. Adapter Pattern (Core Architecture)

The application uses an adapter pattern to abstract data sources, allowing seamless switching between real APIs and mock data:

// Unified API interface
export function useDiseaseData(disease: Disease) {
  return useQuery({
    queryKey: ['disease', disease],
    queryFn: async () => {
      // Adapter selects appropriate data source
      if (disease === 'covid19') {
        return await fetchCovidData(); // Real API
      } else {
        return generateMockData(disease); // Mock data
      }
    }
  });
}

Benefits:

  • Easy to add new diseases
  • Simple migration from mock to real data
  • Consistent data structure across all diseases
  • Testable with mock data

2. Component Composition

Reusable, composable components for maintainability:

<DiseaseStatsCard
  title="Total Cases"
  value={globalStats?.cases || 0}
  icon={Activity}
  disease={selectedDisease}
/>

3. Type-Safe Configuration

Disease configurations use const assertions for type safety:

export const diseaseConfigs = {
  covid19: {
    name: 'COVID-19',
    colors: { primary: 'rgb(239, 68, 68)', ... },
    icon: Activity,
    // ...
  }
} as const;

export type Disease = keyof typeof diseaseConfigs;

4. State Management Strategy

  • Zustand: Client state (disease selection, preferences) with localStorage persistence
  • TanStack Query: Server state (API data) with automatic caching and revalidation
  • React State: Component-local UI state (form controls, toggles)

5. Error Boundaries

Graceful error handling at multiple levels:

  • Top-level boundary in main.tsx
  • Component-level boundaries around critical sections (map, charts)
  • Custom fallback UIs that maintain layout integrity

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm/yarn
  • Modern browser with ES2022 support

Installation

# Clone the repository
git clone https://github.com/yourusername/global-disease-tracker.git
cd global-disease-tracker

# Install dependencies
npm install

# Start development server
npm run dev

The application will be available at http://localhost:5173

Building for Production

# Create optimized production build
npm run build

# Preview production build
npm run preview

πŸ“– Usage Guide

Navigation

Main Dashboard

The homepage (/) displays:

  • Interactive world map with disease markers
  • Global statistics cards (Total Cases, Deaths, Recovered, Active)
  • Top 10 affected countries
  • Disease selector and control panel

Detailed Statistics Pages

Click any statistic card to navigate to detailed analysis:

  • Route pattern: /stats/:disease/:metric
  • Example: /stats/covid19/total-cases
  • Features: Charts, tables, filters, and export options

Switching Diseases

Use the disease selector dropdown in the collapsible control panel to switch between different diseases. The entire UI updates with disease-specific colors and data.

Map Controls

  • Display Mode: Choose between cumulative cases or momentum (24h, 3-day, 7-day trends)
  • Map Style: Switch between light, color, and dark map themes
  • Population Normalized: View cases per million population
  • Marker Size: Adjust the size of disease markers on the map

Detailed Statistics Features

Interactive Charts

  • Country Comparison Chart:

    • View top 10 countries by metric
    • Switch between Bar, Line, and Area chart types
    • Responsive sizing for all devices
    • Hover tooltips with detailed data
  • Metric Distribution Chart:

    • Continental breakdown with Pie or Donut charts
    • Percentage and absolute values
    • Color-coded by continent

Data Table

  • Search: Filter countries by name
  • Sort: Click column headers to sort ascending/descending
  • Filter by Continent: Dropdown to filter specific regions
  • Pagination: Navigate through large datasets (10/25/50/100 rows per page)
  • Responsive: Optimized for mobile and desktop viewing

Export & Sharing

Export Formats

Click the "Export" button on any detailed stats page to access export options:

  1. PDF Export πŸ“„

    • Professional document with charts and tables
    • Includes metadata (disease, metric, timestamp)
    • Automatically formatted and sized
    • Use case: Reports, presentations, documentation
  2. PNG Export πŸ–ΌοΈ

    • High-resolution image (2x scale)
    • Captures entire page including charts
    • Perfect for social media or quick sharing
    • Use case: Screenshots, visual sharing
  3. CSV Export πŸ“Š

    • Spreadsheet-compatible format
    • Headers: Country, Continent, Value
    • Easy import into Excel, Google Sheets
    • Use case: Data analysis, further processing
  4. JSON Export πŸ’Ύ

    • Structured data format
    • Includes metadata and full dataset
    • Programmatic access and integration
    • Use case: APIs, data pipelines, custom analysis
  5. Share Link πŸ”—

    • Copies current page URL to clipboard
    • Shareable with colleagues and teams
    • Preserves disease and metric selection
    • Use case: Collaboration, bookmarking
Export File Naming

Files are automatically named with the pattern:

{disease}-{metric}-{timestamp}.{extension}

Example: covid19-total-cases-2025-01-04.pdf

Interpreting Data

  • Markers on Map: Size proportional to case count (or normalized rate)
  • Stat Cards: Show total cases, deaths, recoveries, and active cases with 7-day trends
  • Top 10 Countries: Ranked by active cases (descending order)
  • Chart Colors: Disease-specific theming for visual consistency

πŸ§ͺ Testing

# Run unit tests
npm run test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:coverage

Current test coverage includes:

  • Algorithm correctness (momentum, containment scores)
  • Component rendering
  • API integration logic

πŸ“š Documentation

🎨 Customization

Adding a New Disease

  1. Update Type Definition in src/types/index.ts
  2. Add Configuration in src/config/diseases.ts
  3. Create Mock Data Generator in src/services/mockData/
  4. Update API Adapter in src/services/api/diseaseApi.ts
  5. Add Tailwind Colors in tailwind.config.js

See API_INTEGRATION.md for detailed instructions.

Customizing Colors

Disease-specific colors are defined in src/config/diseases.ts:

colors: {
  primary: 'rgb(239, 68, 68)',    // Main theme color
  secondary: 'rgb(254, 202, 202)', // Accent color
  bg: 'bg-red-50',                 // Background class
  text: 'text-red-700',            // Text color class
  border: 'border-red-200'         // Border color class
}

πŸ”§ Configuration

Environment Variables

Create a .env file for API configuration:

VITE_COVID_API_URL=https://disease.sh/v3/covid-19
VITE_ENABLE_MOCK_DATA=false
VITE_API_RETRY_ATTEMPTS=3

TypeScript Configuration

The project uses strict TypeScript settings:

  • strict: true
  • verbatimModuleSyntax: true
  • erasableSyntaxOnly: true

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Use TypeScript for all new code
  • Follow ESLint rules (run npm run lint)
  • Write tests for new features
  • Use meaningful commit messages

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • disease.sh - COVID-19 data API
  • Shadcn/ui - Beautiful UI components
  • Leaflet - Interactive mapping library
  • Tailwind CSS - Utility-first CSS framework
  • TanStack Query - Powerful data synchronization

πŸ“§ Contact

For questions or support, please open an issue on GitHub.


Built with ❀️ using React, TypeScript, and modern web technologies

About

A modern, interactive dashboard for tracking multiple global diseases including COVID-19, Influenza, Mpox, Malaria, and Dengue. Built with React 19, TypeScript, and real-time data integration.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages