Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”₯ Wildfire Intelligence Platform

AI-powered fire weather monitoring and spread simulation system for the Western Ghats forest reserves.

Python FastAPI React TypeScript MapLibre GL License: MIT


πŸ“– Overview

The Wildfire Intelligence Platform is a full-stack geospatial intelligence system that combines real-time weather ingestion, machine learning fire-risk prediction, satellite fire detection (NASA FIRMS), and a physics-based cellular automata fire spread simulator β€” all presented in a glassmorphic, interactive dashboard.

It was built specifically to monitor fire-prone forest reserves across the Western Ghats of India, providing actionable risk intelligence to ecologists, forest rangers, and fire management teams.


✨ Key Features

Feature Description
🌑️ Real-time Weather Ingestion Pulls temperature, humidity, wind, and rainfall from Open-Meteo at 15-minute intervals
πŸ›°οΈ NASA FIRMS Integration Ingests active fire detections (VIIRS/MODIS) from NASA's Fire Information for Resource Management System
🌿 NDVI Monitoring Vegetation greenness index tracking via satellite-derived fuel moisture proxy
πŸ€– ML Fire Risk Prediction XGBoost model with SHAP explainability providing per-station fire risk probability
πŸ§ͺ Anomaly Detection Isolation Forest detects abnormal meteorological conditions preceding fire events
πŸ’§ Fuel Moisture Estimation Random Forest model estimating live fuel moisture content from weather variables
πŸ—ΊοΈ Fire Spread Simulator Physics-based Cellular Automata (CA) simulation with wind vector, slope, and dryness acceleration
πŸ“Š Interactive Analytics SHAP waterfall charts, gauge indicators, trend analytics, and telemetry panels
πŸ–₯️ Glassmorphic Dashboard Modern, responsive UI with real-time data across Overview, Map, Analytics, Trends, Simulation, and Operations views

πŸ—οΈ Architecture

wildfire-intelligence/
β”œβ”€β”€ backend/                  # FastAPI Python backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ routers/          # REST API route handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ health.py     # System health & DB connectivity
β”‚   β”‚   β”‚   β”œβ”€β”€ stations.py   # Station metadata & FFWI readings
β”‚   β”‚   β”‚   β”œβ”€β”€ readings.py   # Time-series weather data
β”‚   β”‚   β”‚   β”œβ”€β”€ predictions.py# ML fire risk predictions
β”‚   β”‚   β”‚   β”œβ”€β”€ detections.py # NASA FIRMS fire detections
β”‚   β”‚   β”‚   β”œβ”€β”€ simulation.py # Fire spread simulation engine
β”‚   β”‚   β”‚   └── models.py     # Model cards & performance metrics
β”‚   β”‚   β”œβ”€β”€ engines/
β”‚   β”‚   β”‚   β”œβ”€β”€ ffwi.py       # Fosberg Fire Weather Index engine
β”‚   β”‚   β”‚   β”œβ”€β”€ fire_season.py# Fire season calendar logic
β”‚   β”‚   β”‚   └── risk_bands.py # Risk band classification (Lowβ†’Critical)
β”‚   β”‚   β”œβ”€β”€ ingestion/
β”‚   β”‚   β”‚   β”œβ”€β”€ open_meteo.py # Open-Meteo weather data ingestion
β”‚   β”‚   β”‚   β”œβ”€β”€ ndvi.py       # NDVI satellite data ingestion
β”‚   β”‚   β”‚   β”œβ”€β”€ fsi.py        # Fire Season Index computation
β”‚   β”‚   β”‚   └── scheduler.py  # APScheduler background task runner
β”‚   β”‚   β”œβ”€β”€ main.py           # FastAPI app entry point
β”‚   β”‚   β”œβ”€β”€ config.py         # Pydantic settings management
β”‚   β”‚   └── database.py       # SQLAlchemy async session factory
β”‚   └── ml/
β”‚       β”œβ”€β”€ train_xgboost.py       # Fire risk XGBoost trainer
β”‚       β”œβ”€β”€ train_isolation_forest.py # Anomaly detection trainer
β”‚       β”œβ”€β”€ train_fuel_moisture.py # Fuel moisture Random Forest trainer
β”‚       β”œβ”€β”€ feature_engineering.py # Shared feature pipeline
β”‚       └── shap_explainer.py      # SHAP value computation
β”‚
└── frontend/                 # React + TypeScript + Vite frontend
    └── src/
        β”œβ”€β”€ views/
        β”‚   β”œβ”€β”€ Overview.tsx   # Station grid with FFWI risk cards
        β”‚   β”œβ”€β”€ MapView.tsx    # MapLibre GL interactive fire map
        β”‚   β”œβ”€β”€ Analytics.tsx  # SHAP, anomaly & fuel moisture panels
        β”‚   β”œβ”€β”€ Trends.tsx     # Historical weather trend charts
        β”‚   β”œβ”€β”€ Simulation.tsx # Interactive fire spread simulator
        β”‚   └── Operations.tsx # Data pipeline & model ops status
        β”œβ”€β”€ styles/
        β”‚   β”œβ”€β”€ tokens.css     # Design system CSS custom properties
        β”‚   └── glassmorphism.css
        β”œβ”€β”€ hooks/             # Custom React data hooks
        └── utils/             # Shared utilities

🧠 Machine Learning Models

1. XGBoost Fire Risk Classifier

Predicts the probability of fire ignition at each station over the next 24 hours using weather and terrain features. SHAP values provide per-prediction explanations visible directly in the Analytics view.

Key Features: Temperature, Relative Humidity, Wind Speed, FFWI score, NDVI, Rainfall (7-day), Fire Season flag.

2. Isolation Forest Anomaly Detector

Detects statistically anomalous weather patterns (e.g., sudden temperature spike + humidity drop) that historically precede fire events, even when individual values appear within normal range.

3. Random Forest Fuel Moisture Estimator

Estimates live fuel moisture content (%) from meteorological inputs. Dry fuel (<15% moisture) accelerates fire spread dramatically in the simulation engine.


πŸ—ΊοΈ Fire Spread Simulation

The simulation engine implements a physics-based Cellular Automata model on a high-resolution geospatial grid over the selected reserve:

  • Wind Vector Acceleration: Spread rate multiplied in downwind directions using the wind azimuth
  • Terrain Slope: Uphill spread is geometrically accelerated (tilted flame pre-heating)
  • Fuel Moisture: Drier cells (from ML model output) have shorter transit times between grid nodes
  • Fosberg Fire Weather Index (FFWI): Real-time scalar that gates overall spread intensity
  • Interactive Controls: Click ignition origin, adjust wind speed/direction, playback timeline scrubber, and real-time elapsed timer

πŸš€ Getting Started

Prerequisites

  • Python 3.11+
  • Node.js 18+ and npm
  • PostgreSQL 15+ (with PostGIS recommended)
  • NASA FIRMS API key β†’ Register here

1. Clone the Repository

git clone https://github.com/Nekilesh001/forest-fire-ai.git
cd forest-fire-ai

2. Backend Setup

# Create and activate virtual environment
python -m venv .venv
.venv\Scripts\activate        # Windows
# source .venv/bin/activate   # macOS/Linux

# Install dependencies
pip install -r backend/requirements.txt

# Configure environment variables
cp .env.example .env
# Edit .env with your database credentials and NASA FIRMS key

.env Configuration

Variable Description Default
POSTGRES_HOST PostgreSQL host localhost
POSTGRES_PORT PostgreSQL port 5432
POSTGRES_DB Database name wildfire
POSTGRES_USER DB username postgres
POSTGRES_PASSWORD DB password (required)
NASA_FIRMS_KEY NASA FIRMS API key (required)
ALLOWED_ORIGINS CORS origins http://localhost:5173
LOG_LEVEL Logging verbosity INFO

Run the Backend

# From project root
uvicorn backend.app.main:app --reload --host 0.0.0.0 --port 8000

API docs available at: http://localhost:8000/docs


3. Train ML Models

Run training scripts before launching the backend for the first time (or whenever you want to retrain on updated data):

cd backend
python -m ml.train_xgboost
python -m ml.train_isolation_forest
python -m ml.train_fuel_moisture

4. Frontend Setup

cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

Frontend runs at: http://localhost:5173


5. Production Build

cd frontend
npm run build
# Output in frontend/dist/

🌐 API Endpoints

Method Endpoint Description
GET /api/health System health and DB connectivity check
GET /api/stations All monitoring stations with latest readings
GET /api/stations/{id}/readings Time-series weather data for a station
GET /api/predictions/{station_id} ML fire risk predictions
GET /api/detections NASA FIRMS active fire detections
POST /api/simulation/run Run a fire spread simulation
GET /api/models Model cards and performance metrics

Full interactive API documentation: /docs (Swagger UI) or /redoc


πŸ“Š Dashboard Views

View Description
Overview Station grid cards with FFWI score, risk band, and 4-metric weather summary
Map Real-time interactive MapLibre GL map with fire detections and spread simulation overlay
Analytics SHAP waterfall explanations, Isolation Forest anomaly indicator, fuel moisture gauge
Trends Historical time-series charts with extreme value panels
Simulation Interactive fire spread simulator with wind/terrain physics controls
Operations Data pipeline health, ingestion schedules, model performance metrics

πŸ› οΈ Tech Stack

Backend

  • FastAPI β€” Async REST API framework
  • SQLAlchemy (Async) β€” ORM and database session management
  • PostgreSQL β€” Primary time-series and geospatial data store
  • APScheduler β€” Background scheduler for weather ingestion
  • XGBoost β€” Gradient boosting fire risk classifier
  • scikit-learn β€” Isolation Forest and Random Forest models
  • SHAP β€” Model explainability and feature attribution
  • Loguru β€” Structured application logging

Frontend

  • React 19 + TypeScript β€” UI framework
  • Vite β€” Build tool and development server
  • MapLibre GL JS β€” Open-source WebGL interactive mapping
  • Deck.gl β€” GPU-accelerated geospatial visualization layers
  • D3.js β€” Custom data-driven charts and gauges
  • React Router v7 β€” Client-side navigation
  • Tailwind CSS β€” Utility-first styling with custom design tokens

πŸ“ Data Sources

Source Data Type Update Frequency
Open-Meteo Temperature, Humidity, Wind, Rainfall Every 15 minutes
NASA FIRMS VIIRS/MODIS active fire detections Daily
Copernicus/Sentinel NDVI vegetation index Weekly/On-demand

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit changes: git commit -m "Add my feature"
  4. Push to branch: git push origin feature/my-feature
  5. Open a Pull Request

Please ensure backend changes include unit tests in backend/tests/ and frontend changes follow the existing component patterns.


πŸ“œ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ™ Acknowledgements

  • NASA FIRMS for open access fire detection data
  • Open-Meteo for free, open weather API
  • MapLibre GL for the open-source mapping engine
  • The Western Ghats forest ecology community for domain expertise

Built with ❀️ for forest fire intelligence and conservation.

About

Real-time geospatial wildfire monitoring dashboard for South Indian forests using FastAPI, React, MongoDB, and IoT telemetry simulation. Features live environmental tracking, GIS visualization, and rule-based fire risk prediction across multiple wildlife reserves.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages