# selva-meenakshi-k/climateguard-ai architecture

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

- Interactive diagram: https://gitdiagram.com/selva-meenakshi-k/climateguard-ai
- Repository: https://github.com/selva-meenakshi-k/climateguard-ai

## Overview

ClimateGuard AI serves Tamil Nadu farmers and the public with bilingual weather warnings, deterministic hazard assessments, farm actions, and emergency guidance. The main web workflow is user selection and dashboard in React → FastAPI weather and risk endpoints → forecast retrieval and rule-based assessment → localized advisories and plans. A separate Strands agent path answers questions through tools and a safety gate; Bedrock AgentCore is an additional runtime entrypoint. The README documents irrigation, scenario simulation, historical impact, and public-safety capabilities. Some endpoint and component wiring is unsampled, so only documented or indexed relationships are connected.

Main entry points: [`frontend/src/App.jsx`](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/App.jsx) (React application), [`backend/main.py`](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/main.py) (FastAPI endpoints), [`backend/agent/tools.py`](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/tools.py) (Agent tools), [`backend/agent/orchestrator.py`](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/orchestrator.py) (Agent orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Bilingual web experience"]
  node_app["React application<br/>[App.jsx]"]
  node_language["Language context"]
  node_riskview["Risk dashboard<br/>[RiskOverview.jsx]"]
  node_advisory["Farm advisories<br/>[AdvisoryCard.jsx]"]
  node_irrigationui["Irrigation plan<br/>[IrrigationPlan.jsx]"]
  node_safetyui["Safety plan<br/>[SafetyPlan.jsx]"]
  node_scenario["Scenario simulator"]
  node_impact["Historical impact<br/>[ImpactPage.jsx]"]
  node_scene["Weather scene<br/>[WeatherScene.jsx]"]
end

subgraph group_api["Climate API and data"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_irrigation["Irrigation calculation<br/>[main.py]"]
  node_simulation["Scenario calculation<br/>[main.py]"]
  node_locations["District profiles<br/>[locations.py]"]
  node_weather["Forecast service<br/>[weather_service.py]"]
end

subgraph group_risk["Risk and farm guidance"]
  node_riskengine["Risk assessment<br/>[risk_engine.py]"]
  node_thresholds["Agronomic thresholds<br/>[thresholds.py]"]
end

subgraph group_agent["Agent and safety"]
  node_agentcore["Agent orchestrator<br/>[orchestrator.py]"]
  node_tools["Agent tools<br/>[tools.py]"]
  node_graph["Planner critic graph<br/>[app.py]"]
  node_safety["Emergency gate<br/>[safety.py]"]
  node_guidance["Crop guidance<br/>[plan.py]"]
  node_agentcore_runtime["AgentCore runtime<br/>[agentcore_main.py]"]
  node_baseline["Agent baseline<br/>[baseline.py]"]
  node_evaluator["Answer evaluator<br/>[score.py]"]
end

node_user(("Farmer or public user"))
node_meteo["Open-Meteo"]

node_user -->|"uses"| node_app
node_app -->|"requests REST"| node_api
node_app -->|"uses translations"| node_language
node_app -->|"renders"| node_riskview
node_app -->|"renders"| node_advisory
node_app -->|"renders"| node_irrigationui
node_app -->|"renders"| node_safetyui
node_app -->|"renders"| node_scenario
node_app -->|"renders"| node_impact
node_riskview -->|"renders"| node_scene
node_api -->|"resolves districts"| node_locations
node_api -->|"requests forecasts"| node_weather
node_weather -->|"fetches forecast"| node_meteo
node_api -->|"assesses hazards"| node_riskengine
node_riskengine -->|"applies rules"| node_thresholds
node_api -->|"serves schedule"| node_irrigation
node_irrigation -->|"fetches forecast"| node_weather
node_api -->|"serves scenarios"| node_simulation
node_simulation -.->|"reassesses hazards"| node_riskengine
node_user -.->|"invokes agent"| node_agentcore_runtime
node_api -->|"routes questions"| node_agentcore
node_agentcore_runtime -->|"invokes"| node_agentcore
node_agentcore -->|"dispatches tools"| node_tools
node_tools -->|"looks up district"| node_locations
node_tools -->|"gets forecast"| node_weather
node_tools -->|"assesses risk"| node_riskengine
node_agentcore -.->|"uses agent graph"| node_graph
node_graph -->|"checks emergency"| node_safety
node_tools -.->|"uses guidance"| node_guidance
node_baseline -.->|"evaluated by"| node_evaluator

click node_app "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/App.jsx"
click node_language "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/context/LanguageContext.jsx"
click node_riskview "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/RiskOverview.jsx"
click node_advisory "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/AdvisoryCard.jsx"
click node_irrigationui "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/IrrigationPlan.jsx"
click node_safetyui "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/SafetyPlan.jsx"
click node_scenario "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/WhatIfSimulator.jsx"
click node_impact "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/ImpactPage.jsx"
click node_scene "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/WeatherScene.jsx"
click node_api "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/main.py"
click node_irrigation "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/main.py"
click node_simulation "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/main.py"
click node_locations "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/data/locations.py"
click node_weather "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/services/weather_service.py"
click node_riskengine "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/services/risk_engine.py"
click node_thresholds "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/config/thresholds.py"
click node_agentcore "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/orchestrator.py"
click node_tools "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/tools.py"
click node_graph "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/app.py"
click node_safety "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/safety.py"
click node_guidance "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/plan.py"
click node_agentcore_runtime "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agentcore_main.py"
click node_baseline "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/baseline.py"
click node_evaluator "https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/score.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_language,node_riskview,node_advisory,node_irrigationui,node_safetyui,node_scenario,node_impact,node_scene,node_user toneBlue
class node_api,node_irrigation,node_simulation,node_locations,node_weather toneAmber
class node_riskengine,node_thresholds toneMint
class node_agentcore,node_tools,node_graph,node_safety,node_guidance,node_agentcore_runtime,node_baseline,node_evaluator toneRose
class node_meteo toneIndigo
```

## Components

### Bilingual web experience

- [React application](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Language context](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/context/LanguageContext.jsx): `frontend/src/context/LanguageContext.jsx`
- [Risk dashboard](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/RiskOverview.jsx): `frontend/src/components/RiskOverview.jsx`
- [Farm advisories](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/AdvisoryCard.jsx): `frontend/src/components/AdvisoryCard.jsx`
- [Irrigation plan](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/IrrigationPlan.jsx): `frontend/src/components/IrrigationPlan.jsx`
- [Safety plan](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/SafetyPlan.jsx): `frontend/src/components/SafetyPlan.jsx`
- [Scenario simulator](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/WhatIfSimulator.jsx): `frontend/src/components/WhatIfSimulator.jsx`
- [Historical impact](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/ImpactPage.jsx): `frontend/src/components/ImpactPage.jsx`
- [Weather scene](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/frontend/src/components/WeatherScene.jsx): `frontend/src/components/WeatherScene.jsx`

### Climate API and data

- [FastAPI endpoints](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/main.py): `backend/main.py`
- [Irrigation calculation](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/main.py): `backend/main.py`
- [Scenario calculation](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/main.py): `backend/main.py`
- [District profiles](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/data/locations.py): `backend/data/locations.py`
- [Forecast service](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/services/weather_service.py): `backend/services/weather_service.py`

### Risk and farm guidance

- [Risk assessment](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/services/risk_engine.py): `backend/services/risk_engine.py`
- [Agronomic thresholds](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/config/thresholds.py): `backend/config/thresholds.py`

### Agent and safety

- [Agent orchestrator](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/orchestrator.py): `backend/agent/orchestrator.py`
- [Agent tools](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/tools.py): `backend/agent/tools.py`
- [Planner critic graph](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/app.py): `backend/agent/app.py`
- [Emergency gate](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/safety.py): `backend/agent/safety.py`
- [Crop guidance](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/plan.py): `backend/agent/plan.py`
- [AgentCore runtime](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agentcore_main.py): `backend/agentcore_main.py`
- [Agent baseline](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/baseline.py): `backend/agent/baseline.py`
- [Answer evaluator](https://github.com/selva-meenakshi-k/climateguard-ai/blob/main/backend/agent/score.py): `backend/agent/score.py`

### Other components

- **Farmer or public user**
- **Open-Meteo**

## Connections

- Farmer or public user → React application: uses (evidence: `README.md`)
- React application → FastAPI endpoints: requests REST (evidence: `README.md`)
- React application → Language context: uses translations (evidence: `frontend/src/App.jsx`)
- React application → Risk dashboard: renders (evidence: `frontend/src/App.jsx`)
- React application → Farm advisories: renders (evidence: `frontend/src/App.jsx`)
- React application → Irrigation plan: renders (evidence: `frontend/src/App.jsx`)
- React application → Safety plan: renders (evidence: `frontend/src/App.jsx`)
- React application → Scenario simulator: renders (evidence: `frontend/src/App.jsx`)
- React application → Historical impact: renders (evidence: `frontend/src/App.jsx`)
- Risk dashboard → Weather scene: renders
- FastAPI endpoints → District profiles: resolves districts (evidence: `backend/main.py`)
- FastAPI endpoints → Forecast service: requests forecasts (evidence: `backend/main.py`)
- Forecast service → Open-Meteo: fetches forecast (evidence: `backend/services/weather_service.py`)
- FastAPI endpoints → Risk assessment: assesses hazards (evidence: `backend/main.py`)
- Risk assessment → Agronomic thresholds: applies rules (evidence: `backend/services/risk_engine.py`)
- FastAPI endpoints → Irrigation calculation: serves schedule (evidence: `README.md`)
- Irrigation calculation → Forecast service: fetches forecast (evidence: `backend/main.py`)
- FastAPI endpoints → Scenario calculation: serves scenarios (evidence: `README.md`)
- Scenario calculation → Risk assessment: reassesses hazards (evidence: `backend/main.py`)
- Farmer or public user → AgentCore runtime: invokes agent (evidence: `README.md`)
- FastAPI endpoints → Agent orchestrator: routes questions (evidence: `backend/main.py`)
- AgentCore runtime → Agent orchestrator: invokes (evidence: `backend/agentcore_main.py`)
- Agent orchestrator → Agent tools: dispatches tools (evidence: `backend/agent/orchestrator.py`)
- Agent tools → District profiles: looks up district (evidence: `backend/agent/tools.py`)
- Agent tools → Forecast service: gets forecast (evidence: `backend/agent/tools.py`)
- Agent tools → Risk assessment: assesses risk (evidence: `backend/agent/tools.py`)
- Agent orchestrator → Planner critic graph: uses agent graph (evidence: `README.md`)
- Planner critic graph → Emergency gate: checks emergency (evidence: `backend/agent/app.py`)
- Agent tools → Crop guidance: uses guidance
- Agent baseline → Answer evaluator: evaluated by
