ForestGuard is an open-source, full-stack satellite monitoring and environmental change detection platform. It couples high-resolution optical imagery (Sentinel-2) and spectral index analysis with an interactive geospatial dashboard, change vectorization, automated timeline tracking, and AI-assisted environmental impact reporting.
- Interactive Geospatial AOI Selection: Draw arbitrary polygon boundaries directly on an interactive MapLibre GL map or load pre-configured benchmark sites (Amazon Rainforest, Elephant Butte Reservoir, Austin Urban Growth).
- Multi-Temporal Spectral Analysis: Computes pixel-level difference masks across core spectral indices:
- NDVI (Normalized Difference Vegetation Index) for canopy disturbance and deforestation.
- MNDWI / NDWI (Normalized Difference Water Index) for drought, reservoir shrinkage, and flood recession.
- NDBI (Normalized Difference Built-up Index) for urbanization and bare-ground expansion.
- Vectorized Hotspots & GeoJSON Overlay: Converts pixel change masks into GeoJSON polygons with computed geographic coordinates, centroid locations, and hectare-scale area measurements.
- Interactive Split Slider: Real-time before/after satellite composite inspection with interactive wipe-slider comparisons.
- Chronological Change Timeline: Visualizes historical NDVI progression, event severity, and state transitions over the selected observation window.
- Grounded AI Synthesis: Generates structured executive summaries detailing key findings, critical zones, environmental impact, and verification steps based strictly on calculated metrics.
- Executive Report Generation: Exports standalone, publication-ready HTML environmental audit reports containing executive summaries, KPI breakdown tables, change catalogs, and verification recommendations.
- Resilient Fallback Mode: Gracefully transitions to offline benchmark datasets when backend services or satellite APIs are unreachable.
forestguard/
โโโ src/ # Frontend (Next.js 16 + React 19 + MapLibre GL)
โ โโโ app/ # App Router (Landing, /monitor, /cases)
โ โโโ components/ # Analysis controls, map viewers, split-screens, reports
โ โโโ lib/ # API client, domain adapters, context, mocks
โโโ backend/ # Backend (FastAPI + Pydantic v2 + Geospatial Pipeline)
โโโ app/
โ โโโ api/ # REST endpoints (health, analyses, reports)
โ โโโ services/ # Spectral indices, change detection, vectorization, AI
โ โโโ schemas/ # Pydantic DTO models
โโโ tests/ # Pytest suite for API & change detection algorithms
- Framework: Next.js (App Router, Turbopack)
- Styling: Tailwind CSS
- Maps: MapLibre GL
- Icons: Lucide React
- Framework: FastAPI (Python 3.10+)
- Validation: Pydantic v2
- Geospatial Processing: NumPy, SciPy (
ndimage.label), Shapely - Satellite Provider: Google Earth Engine (Sentinel-2 SR Harmonized) with built-in offline synthetic provider (
MockSatelliteProvider)
- Node.js: v18.17+ or v20+
- Python: v3.10+
- npm or pnpm / yarn
-
Navigate to the
backenddirectory:cd backend -
Create and activate a Python virtual environment:
# Linux / macOS python -m venv .venv source .venv/bin/activate # Windows (PowerShell) python -m venv .venv .venv\Scripts\Activate.ps1
-
Install backend dependencies:
pip install -e . -
Configure environment variables (optional for local testing; defaults to mock provider):
# Windows PowerShell: Copy-Item .env.example .env # Linux / macOS: cp .env.example .env
-
Start the FastAPI development server:
uvicorn app.main:app --reload --port 8000
Backend is available at http://localhost:8000 (Interactive Swagger docs: http://localhost:8000/docs)
-
Open a new terminal in the repository root:
# Install dependencies npm install -
(Optional) Verify frontend environment variable in
.env.local:NEXT_PUBLIC_API_URL=http://localhost:8000
-
Start the Next.js development server:
npm run dev
Frontend is available at http://localhost:3000
- Open
http://localhost:3000and click "Launch Monitor" or navigate directly to/monitor.
- Quick Benchmark: Click one of the benchmark site buttons:
- ๐ฒ Amazon (Deforestation in Para, Brazil)
- ๐ง Reservoir (Elephant Butte water loss, NM)
- ๐๏ธ Urban (Suburban expansion in Austin, TX)
- Custom Area: Click "Draw Polygon on Map" and click on the map canvas to construct a custom boundary. Double-click or click the first point to close the polygon.
- Select the Baseline (Before) observation date window (e.g.
2025-03-01to2025-03-31). - Select the Target Observation (After) date window (e.g.
2026-08-01to2026-08-31).
- Toggle desired environmental change layers:
- ๐ฒ Forest Loss (NDVI anomaly)
- ๐ง Water Loss (MNDWI reduction)
- ๐๏ธ Built / Bare (NDBI expansion)
- ๐ฃ๏ธ Road / Mining (SWIR linear features)
- Click "Run Environmental Analysis".
- Watch the live step-by-step pipeline progress:
- Acquiring satellite imagery
- Removing cloud contamination
- Generating spectral indices
- Comparing temporal imagery
- Classifying environmental changes
- Mapping change regions
- Change Hotspots: Click individual polygons on the map or in the change catalog to zoom to the hotspot, inspect change magnitude, and view spectral delta scores.
- Before / After Slider: Toggle the Split-Screen Comparison tab to drag the interactive wipe-slider over satellite composites.
- Observation Timeline: Inspect temporal NDVI trajectories and status milestones.
- AI Summary: Review auto-generated impact assessments, critical vulnerability zones, and validation notes.
- Export Audit Report: Click "Generate Report" to produce an executive HTML report with summary stats and change tables.
cd backend
python -m pytest tests/ -vnpm run build| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
postgresql://... |
Database connection string |
SATELLITE_PROVIDER |
mock |
mock for local synthetic data, or earthengine |
EARTHENGINE_PROJECT |
"" |
Google Earth Engine project ID |
EARTHENGINE_SERVICE_ACCOUNT |
"" |
Service account email for GEE |
EARTHENGINE_PRIVATE_KEY |
"" |
Service account private key |
LLM_API_KEY |
"" |
OpenAI / LLM API key for summaries |
LLM_BASE_URL |
https://api.openai.com/v1 |
LLM endpoint URL |
LLM_MODEL |
gpt-4-turbo |
LLM model identifier |
| Variable | Default | Description |
|---|---|---|
NEXT_PUBLIC_API_URL |
http://localhost:8000 |
Backend API base URL |
Distributed under the MIT License. See LICENSE for details.