# devp19/hotspots-ai architecture

> Architecture diagram of the GitHub repository devp19/hotspots-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devp19/hotspots-ai
- Repository: https://github.com/devp19/hotspots-ai

## Overview

##### Project type and purpose
- This is a full-stack geospatial AI application (“HotSpots-AI”) for computing tree-vulnerability hotspots from satellite imagery (NDVI, LST) and visualizing them in a web UI.
- The frontend is built in Next.js/React (components under HotSpots-AI/src), while data-processing and modeling are done via Python and Node scripts.

##### File structure
- Top-level directories:
- HotSpots-AI/ — the Next.js application and data pipelines
- model/ — standalone Python ML model and vulnerability-index scripts
- node_modules/ (supporting the root package.json)
- Under HotSpots-AI/:
- data/ — raw geospatial assets (toronto_ndvi.tif, toronto_lst.tif) & ndvi_points.csv
- compute_tree_priority.py, generate_samples.py — Python data-prep scripts
- tuneWeightsGemini.js, tuneWeights.js — Node scripts to adjust model weights
- public/ — output GeoJSON (tree_priority.geojson, vulnerability_points.geojson) and fonts
- src/ — Next.js pages and components (UI, MagicUI animations, chart & card components)
- next.config.ts, tsconfig.json, package.json, postcss.config.mjs — configuration for the build/deploy
- model/:
- rf_model.py — Random Forest model
- vulnerability_index.py — computes vulnerability scores
- tuneWeights.js — JavaScript weight-tuning utilities

##### README for additional insights
- While the README contains screenshots, the lack of text means we rely on file names and directory patterns to infer the architecture and data flows.

##### Elements
- Clear labels: “Raw TIFF/CSV” → “Data-Prep Scripts” → “RF Model” → “Weight-Tuning” → “GeoJSON Outputs” → “Next.js Frontend” → “Browser”
- Blue rectangles for code modules (Python, Node, Next.js)
- Orange for the Browser/UI layer

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Data Processing Layer
  subgraph "Data Processing Layer"
    direction TB
    subgraph "Raw Geospatial Data" 
      direction TB
      NDVI[(toronto_ndvi.tif)]:::data
      LST[(toronto_lst.tif)]:::data
      CSV[(ndvi_points.csv)]:::data
    end

    subgraph "Data Ingestion & Preprocessing" 
      direction TB
      Compute["compute_tree_priority.py"]:::code
      Generate["generate_samples.py"]:::code
    end

    subgraph "Machine Learning Model" 
      direction TB
      RF["rf_model.py"]:::code
      Vulnerability["vulnerabilty_index.py"]:::code
    end

    subgraph "Weight-Tuning Services"
      direction TB
      Gemini["tuneWeightsGemini.js"]:::code
      TuneModel["tuneWeights.js"]:::code
    end

    subgraph "GeoJSON Output Storage"
      direction TB
      TreeGeo[(tree_priority.geojson)]:::data
      VulnerGeo[(vulnerability_points.geojson)]:::data
    end
  end

  %% Presentation Layer
  subgraph "Presentation Layer"
    direction TB
    subgraph "Next.js Frontend"
      direction TB
      Layout["layout.tsx"]:::frontend
      PageHome["page.tsx"]:::frontend
      PageVisualize["visualize/page.tsx"]:::frontend
      Card["card.tsx"]:::frontend
      Chart["chart.tsx"]:::frontend
      Rainbow["rainbow-button.tsx"]:::frontend
      MagicUI["magicui components"]:::frontend
      Utils["utils.ts"]:::frontend
    end
    Browser[(User Browser)]:::ui
  end

  %% Connections
  NDVI -->|reads| Compute
  LST -->|reads| Compute
  CSV -->|reads| Generate
  Compute -->|produces intermediate| RF
  Generate -->|produces intermediate| RF
  RF -->|calls| Vulnerability
  Gemini -->|adjusts weights of| RF
  TuneModel -->|adjusts weights of| RF
  Vulnerability -->|outputs| TreeGeo
  Vulnerability -->|outputs| VulnerGeo
  TreeGeo -->|served by| Layout
  VulnerGeo -->|served by| Layout
  Layout -->|renders| PageHome
  Layout -->|renders| PageVisualize
  PageVisualize -->|uses| Card
  PageVisualize -->|uses| Chart
  PageVisualize -->|uses| Rainbow
  PageVisualize -->|uses| MagicUI
  PageVisualize -->|uses| Utils
  PageHome -->|viewed in| Browser
  PageVisualize -->|viewed in| Browser

  %% Click Events
  click Compute "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/compute_tree_priority.py"
  click Generate "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/generate_samples.py"
  click NDVI "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/data/toronto_ndvi.tif"
  click LST "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/data/toronto_lst.tif"
  click CSV "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/data/ndvi_points.csv"
  click RF "https://github.com/devp19/hotspots-ai/blob/main/model/rf_model.py"
  click Vulnerability "https://github.com/devp19/hotspots-ai/blob/main/model/vulnerabilty_index.py"
  click Gemini "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/tuneWeightsGemini.js"
  click TuneModel "https://github.com/devp19/hotspots-ai/blob/main/model/tuneWeights.js"
  click TreeGeo "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/public/tree_priority.geojson"
  click VulnerGeo "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/public/vulnerability_points.geojson"
  click Layout "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/src/app/layout.tsx"
  click PageHome "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/src/app/page.tsx"
  click PageVisualize "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/src/app/visualize/page.tsx"
  click Card "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/src/components/ui/card.tsx"
  click Chart "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/src/components/ui/chart.tsx"
  click Rainbow "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/src/app/magicui/rainbow-button.tsx"
  click MagicUI "https://github.com/devp19/hotspots-ai/tree/main/HotSpots-AI/src/components/magicui"
  click Utils "https://github.com/devp19/hotspots-ai/blob/main/HotSpots-AI/src/lib/utils.ts"

  %% Styles
  classDef code fill:#CFE2F3,stroke:#031A6B,color:#031A6B
  classDef data fill:#DFF2BF,stroke:#4F8A10,color:#4F8A10
  classDef frontend fill:#FCE5CD,stroke:#9C6500,color:#9C6500
  classDef ui fill:#FED9A6,stroke:#B45F06,color:#B45F06
```
