# kanglesoham11-code/pccoe_hackathon architecture

> Architecture diagram of the GitHub repository kanglesoham11-code/pccoe_hackathon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kanglesoham11-code/pccoe_hackathon
- Repository: https://github.com/kanglesoham11-code/pccoe_hackathon

## Overview

Crop Stress Detection combines a geospatial preparation pipeline, a browser-based field viewer, and crop-photo stress investigation. The main field workflow loads grid and terrain data through the API, then lets users inspect cells and visualize satellite, NDVI, terrain, and stress layers. The crop workflow supports photo-based assessment and interactive diagnostic investigations through backend endpoints. The README documents raster-to-grid processing and its scientific caveat: measurements are observations, not diagnoses. Some pipeline and frontend integrations are represented from documentation or indexes because their source was not excerpted.

Main entry points: [`frontend/src/pages/LandInspectionPage.tsx`](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/pages/LandInspectionPage.tsx) (Land Inspection), [`frontend/src/components/ThreeCanvas.tsx`](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/ThreeCanvas.tsx) (3D Field Canvas), [`backend/server.py`](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/backend/server.py) (Application API), [`scripts/03_download_sentinel.py`](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/03_download_sentinel.py) (Imagery Download)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Field and Crop UI"]
  node_app["App Router<br/>[App.tsx]"]
  node_land["Land Inspection"]
  node_crop["Crop Inspection"]
  node_canvas["3D Field Canvas<br/>[ThreeCanvas.tsx]"]
  node_scene["Terrain Scene<br/>[TerrainScene.ts]"]
  node_crop_render["Crop Renderer<br/>[CropRenderer.ts]"]
  node_stress_layer["Stress Layer<br/>[StressRiskLayer.ts]"]
  node_grid_overlay["Grid Overlay<br/>[GridOverlay.ts]"]
  node_cell_inspector["Cell Inspector<br/>[CellInspector.tsx]"]
  node_layer_toggle["Layer Controls<br/>[LayerToggle.tsx]"]
  node_info_panel["Field Information<br/>[InfoPanel.tsx]"]
  node_stress_panel["Stress Analysis"]
  node_wav["Voice Recorder<br/>[wavRecorder.ts]"]
end

subgraph group_api["Application Services"]
  node_server["Application API<br/>[server.py]"]
  node_diagnostics["Diagnostic Engine"]
  node_grid_store[("Processed Grid Data<br/>[server.py]")]
end

subgraph group_geo["Geospatial Pipeline"]
  node_download["Imagery Download"]
  node_ndvi["NDVI Calculation"]
  node_dem_download["Elevation Download<br/>[05_download_dem.py]"]
  node_terrain["Terrain Derivation"]
  node_grid["Grid Construction<br/>[07_create_grid.py]"]
  node_intelligence["Stress Enrichment"]
end

subgraph group_config["Configuration and Access"]
  node_settings["Pipeline Settings<br/>[settings.py]"]
  node_auth["Copernicus OAuth<br/>[auth.py]"]
end

node_farmer(("Farmer / Agronomist"))
node_groq{{"Groq API"}}
node_sarvam{{"Sarvam Speech API"}}
node_sentinel[("Sentinel-2 Imagery")]
node_dem[("Copernicus DEM")]

node_farmer -->|"uses"| node_app
node_app -->|"fetches grid and terrain"| node_server
node_server -->|"reads processed data"| node_grid_store
node_app -->|"routes to"| node_land
node_app -->|"routes to"| node_crop
node_land -->|"renders"| node_canvas
node_land -->|"renders"| node_cell_inspector
node_land -->|"renders"| node_layer_toggle
node_land -->|"renders"| node_info_panel
node_land -->|"renders"| node_stress_panel
node_canvas -->|"creates"| node_scene
node_canvas -->|"uses"| node_crop_render
node_canvas -->|"uses"| node_stress_layer
node_canvas -->|"uses"| node_grid_overlay
node_crop -->|"records audio"| node_wav
node_crop -.->|"requests investigations"| node_server
node_server -->|"starts investigations"| node_diagnostics
node_diagnostics -.->|"requests language assistance"| node_groq
node_server -->|"sends speech requests"| node_sarvam
node_settings -->|"provides credentials"| node_auth
node_download -->|"gets access token"| node_auth
node_download -->|"uses settings"| node_settings
node_download -->|"downloads imagery"| node_sentinel
node_dem_download -->|"downloads elevation"| node_dem
node_download -->|"provides imagery"| node_ndvi
node_ndvi -.->|"provides raster basis"| node_terrain
node_dem_download -.->|"provides elevation"| node_terrain
node_terrain -->|"provides terrain measures"| node_grid
node_ndvi -->|"defines grid template"| node_grid
node_grid -->|"produces grid layers"| node_grid_store
node_grid -.->|"enriches grid"| node_intelligence

click node_app "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/App.tsx"
click node_land "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/pages/LandInspectionPage.tsx"
click node_crop "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/pages/CropInspectionPage.tsx"
click node_canvas "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/ThreeCanvas.tsx"
click node_scene "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/three/TerrainScene.ts"
click node_crop_render "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/three/CropRenderer.ts"
click node_stress_layer "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/three/StressRiskLayer.ts"
click node_grid_overlay "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/three/GridOverlay.ts"
click node_cell_inspector "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/CellInspector.tsx"
click node_layer_toggle "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/LayerToggle.tsx"
click node_info_panel "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/InfoPanel.tsx"
click node_stress_panel "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/StressAnalysisPanel.tsx"
click node_wav "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/utils/wavRecorder.ts"
click node_server "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/backend/server.py"
click node_diagnostics "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/backend/diagnostic_engine.py"
click node_grid_store "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/backend/server.py"
click node_settings "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/config/settings.py"
click node_auth "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/src/auth.py"
click node_download "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/03_download_sentinel.py"
click node_ndvi "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/04_calculate_ndvi.py"
click node_dem_download "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/05_download_dem.py"
click node_terrain "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/06_calculate_terrain.py"
click node_grid "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/07_create_grid.py"
click node_intelligence "https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/10_intelligence_engine.py"

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_app,node_land,node_crop,node_canvas,node_scene,node_crop_render,node_stress_layer,node_grid_overlay,node_cell_inspector,node_layer_toggle,node_info_panel,node_stress_panel,node_wav toneBlue
class node_server,node_diagnostics,node_grid_store,node_sentinel,node_dem toneAmber
class node_download,node_ndvi,node_dem_download,node_terrain,node_grid,node_intelligence,node_groq,node_sarvam toneMint
class node_settings,node_auth toneRose
class node_farmer toneIndigo
```

## Components

### Field and Crop UI

- [App Router](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Land Inspection](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/pages/LandInspectionPage.tsx): `frontend/src/pages/LandInspectionPage.tsx`
- [Crop Inspection](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/pages/CropInspectionPage.tsx): `frontend/src/pages/CropInspectionPage.tsx`
- [3D Field Canvas](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/ThreeCanvas.tsx): `frontend/src/components/ThreeCanvas.tsx`
- [Terrain Scene](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/three/TerrainScene.ts): `frontend/src/three/TerrainScene.ts`
- [Crop Renderer](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/three/CropRenderer.ts): `frontend/src/three/CropRenderer.ts`
- [Stress Layer](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/three/StressRiskLayer.ts): `frontend/src/three/StressRiskLayer.ts`
- [Grid Overlay](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/three/GridOverlay.ts): `frontend/src/three/GridOverlay.ts`
- [Cell Inspector](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/CellInspector.tsx): `frontend/src/components/CellInspector.tsx`
- [Layer Controls](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/LayerToggle.tsx): `frontend/src/components/LayerToggle.tsx`
- [Field Information](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/InfoPanel.tsx): `frontend/src/components/InfoPanel.tsx`
- [Stress Analysis](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/components/StressAnalysisPanel.tsx): `frontend/src/components/StressAnalysisPanel.tsx`
- [Voice Recorder](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/frontend/src/utils/wavRecorder.ts): `frontend/src/utils/wavRecorder.ts`

### Application Services

- [Application API](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/backend/server.py): `backend/server.py`
- [Diagnostic Engine](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/backend/diagnostic_engine.py): `backend/diagnostic_engine.py`
- [Processed Grid Data](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/backend/server.py): `backend/server.py`

### Geospatial Pipeline

- [Imagery Download](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/03_download_sentinel.py): `scripts/03_download_sentinel.py`
- [NDVI Calculation](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/04_calculate_ndvi.py): `scripts/04_calculate_ndvi.py`
- [Elevation Download](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/05_download_dem.py): `scripts/05_download_dem.py`
- [Terrain Derivation](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/06_calculate_terrain.py): `scripts/06_calculate_terrain.py`
- [Grid Construction](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/07_create_grid.py): `scripts/07_create_grid.py`
- [Stress Enrichment](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/scripts/10_intelligence_engine.py): `scripts/10_intelligence_engine.py`

### Configuration and Access

- [Pipeline Settings](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/config/settings.py): `config/settings.py`
- [Copernicus OAuth](https://github.com/kanglesoham11-code/pccoe_hackathon/blob/main/src/auth.py): `src/auth.py`

### Other components

- **Farmer / Agronomist**
- **Groq API**
- **Sarvam Speech API**
- **Sentinel-2 Imagery**
- **Copernicus DEM**

## Connections

- Farmer / Agronomist → App Router: uses
- App Router → Application API: fetches grid and terrain (evidence: `frontend/src/App.tsx`)
- Application API → Processed Grid Data: reads processed data (evidence: `backend/server.py`)
- App Router → Land Inspection: routes to (evidence: `frontend/src/App.tsx`)
- App Router → Crop Inspection: routes to (evidence: `frontend/src/App.tsx`)
- Land Inspection → 3D Field Canvas: renders (evidence: `frontend/src/pages/LandInspectionPage.tsx`)
- Land Inspection → Cell Inspector: renders (evidence: `frontend/src/pages/LandInspectionPage.tsx`)
- Land Inspection → Layer Controls: renders (evidence: `frontend/src/pages/LandInspectionPage.tsx`)
- Land Inspection → Field Information: renders (evidence: `frontend/src/pages/LandInspectionPage.tsx`)
- Land Inspection → Stress Analysis: renders (evidence: `frontend/src/pages/LandInspectionPage.tsx`)
- 3D Field Canvas → Terrain Scene: creates (evidence: `frontend/src/components/ThreeCanvas.tsx`)
- 3D Field Canvas → Crop Renderer: uses (evidence: `frontend/src/components/ThreeCanvas.tsx`)
- 3D Field Canvas → Stress Layer: uses (evidence: `frontend/src/components/ThreeCanvas.tsx`)
- 3D Field Canvas → Grid Overlay: uses (evidence: `frontend/src/components/ThreeCanvas.tsx`)
- Crop Inspection → Voice Recorder: records audio (evidence: `frontend/src/pages/CropInspectionPage.tsx`)
- Crop Inspection → Application API: requests investigations
- Application API → Diagnostic Engine: starts investigations (evidence: `backend/server.py`)
- Diagnostic Engine → Groq API: requests language assistance
- Application API → Sarvam Speech API: sends speech requests (evidence: `backend/server.py`)
- Pipeline Settings → Copernicus OAuth: provides credentials (evidence: `src/auth.py`)
- Imagery Download → Copernicus OAuth: gets access token (evidence: `scripts/03_download_sentinel.py`)
- Imagery Download → Pipeline Settings: uses settings (evidence: `scripts/03_download_sentinel.py`)
- Imagery Download → Sentinel-2 Imagery: downloads imagery
- Elevation Download → Copernicus DEM: downloads elevation
- Imagery Download → NDVI Calculation: provides imagery
- NDVI Calculation → Terrain Derivation: provides raster basis
- Elevation Download → Terrain Derivation: provides elevation
- Terrain Derivation → Grid Construction: provides terrain measures
- NDVI Calculation → Grid Construction: defines grid template
- Grid Construction → Processed Grid Data: produces grid layers
- Grid Construction → Stress Enrichment: enriches grid
