Skip to content

vaskoyudha/DBDWaspada

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🦟 DBDWaspada

AI-powered Dengue Hemorrhagic Fever Early Warning System
Platform Prediksi dan Peringatan Dini Wabah Demam Berdarah Dengue

Python Next.js FastAPI XGBoost Docker PostgreSQL TypeScript License

About

DBDWaspada is an advanced AI-driven prediction system designed to forecast Dengue Hemorrhagic Fever (DHF/DBD) outbreaks at the kelurahan (sub-district) level. By integrating epidemiological data, weather patterns, satellite imagery, and social media sentiment, the platform provides a comprehensive early warning system for public health officials.

The system utilizes an XGBoost machine learning model trained on three years of weekly data (2022–2024) across 553 kelurahan in Jakarta, Bandung, and Surabaya. The model predicts outbreak risks two weeks in advance, allowing for proactive intervention. Risks are categorized into three tiers based on incidence rates: LOW (<20/100k), MEDIUM (20–55/100k), and HIGH (>55/100k).

Built specifically for Dinas Kesehatan (Health Departments), the dashboard offers interactive visualizations and explainable AI through SHAP values. This transparency helps decision-makers understand the specific environmental or social factors driving risk in each neighborhood, leading to more precise and effective preventative measures.

The platform streamlines the transition from data to action by automating multi-channel alerts. Whether it's rising temperatures or increasing social media reports of fever, DBDWaspada captures the signals early, helping cities move from reactive treatment to proactive prevention.

Screenshots

Peta Risiko (Risk Map) Riwayat Peringatan (Alert History)
Risk Map Alert History
Monitoring Tweet Navigation Sidebar
Tweet Monitor Sidebar

System Architecture

graph LR
    FE["πŸ–₯️ Frontend\nNext.js 15\n:3000"] -->|REST API| BE["⚑ Backend\nFastAPI\n:8001"]
    BE --> DB["πŸ—„οΈ PostgreSQL 16\n+ TimescaleDB\n+ PostGIS\n:5433"]
    BE --> ML["πŸ“Š MLflow\n:5000"]
    BE --> PF["πŸ”„ Prefect 3\n:4200"]
    style FE fill:#1e293b,color:#fff
    style BE fill:#0f766e,color:#fff
    style DB fill:#1d4ed8,color:#fff
    style ML fill:#7c3aed,color:#fff
    style PF fill:#b45309,color:#fff
Loading

Features

Feature Description
πŸ—ΊοΈ Interactive Choropleth Map MapLibre GL JS + Deck.gl visualization at kelurahan level
πŸ€– XGBoost ML Prediction 2-week ahead dengue outbreak risk prediction
πŸ“Š SHAP Explainability Per-kelurahan SHapley Additive exPlanations for model transparency
πŸ”” Multi-Channel Alerts Automated warnings via WhatsApp, SMS, and Email
🌧️ Weather Integration Rainfall, humidity, and temperature data
πŸ›°οΈ Satellite Imagery Standing water score from satellite data
🐦 Social Media Monitoring Twitter/X sentiment analysis for DBD-related posts
πŸ“ˆ Trend Analytics Historical charts with Recharts
πŸ§ͺ MLflow Experiment Tracking Full ML experiment reproducibility
πŸ”„ Prefect 3 Pipeline Automated data pipeline orchestration
πŸ“š Swagger API Docs Auto-generated interactive API documentation

Quick Start

# 1. Clone the repository
git clone https://github.com/vaskoyudha/DBDWaspada.git
cd DBDWaspada

# 2. Copy environment file
cp .env.example .env

# 3. Launch all services
docker compose up -d

# 4. Check service status
docker compose ps

Database Setup & Seeding

After the containers are running, initialize the database and generate the required mock data:

# Apply database migrations
docker compose exec backend alembic upgrade head

# Seed geographical data (Cities, Districts, Sub-districts)
docker compose exec backend python -m backend.seeders.kelurahan_seeder

# Generate mock datasets for each category
docker compose exec backend python -m backend.generators.dinkes_generator
docker compose exec backend python -m backend.generators.weather_generator
docker compose exec backend python -m backend.generators.satellite_generator
docker compose exec backend python -m backend.generators.tweet_generator

# Train the XGBoost model
docker compose exec backend python -m backend.ml.train

# Generate initial predictions
docker compose exec backend python -m backend.ml.predict

Service URLs

Service URL Description
πŸ–₯️ Frontend Dashboard http://localhost:3000 Main UI
⚑ Backend API http://localhost:8001 FastAPI REST API
πŸ“š API Docs http://localhost:8001/docs Swagger UI
πŸ“Š MLflow UI http://localhost:5000 ML Experiment Tracking
πŸ”„ Prefect UI http://localhost:4200 Pipeline Orchestration
πŸ—„οΈ Database localhost:5433 PostgreSQL (psql)

API Reference

All endpoints are prefixed with /api/v1.

Method Endpoint Description
GET /api/v1/kota List all cities
GET /api/v1/kota/{kota_id}/kelurahan Sub-districts per city (GeoJSON)
GET /api/v1/kelurahan/{kelurahan_id} Specific sub-district details (GeoJSON)
GET /api/v1/predictions?city={name} Risk predictions per city (GeoJSON + SHAP top-5)
GET /api/v1/predictions/shap?city={name}&kelurahan_id={id} SHAP waterfall values per sub-district
GET /api/v1/alerts List of alerts (filters, pagination)
GET /api/v1/alerts/logs?channel={channel} Alert delivery history logs
GET /api/v1/alerts/{alert_id} Specific alert details
POST /api/v1/alerts/dispatch Manually dispatch alerts for current predictions
GET /health System health check
GET /docs Interactive Swagger UI documentation

Tech Stack

  • Backend: Python FastAPI SQLAlchemy, Alembic, XGBoost, SHAP, Prefect 3, MLflow
  • Frontend: Next.js React TypeScript Tailwind CSS v4, MapLibre GL JS, Deck.gl, Recharts
  • Database: PostgreSQL TimescaleDB, PostGIS
  • Infrastructure: Docker

Running Tests

Verify the system by running tests across the stack:

# Backend unit tests (Mocked DB)
docker compose exec backend python -m pytest backend/tests/ -m "not integration" -v

# Backend integration tests (Full DB)
docker compose exec backend python -m pytest backend/tests/ -v

# End-to-End pipeline tests
docker compose exec backend python -m pytest tests/e2e/ -v

# Frontend test suite
docker compose exec frontend pnpm test --run

Development Notes

  • Network Ports: The database uses host port 5433 and the backend uses 8001 to avoid common local conflicts. Port 8000 and 5432 are reserved for internal container mapping.
  • Reproducibility: Mock data generators use a fixed seed of 42.
  • Epidemiological Weeks: Based on WIB (UTC+7) timezone.
  • Data Coverage: 3 years of weekly data (2022–2024) across 7 city entities: Jakarta (5 administrative cities), Bandung, and Surabaya.
  • Resolution: Covers 553 kelurahan: 262 in Jakarta, 137 in Bandung, and 154 in Surabaya.
  • Risk Tiers:
    • LOW (RENDAH): < 20 per 100k population.
    • MEDIUM (SEDANG): 20 – 55 per 100k population.
    • HIGH (TINGGI): > 55 per 100k population.
  • Prediction Target: The model predicts 2 weeks ahead (Target Week = Current Week + 2).

Contributing

Contributions are welcome! Please open an issue first to discuss what you would like to change. Pull requests should be against the main branch.

License

This project is licensed under the MIT License.

About

🦟 Dengue fever early-warning system β€” predictive analytics and geospatial risk mapping for Indonesian communities

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors