# ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting architecture

> Architecture diagram of the GitHub repository ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting
- Repository: https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting

## Overview

This is a desertification-risk dashboard backed by a FastAPI analysis service. The main workflow lets users select an area on the map for current or forecast analysis, fetches satellite/environmental inputs, runs inference, and presents generated visualizations; users can also search precomputed districts. Separate capabilities include saved-analysis history, AI reports, and a data-grounded chat copilot. The graph reflects the route handlers and service calls visible in sampled source; frontend request wiring beyond the explicit search request is not fully evidenced, so uncertain links are omitted.

Main entry points: [`desertification_api/app/api/routes.py`](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/api/routes.py) (API routes), [`desertification_api/app/services/mongodb_service.py`](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/mongodb_service.py) (Mongo service), [`desertification-dashboard/app/page.tsx`](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification-dashboard/app/page.tsx) (Dashboard page), [`desertification_api/app/services/inference.py`](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/inference.py) (Model inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard UI"]
  node_dashboard["Dashboard page<br/>[page.tsx]"]
  node_search["District search<br/>[SearchBar.tsx]"]
  node_map["Map widget<br/>[MapWidget.tsx]"]
end

subgraph group_api["API workflows"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_analysis["Analysis services"]
  node_earthservice["Earth Engine data<br/>[ee_service.py]"]
  node_inference["Model inference<br/>[inference.py]"]
  node_models["Forecast model<br/>[convgru.py]"]
  node_unet["U-Net model<br/>[unet.py]"]
  node_visuals["Visualization metrics<br/>[visuals.py]"]
end

subgraph group_data["Data and AI"]
  node_mongo["Mongo service<br/>[mongodb_service.py]"]
  node_supabase["Supabase service"]
  node_rag["RAG copilot<br/>[rag_service.py]"]
  node_reports["AI reports<br/>[report_service.py]"]
end

subgraph group_external["External platforms"]
  node_earthengine["Google Earth Engine"]
  node_mongodb[("MongoDB")]
  node_supabase_platform[("Supabase")]
  node_gemini["Gemini"]
  node_imagehost["Visualization image URLs"]
end

node_user(("Dashboard user"))

node_user -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_search
node_dashboard -->|"loads"| node_map
node_search -->|"requests search"| node_fastapi
node_fastapi -->|"dispatches"| node_routes
node_routes -->|"validates"| node_schemas
node_routes -->|"fetches inputs"| node_earthservice
node_earthservice -->|"queries imagery"| node_earthengine
node_routes -->|"runs analysis"| node_inference
node_routes -->|"generates outputs"| node_visuals
node_routes -->|"stores outputs"| node_supabase
node_supabase -->|"uploads and records"| node_supabase_platform
node_routes -->|"searches districts"| node_mongo
node_mongo -->|"queries"| node_mongodb
node_routes -->|"dispatches chat"| node_rag
node_rag -->|"reads district data"| node_mongo
node_rag -->|"streams answers"| node_gemini
node_routes -->|"generates report"| node_reports
node_reports -->|"downloads images"| node_imagehost
node_reports -->|"submits report"| node_gemini
node_routes -->|"reads history"| node_supabase_platform
node_routes -->|"loads district data"| node_mongo
node_inference -.->|"uses forecast network"| node_models
node_inference -.->|"uses segmentation network"| node_unet

click node_dashboard "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification-dashboard/app/page.tsx"
click node_search "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification-dashboard/components/SearchBar.tsx"
click node_map "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification-dashboard/components/MapWidget.tsx"
click node_fastapi "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/main.py"
click node_routes "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/api/routes.py"
click node_schemas "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/api/schemas.py"
click node_earthservice "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/ee_service.py"
click node_inference "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/inference.py"
click node_models "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/models/convgru.py"
click node_unet "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/models/unet.py"
click node_visuals "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/visuals.py"
click node_mongo "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/mongodb_service.py"
click node_supabase "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/supabase_service.py"
click node_rag "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/rag_service.py"
click node_reports "https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/report_service.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_dashboard,node_search,node_map,node_user toneBlue
class node_fastapi,node_routes,node_schemas toneAmber
class node_earthservice,node_inference,node_models,node_unet,node_visuals toneMint
class node_mongo,node_supabase,node_rag,node_reports toneRose
class node_earthengine,node_mongodb,node_supabase_platform,node_gemini,node_imagehost toneIndigo
```

## Components

### Dashboard UI

- [Dashboard page](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification-dashboard/app/page.tsx): `desertification-dashboard/app/page.tsx`
- [District search](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification-dashboard/components/SearchBar.tsx): `desertification-dashboard/components/SearchBar.tsx`
- [Map widget](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification-dashboard/components/MapWidget.tsx): `desertification-dashboard/components/MapWidget.tsx`

### API workflows

- [FastAPI app](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/main.py): `desertification_api/app/main.py`
- [API routes](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/api/routes.py): `desertification_api/app/api/routes.py`
- [API schemas](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/api/schemas.py): `desertification_api/app/api/schemas.py`

### Analysis services

- [Earth Engine data](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/ee_service.py): `desertification_api/app/services/ee_service.py`
- [Model inference](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/inference.py): `desertification_api/app/services/inference.py`
- [Forecast model](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/models/convgru.py): `desertification_api/app/models/convgru.py`
- [U-Net model](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/models/unet.py): `desertification_api/app/models/unet.py`
- [Visualization metrics](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/visuals.py): `desertification_api/app/services/visuals.py`

### Data and AI

- [Mongo service](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/mongodb_service.py): `desertification_api/app/services/mongodb_service.py`
- [Supabase service](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/supabase_service.py): `desertification_api/app/services/supabase_service.py`
- [RAG copilot](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/rag_service.py): `desertification_api/app/services/rag_service.py`
- [AI reports](https://github.com/ahmedfarazsyk/sindh-desertification-risk-prediction-and-forecasting/blob/main/desertification_api/app/services/report_service.py): `desertification_api/app/services/report_service.py`

### External platforms

- **Google Earth Engine**
- **MongoDB**
- **Supabase**
- **Gemini**
- **Visualization image URLs**

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Dashboard page: uses
- Dashboard page → District search: renders
- Dashboard page → Map widget: loads
- District search → FastAPI app: requests search
- FastAPI app → API routes: dispatches
- API routes → API schemas: validates
- API routes → Earth Engine data: fetches inputs
- Earth Engine data → Google Earth Engine: queries imagery
- API routes → Model inference: runs analysis
- API routes → Visualization metrics: generates outputs
- API routes → Supabase service: stores outputs
- Supabase service → Supabase: uploads and records
- API routes → Mongo service: searches districts
- Mongo service → MongoDB: queries
- API routes → RAG copilot: dispatches chat
- RAG copilot → Mongo service: reads district data
- RAG copilot → Gemini: streams answers
- API routes → AI reports: generates report
- AI reports → Visualization image URLs: downloads images
- AI reports → Gemini: submits report
- API routes → Supabase: reads history
- API routes → Mongo service: loads district data
- Model inference → Forecast model: uses forecast network
- Model inference → U-Net model: uses segmentation network
