# himesh-mehta/geolens architecture

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

- Interactive diagram: https://gitdiagram.com/himesh-mehta/geolens
- Repository: https://github.com/himesh-mehta/geolens

## Overview

GeoLens is a web platform for satellite-based land-cover analysis across India. Users select an area or location, request Sentinel-2 analysis, and review classification, spectral indices, and reports; they can also compare periods, analyze uploaded imagery or shapefiles, and ask Orbit AI questions grounded in active results. The README documents these capabilities; sampled backend excerpts show Flask coordinating ML, imagery, and reasoning. Frontend service-to-page wiring and several upload workflows were not excerpted, so those connections are shown only where documented or evidenced.

Main entry points: [`backend/app.py`](https://github.com/himesh-mehta/geolens/blob/main/backend/app.py) (Flask API), [`frontend/lib/api-client.ts`](https://github.com/himesh-mehta/geolens/blob/main/frontend/lib/api-client.ts) (Backend API client), [`backend/ml_layer/model_service.py`](https://github.com/himesh-mehta/geolens/blob/main/backend/ml_layer/model_service.py) (Land-cover classifier), [`backend/gpt_oss_layer/reasoning_engine.py`](https://github.com/himesh-mehta/geolens/blob/main/backend/gpt_oss_layer/reasoning_engine.py) (Reasoning engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web experience"]
  node_web["Analysis workspace<br/>[page.tsx]"]
  node_comparison_ui["Period comparison<br/>[page.tsx]"]
  node_image_ui["Image analysis<br/>[page.tsx]"]
  node_shape_ui["Shapefile analysis<br/>[page.tsx]"]
  node_assistant_ui["Orbit assistant<br/>[ai-assistant.tsx]"]
  node_api_client["Backend API client<br/>[api-client.ts]"]
  node_analysis_service["Location analysis service"]
  node_comparison_service["Comparison service"]
end

subgraph group_backend["Analysis backend"]
  node_backend_app["Flask API<br/>[app.py]"]
  node_classifier["Land-cover classifier<br/>[model_service.py]"]
  node_vector_analysis["Vector analytics"]
end

subgraph group_sources["Earth observation sources"]
  node_gee["Earth Engine imagery<br/>[gee_source.py]"]
  node_sentinel["Sentinel data source<br/>[sentinel_source.py]"]
  node_isro["ISRO data source<br/>[isro_source.py]"]
end

subgraph group_insights["Interpretation and outputs"]
  node_visual_extractor["EO visual extractor"]
  node_image_generator["Imagery renderer<br/>[image_generator.py]"]
  node_vision_evaluator["Vision evaluator"]
  node_reasoning["Reasoning engine"]
  node_ai_service["Groq AI service<br/>[ai_service.py]"]
  node_prompt_templates["Prompt templates"]
end

node_user(("GeoLens user"))
node_groq(("Groq LLM"))
node_gee_service(("Google Earth Engine"))

node_user -->|"selects area"| node_web
node_web -.->|"requests analysis"| node_analysis_service
node_comparison_ui -.->|"requests comparison"| node_comparison_service
node_image_ui -.->|"uploads imagery"| node_api_client
node_shape_ui -.->|"uploads shapefile"| node_api_client
node_assistant_ui -.->|"asks question"| node_api_client
node_analysis_service -->|"requests data"| node_api_client
node_comparison_service -->|"requests change data"| node_api_client
node_api_client -.->|"sends REST requests"| node_backend_app
node_backend_app -->|"runs classification"| node_classifier
node_backend_app -.->|"dispatches analysis"| node_vector_analysis
node_backend_app -->|"extracts EO features"| node_visual_extractor
node_backend_app -->|"generates imagery"| node_image_generator
node_backend_app -->|"evaluates agreement"| node_vision_evaluator
node_backend_app -->|"requests reasoning"| node_reasoning
node_backend_app -->|"checks connectivity"| node_gee
node_classifier -->|"fetches features"| node_gee
node_gee -.->|"queries imagery"| node_gee_service
node_reasoning -->|"prepares response"| node_ai_service
node_reasoning -->|"uses prompts"| node_prompt_templates
node_ai_service -.->|"generates answer"| node_groq
node_classifier -.->|"uses observations"| node_sentinel
node_classifier -.->|"uses observations"| node_isro

click node_web "https://github.com/himesh-mehta/geolens/blob/main/frontend/app/explorer/page.tsx"
click node_comparison_ui "https://github.com/himesh-mehta/geolens/blob/main/frontend/app/compare/page.tsx"
click node_image_ui "https://github.com/himesh-mehta/geolens/blob/main/frontend/app/image-analysis/page.tsx"
click node_shape_ui "https://github.com/himesh-mehta/geolens/blob/main/frontend/app/shapefile-analysis/page.tsx"
click node_assistant_ui "https://github.com/himesh-mehta/geolens/blob/main/frontend/components/analysis/ai-assistant.tsx"
click node_api_client "https://github.com/himesh-mehta/geolens/blob/main/frontend/lib/api-client.ts"
click node_analysis_service "https://github.com/himesh-mehta/geolens/blob/main/frontend/services/analysis-service.ts"
click node_comparison_service "https://github.com/himesh-mehta/geolens/blob/main/frontend/services/comparison-service.ts"
click node_backend_app "https://github.com/himesh-mehta/geolens/blob/main/backend/app.py"
click node_gee "https://github.com/himesh-mehta/geolens/blob/main/backend/data_sources/gee_source.py"
click node_sentinel "https://github.com/himesh-mehta/geolens/blob/main/backend/data_sources/sentinel_source.py"
click node_isro "https://github.com/himesh-mehta/geolens/blob/main/backend/data_sources/isro_source.py"
click node_classifier "https://github.com/himesh-mehta/geolens/blob/main/backend/ml_layer/model_service.py"
click node_vector_analysis "https://github.com/himesh-mehta/geolens/blob/main/backend/ml_layer/shapefile_service.py"
click node_visual_extractor "https://github.com/himesh-mehta/geolens/blob/main/backend/vision_layer/visual_extractor.py"
click node_image_generator "https://github.com/himesh-mehta/geolens/blob/main/backend/vision_layer/image_generator.py"
click node_vision_evaluator "https://github.com/himesh-mehta/geolens/blob/main/backend/vision_layer/vision_evaluator.py"
click node_reasoning "https://github.com/himesh-mehta/geolens/blob/main/backend/gpt_oss_layer/reasoning_engine.py"
click node_ai_service "https://github.com/himesh-mehta/geolens/blob/main/backend/gpt_oss_layer/ai_service.py"
click node_prompt_templates "https://github.com/himesh-mehta/geolens/blob/main/backend/gpt_oss_layer/prompt_templates.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_web,node_comparison_ui,node_image_ui,node_shape_ui,node_assistant_ui,node_api_client,node_analysis_service,node_comparison_service,node_user toneBlue
class node_backend_app,node_classifier,node_vector_analysis toneAmber
class node_gee,node_sentinel,node_isro toneMint
class node_visual_extractor,node_image_generator,node_vision_evaluator,node_reasoning,node_ai_service,node_prompt_templates toneRose
class node_groq,node_gee_service toneIndigo
```

## Components

### Web experience

- [Analysis workspace](https://github.com/himesh-mehta/geolens/blob/main/frontend/app/explorer/page.tsx): `frontend/app/explorer/page.tsx`
- [Period comparison](https://github.com/himesh-mehta/geolens/blob/main/frontend/app/compare/page.tsx): `frontend/app/compare/page.tsx`
- [Image analysis](https://github.com/himesh-mehta/geolens/blob/main/frontend/app/image-analysis/page.tsx): `frontend/app/image-analysis/page.tsx`
- [Shapefile analysis](https://github.com/himesh-mehta/geolens/blob/main/frontend/app/shapefile-analysis/page.tsx): `frontend/app/shapefile-analysis/page.tsx`
- [Orbit assistant](https://github.com/himesh-mehta/geolens/blob/main/frontend/components/analysis/ai-assistant.tsx): `frontend/components/analysis/ai-assistant.tsx`
- [Backend API client](https://github.com/himesh-mehta/geolens/blob/main/frontend/lib/api-client.ts): `frontend/lib/api-client.ts`
- [Location analysis service](https://github.com/himesh-mehta/geolens/blob/main/frontend/services/analysis-service.ts): `frontend/services/analysis-service.ts`
- [Comparison service](https://github.com/himesh-mehta/geolens/blob/main/frontend/services/comparison-service.ts): `frontend/services/comparison-service.ts`

### Analysis backend

- [Flask API](https://github.com/himesh-mehta/geolens/blob/main/backend/app.py): `backend/app.py`
- [Land-cover classifier](https://github.com/himesh-mehta/geolens/blob/main/backend/ml_layer/model_service.py): `backend/ml_layer/model_service.py`
- [Vector analytics](https://github.com/himesh-mehta/geolens/blob/main/backend/ml_layer/shapefile_service.py): `backend/ml_layer/shapefile_service.py`

### Earth observation sources

- [Earth Engine imagery](https://github.com/himesh-mehta/geolens/blob/main/backend/data_sources/gee_source.py): `backend/data_sources/gee_source.py`
- [Sentinel data source](https://github.com/himesh-mehta/geolens/blob/main/backend/data_sources/sentinel_source.py): `backend/data_sources/sentinel_source.py`
- [ISRO data source](https://github.com/himesh-mehta/geolens/blob/main/backend/data_sources/isro_source.py): `backend/data_sources/isro_source.py`

### Interpretation and outputs

- [EO visual extractor](https://github.com/himesh-mehta/geolens/blob/main/backend/vision_layer/visual_extractor.py): `backend/vision_layer/visual_extractor.py`
- [Imagery renderer](https://github.com/himesh-mehta/geolens/blob/main/backend/vision_layer/image_generator.py): `backend/vision_layer/image_generator.py`
- [Vision evaluator](https://github.com/himesh-mehta/geolens/blob/main/backend/vision_layer/vision_evaluator.py): `backend/vision_layer/vision_evaluator.py`
- [Reasoning engine](https://github.com/himesh-mehta/geolens/blob/main/backend/gpt_oss_layer/reasoning_engine.py): `backend/gpt_oss_layer/reasoning_engine.py`
- [Groq AI service](https://github.com/himesh-mehta/geolens/blob/main/backend/gpt_oss_layer/ai_service.py): `backend/gpt_oss_layer/ai_service.py`
- [Prompt templates](https://github.com/himesh-mehta/geolens/blob/main/backend/gpt_oss_layer/prompt_templates.py): `backend/gpt_oss_layer/prompt_templates.py`

### Other components

- **GeoLens user**
- **Groq LLM**
- **Google Earth Engine**

## Connections

- GeoLens user → Analysis workspace: selects area (evidence: `README.md`)
- Analysis workspace → Location analysis service: requests analysis
- Period comparison → Comparison service: requests comparison
- Image analysis → Backend API client: uploads imagery (evidence: `README.md`)
- Shapefile analysis → Backend API client: uploads shapefile (evidence: `README.md`)
- Orbit assistant → Backend API client: asks question
- Location analysis service → Backend API client: requests data (evidence: `frontend/services/analysis-service.ts`)
- Comparison service → Backend API client: requests change data (evidence: `frontend/services/comparison-service.ts`)
- Backend API client → Flask API: sends REST requests (evidence: `README.md`)
- Flask API → Land-cover classifier: runs classification (evidence: `backend/app.py`)
- Flask API → Vector analytics: dispatches analysis (evidence: `README.md`)
- Flask API → EO visual extractor: extracts EO features (evidence: `backend/app.py`)
- Flask API → Imagery renderer: generates imagery (evidence: `backend/app.py`)
- Flask API → Vision evaluator: evaluates agreement (evidence: `backend/app.py`)
- Flask API → Reasoning engine: requests reasoning (evidence: `backend/app.py`)
- Flask API → Earth Engine imagery: checks connectivity (evidence: `backend/app.py`)
- Land-cover classifier → Earth Engine imagery: fetches features (evidence: `backend/ml_layer/model_service.py`)
- Earth Engine imagery → Google Earth Engine: queries imagery (evidence: `backend/data_sources/gee_source.py`)
- Reasoning engine → Groq AI service: prepares response (evidence: `backend/gpt_oss_layer/reasoning_engine.py`)
- Reasoning engine → Prompt templates: uses prompts (evidence: `backend/gpt_oss_layer/reasoning_engine.py`)
- Groq AI service → Groq LLM: generates answer (evidence: `README.md`)
- Land-cover classifier → Sentinel data source: uses observations
- Land-cover classifier → ISRO data source: uses observations
