# nikhil-patyal/thermal architecture

> Architecture diagram of the GitHub repository nikhil-patyal/thermal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikhil-patyal/thermal
- Repository: https://github.com/nikhil-patyal/thermal

## Overview

AGNI-DRISHTI ingests NASA FIRMS thermal detections, enriches hotspots with geographic and exposure context, classifies them using spatial evidence, and presents results through an interactive map and event dossier. The README emphasizes India-focused PostGIS facility footprints and deterministic evidence labels. The graph follows the sampled pipeline and frontend data-fetch path; unsampled views and dossier tabs are represented by their exact enclosing source paths, but uncertain internal calls are omitted.

Main entry points: [`backend/run_full_pipeline.py`](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/run_full_pipeline.py) (Pipeline runner), [`backend/hotspots/tasks.py`](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/tasks.py) (FIRMS ingestion), [`backend/hotspots/batch_enrich.py`](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/batch_enrich.py) (Batch enrichment), [`backend/hotspots/batch_classify.py`](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/batch_classify.py) (Batch classification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Detection and geography"]
  node_pipeline["Pipeline runner"]
  node_fetch["FIRMS ingestion<br/>[tasks.py]"]
  node_osm["OSM footprint import"]
  node_facilities[("Facility candidates<br/>[models.py]")]
end

subgraph group_analysis["Enrichment and classification"]
  node_enrich["Batch enrichment<br/>[batch_enrich.py]"]
  node_geo["Geographic context<br/>[services.py]"]
  node_classify["Batch classification<br/>[batch_classify.py]"]
  node_features["Feature extraction"]
  node_evidence["Spatial evidence<br/>[evidence_engine.py]"]
end

subgraph group_service["Backend services"]
  node_hotspots[("Hotspot records<br/>[models.py]")]
  node_api["Hotspot API<br/>[views.py]"]
  node_imagery_api["Imagery API<br/>[views.py]"]
end

subgraph group_client["Map and investigation"]
  node_app["Application shell<br/>[App.tsx]"]
  node_data_hook["Thermal data hook<br/>[useThermalData.ts]"]
  node_map["Intelligence map<br/>[Map.tsx]"]
  node_dossier["Event dossier<br/>[EventDossier.tsx]"]
  node_tabs["Analysis tabs<br/>[AIAnalysis.tsx]"]
end

node_operator(("Pipeline operator"))
node_firms{{"NASA FIRMS"}}
node_sentinel{{"Copernicus imagery"}}
node_mapillary{{"Mapillary photos"}}
node_browser(("Analyst"))

node_operator -->|"runs"| node_pipeline
node_pipeline -->|"calls fetch"| node_fetch
node_pipeline -->|"calls enrich"| node_enrich
node_pipeline -->|"calls classify"| node_classify
node_fetch -->|"requests detections"| node_firms
node_fetch -->|"stores detections"| node_hotspots
node_osm -->|"loads footprints"| node_facilities
node_enrich -->|"enriches records"| node_hotspots
node_enrich -->|"requests context"| node_geo
node_geo -->|"queries nearby"| node_facilities
node_classify -->|"extracts features"| node_features
node_features -->|"reads hotspot data"| node_hotspots
node_features -->|"extracts context"| node_geo
node_classify -->|"generates labels"| node_evidence
node_evidence -->|"checks overlap"| node_facilities
node_browser -->|"opens"| node_app
node_app -->|"renders"| node_map
node_map -->|"loads data"| node_data_hook
node_data_hook -->|"fetches hotspots"| node_api
node_app -->|"opens selected event"| node_dossier
node_dossier -->|"presents analysis"| node_tabs
node_browser -.->|"requests imagery"| node_imagery_api
node_imagery_api -.->|"fetches scenes"| node_sentinel
node_imagery_api -.->|"searches photos"| node_mapillary

click node_pipeline "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/run_full_pipeline.py"
click node_fetch "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/tasks.py"
click node_hotspots "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/models.py"
click node_osm "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/import_india_osm.py"
click node_facilities "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/models.py"
click node_enrich "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/batch_enrich.py"
click node_geo "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/geography/services.py"
click node_classify "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/batch_classify.py"
click node_features "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/ml/feature_engineering.py"
click node_evidence "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/ml/evidence_engine.py"
click node_api "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/views.py"
click node_imagery_api "https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/satellite_imagery/views.py"
click node_app "https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/App.tsx"
click node_data_hook "https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/hooks/useThermalData.ts"
click node_map "https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/components/Map.tsx"
click node_dossier "https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/components/events/EventDossier.tsx"
click node_tabs "https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/components/events/tabs/AIAnalysis.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pipeline,node_fetch,node_osm,node_facilities toneBlue
class node_enrich,node_geo,node_classify,node_features,node_evidence toneAmber
class node_hotspots,node_api,node_imagery_api,node_mapillary toneMint
class node_app,node_data_hook,node_map,node_dossier,node_tabs toneRose
class node_operator,node_firms,node_sentinel,node_browser toneIndigo
```

## Components

### Detection and geography

- [Pipeline runner](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/run_full_pipeline.py): `backend/run_full_pipeline.py`
- [FIRMS ingestion](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/tasks.py): `backend/hotspots/tasks.py`
- [OSM footprint import](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/import_india_osm.py): `backend/import_india_osm.py`
- [Facility candidates](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/models.py): `backend/hotspots/models.py`

### Enrichment and classification

- [Batch enrichment](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/batch_enrich.py): `backend/hotspots/batch_enrich.py`
- [Geographic context](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/geography/services.py): `backend/geography/services.py`
- [Batch classification](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/batch_classify.py): `backend/hotspots/batch_classify.py`
- [Feature extraction](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/ml/feature_engineering.py): `backend/ml/feature_engineering.py`
- [Spatial evidence](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/ml/evidence_engine.py): `backend/ml/evidence_engine.py`

### Backend services

- [Hotspot records](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/models.py): `backend/hotspots/models.py`
- [Hotspot API](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/hotspots/views.py): `backend/hotspots/views.py`
- [Imagery API](https://github.com/nikhil-patyal/thermal/blob/nikhil/backend/satellite_imagery/views.py): `backend/satellite_imagery/views.py`

### Map and investigation

- [Application shell](https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Thermal data hook](https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/hooks/useThermalData.ts): `frontend/src/hooks/useThermalData.ts`
- [Intelligence map](https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/components/Map.tsx): `frontend/src/components/Map.tsx`
- [Event dossier](https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/components/events/EventDossier.tsx): `frontend/src/components/events/EventDossier.tsx`
- [Analysis tabs](https://github.com/nikhil-patyal/thermal/blob/nikhil/frontend/src/components/events/tabs/AIAnalysis.tsx): `frontend/src/components/events/tabs/AIAnalysis.tsx`

### Other components

- **Pipeline operator**
- **NASA FIRMS**
- **Copernicus imagery**
- **Mapillary photos**
- **Analyst**

## Connections

- Pipeline operator → Pipeline runner: runs
- Pipeline runner → FIRMS ingestion: calls fetch
- Pipeline runner → Batch enrichment: calls enrich
- Pipeline runner → Batch classification: calls classify
- FIRMS ingestion → NASA FIRMS: requests detections
- FIRMS ingestion → Hotspot records: stores detections
- OSM footprint import → Facility candidates: loads footprints
- Batch enrichment → Hotspot records: enriches records
- Batch enrichment → Geographic context: requests context
- Geographic context → Facility candidates: queries nearby
- Batch classification → Feature extraction: extracts features
- Feature extraction → Hotspot records: reads hotspot data
- Feature extraction → Geographic context: extracts context
- Batch classification → Spatial evidence: generates labels
- Spatial evidence → Facility candidates: checks overlap
- Analyst → Application shell: opens
- Application shell → Intelligence map: renders
- Intelligence map → Thermal data hook: loads data
- Thermal data hook → Hotspot API: fetches hotspots
- Application shell → Event dossier: opens selected event
- Event dossier → Analysis tabs: presents analysis
- Analyst → Imagery API: requests imagery
- Imagery API → Copernicus imagery: fetches scenes
- Imagery API → Mapillary photos: searches photos
