How spiritussanctiswoyam/terra-pulse works
Purpose and entry points
Terra Pulse is a satellite-based disaster damage assessment system focused on flood inundation. Its two operational entry points are the Python batch pipeline at pipeline/run_all.py and the React/Vite dashboard at src/main.jsx; pipeline/server.py optionally exposes pipeline results locally. Production frontend deployment is configured by vercel.json.
Satellite ingestion boundary
pipeline/fetch_data.py retrieves pre- and post-event Sentinel-2 L2A imagery from the Microsoft Planetary Computer STAC API. It produces GeoTIFF inputs such as data/before.tif and data/after.tif. This is the principal external-data boundary: remote catalog/search and raster asset access are isolated from downstream analysis.
Raster change-detection stage
pipeline/ndwi.py calculates Normalized Difference Water Index values from Green and NIR raster bands for both time periods, then differences them to identify likely new water coverage. Generated intermediates include output/ndwi_before.tif, output/ndwi_after.tif, and output/delta_ndwi.tif. Rasterio/Numpy operate over pixel data; GeoTIFF files are the contract between ingestion and scoring.
Severity classification and spatial aggregation
pipeline/severity.py and pipeline/severity_real.py convert NDWI-change evidence into severity values and grid-level records. The resulting JSON artifacts, notably output/severity_grid.json and output/severity_base.json, form the structured assessment boundary consumed by prioritization and presentation. schema/severity_schema.json defines the intended severity-record shape.
Priority scoring
pipeline/prioritize.py combines modeled severity with population density and critical-infrastructure factors into response priority scores. This stage transforms physical change detection into dispatch-oriented rankings. pipeline/run_all.py orchestrates the end-to-end fetch → NDWI → severity → prioritization workflow and writes presentation-ready grid data such as output/ndwi_grid.json and output/severity_grid.json.
API and artifact serving
pipeline/server.py is a Flask-based optional local API layer, with Flask-CORS intended to allow the browser client to retrieve generated data across origins. The repository also carries static/demo data at pipeline/static/demo_grid.json, while frontend-bundled copies exist at src/data/severity_grid.json and src/data/dummyZones.json. These support dashboard operation when the live local pipeline/API is unavailable.
Dashboard application
The Vite React SPA starts from src/main.jsx, with application composition in src/App.jsx. Page-level navigation is organized in src/pages/Home.jsx, src/pages/Dashboard.jsx, and src/pages/Details.jsx. The dashboard is a decision interface rather than part of the ML pipeline: it renders and explains already-generated severity/priority records.
Geospatial decision UI
src/components/MapView.jsx is the core operational visualization boundary, using React Leaflet for map and spatial display. src/components/Sidebar.jsx, src/components/RecommendationCard.jsx, and src/components/ActivationDetails.jsx turn selected zones and scores into recommended response actions. Supporting alert/navigation elements include src/components/AlertBanner.jsx and src/components/TopNav.jsx. The frontend is deployed to Vercel, while live satellite processing remains a separately run Python workload.
Main entry points: run_all.py Batch workflow · severity.py Severity aggregation · delta_ndwi.tif NDWI GeoTIFFs · Dashboard.jsx Dashboard pages
Components 21
Assessment Pipeline
Python batch workflow that produces flood assessment artifacts.
- Planetary Computer STAC · Sentinel-2 L2A catalog and raster asset boundary.
- Satellite ingestion · Retrieves pre- and post-event Sentinel-2 imagery.
pipeline/fetch_data.py - NDWI change detection · Computes water-index change from Green and NIR bands.
pipeline/ndwi.py - Severity aggregation · Converts NDWI evidence into grid-level severity records.
pipeline/severity.py - Real severity variant · Alternate severity-record generation path.
pipeline/severity_real.py - Response prioritization · Combines severity, population, and infrastructure factors.
pipeline/prioritize.py - Batch workflow · Runs fetch through prioritization end to end.
pipeline/run_all.py
Data Contracts
Raster and JSON artifacts passed between processing stages.
- Before / after GeoTIFFs · Examples include data/before.tif and data/after.tif.
data/before.tif - NDWI GeoTIFFs · Before, after, and delta NDWI rasters.
output/delta_ndwi.tif - Severity record schema · Defines the intended severity-record shape.
schema/severity_schema.json - Severity JSON · Includes severity_base.json and severity_grid.json.
output/severity_grid.json - Presentation grid JSON · Includes NDWI and severity grid outputs.
output/ndwi_grid.json
Local Serving
Optional local access to generated results.
- Local results API · Optionally serves generated artifacts with CORS.
pipeline/server.py - Demo grid data · Pipeline-side static dashboard fallback.
pipeline/static/demo_grid.json
Decision Dashboard
React application for reviewing response priorities.
- React/Vite entry · Bootstraps the dashboard application.
src/main.jsx - Dashboard application · Composes home, dashboard, and details navigation.
src/App.jsx - Dashboard pages · Home, Dashboard, and Details decision views.
src/pages/Dashboard.jsx - Geospatial decision UI · Displays zones and spatial assessment data.
src/components/MapView.jsx - Response recommendations · Turns selected zones and scores into recommended actions.
src/components/RecommendationCard.jsx - Bundled fallback data · Used when the live local pipeline/API is unavailable.
src/data/severity_grid.json - Vercel deployment · Deploys the Vite React dashboard.
vercel.json
Connections 24
- Planetary Computer STAC → Satellite ingestion: catalog search and assets
- Satellite ingestion → Before / after GeoTIFFs: writes imagery
- Before / after GeoTIFFs → NDWI change detection: reads bands
- NDWI change detection → NDWI GeoTIFFs: writes NDWI change
- NDWI GeoTIFFs → Severity aggregation: classifies evidence
- NDWI GeoTIFFs → Real severity variant: alternate classification
- Severity record schema → Severity aggregation: record contract
- Severity aggregation → Severity JSON: writes grid records
- Real severity variant → Severity JSON: writes alternate records
- Severity JSON → Response prioritization: severity input
- Response prioritization → Presentation grid JSON: writes ranked grids
- Batch workflow → Satellite ingestion: orchestrates
- Batch workflow → NDWI change detection: orchestrates
- Batch workflow → Severity aggregation: orchestrates
- Batch workflow → Response prioritization: orchestrates
- Presentation grid JSON → Local results API: served results
- Demo grid data → Local results API: demo fallback
- React/Vite entry → Dashboard application: boots
- Dashboard application → Dashboard pages: navigates
- Dashboard pages → Geospatial decision UI: renders dashboard map
- Dashboard pages → Response recommendations: renders actions
- Local results API → Geospatial decision UI: live assessment data
- Bundled fallback data → Geospatial decision UI: offline fallback
- React/Vite entry → Vercel deployment: deployed as SPA