# flamingdemon1/rekolt-alert architecture

> Architecture diagram of the GitHub repository flamingdemon1/rekolt-alert, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flamingdemon1/rekolt-alert
- Repository: https://github.com/flamingdemon1/rekolt-alert

## Overview

Rekolt Alert is a bilingual crop early-warning assistant and agricultural information/shop experience for Mauritian farmers. A farmer submits text, voice, or crop images; the app routes requests to preliminary guidance, optionally enriched with weather and catalogue context, then presents results in Morisien or English. Separate branches provide district risk information, local weather, and shop browsing/account sessions. The graph follows shown route/service calls and documented capabilities; some frontend-to-backend and AI-provider links are documented but their implementation was not sampled.

Main entry points: [`backend/app/main.py`](https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/main.py) (FastAPI entry), [`app/components/pages/CheckPlantPage.tsx`](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/pages/CheckPlantPage.tsx) (Plant assistant UI), [`backend/app/api/language.py`](https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/api/language.py) (Language API), [`app/components/pages/ShopCataloguePage.tsx`](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/pages/ShopCataloguePage.tsx) (Shop catalogue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_farmer["Farmer assistance"]
  node_check_ui["Plant assistant UI<br/>[CheckPlantPage.tsx]"]
  node_voice["Voice client<br/>[voice-client.ts]"]
end

subgraph group_web["Web experience"]
  node_weather_ui["Weather experience<br/>[useLiveWeather.ts]"]
  node_district_ui["District information"]
  node_district_data["District data service<br/>[data.service.ts]"]
  node_home["Home experience"]
end

subgraph group_shop["Shop and accounts"]
  node_catalogue_ui["Shop catalogue"]
  node_shop_service["Catalogue service<br/>[shop.service.ts]"]
  node_cart["Cart and checkout<br/>[useShopCart.ts]"]
  node_auth_api["Shop auth routes<br/>[route.ts]"]
  node_auth_service["Account sessions<br/>[auth.service.ts]"]
  node_auth_repo["Auth repository<br/>[auth.repository.ts]"]
  node_runtime_db[("D1 runtime binding<br/>[runtime.ts]")]
end

subgraph group_backend["Backend services"]
  node_chat_route["Chat endpoint<br/>[route.ts]"]
  node_chat_service["Chat guidance"]
  node_check_route["Image check endpoint<br/>[route.ts]"]
  node_check_service["Plant screening"]
  node_fastapi["FastAPI entry<br/>[main.py]"]
  node_language_api["Language API<br/>[language.py]"]
  node_conversation["Conversation agent"]
  node_image_analysis["Image analysis"]
  node_weather_tool["Weather assessment<br/>[weather_tool.py]"]
  node_provider["AI providers<br/>[myt_client.py]"]
  node_weather_route["Weather endpoint<br/>[route.ts]"]
  node_weather_service["Weather service<br/>[weather.service.ts]"]
end

node_farmer(("Farmer"))
node_d1[("Cloudflare D1")]
node_myt{{"my.t services"}}
node_legacy{{"Gemma and MMS"}}

node_farmer -->|"uses"| node_check_ui
node_check_ui -->|"uses"| node_voice
node_voice -.->|"requests voice"| node_language_api
node_check_ui -.->|"submits chat"| node_chat_route
node_chat_route -->|"calls"| node_chat_service
node_check_ui -.->|"submits image"| node_check_route
node_check_route -->|"screens plant"| node_check_service
node_farmer -.->|"sends requests"| node_fastapi
node_fastapi -->|"registers router"| node_language_api
node_language_api -.->|"handles turns"| node_conversation
node_language_api -.->|"handles images"| node_image_analysis
node_fastapi -->|"creates and calls"| node_weather_tool
node_conversation -.->|"uses provider"| node_provider
node_image_analysis -.->|"uses provider"| node_provider
node_fastapi -.->|"calls AI"| node_myt
node_fastapi -.->|"optional provider"| node_legacy
node_weather_ui -->|"requests coordinates"| node_weather_route
node_weather_route -->|"calls"| node_weather_service
node_farmer -->|"shares location"| node_weather_ui
node_district_ui -->|"loads district data"| node_district_data
node_home -.->|"presents guidance"| node_farmer
node_catalogue_ui -->|"loads products"| node_shop_service
node_catalogue_ui -->|"uses cart"| node_cart
node_farmer -->|"browses shop"| node_catalogue_ui
node_auth_api -->|"calls"| node_auth_service
node_auth_service -->|"reads and writes"| node_auth_repo
node_auth_repo -->|"gets database"| node_runtime_db
node_runtime_db -->|"binds runtime"| node_d1

click node_check_ui "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/pages/CheckPlantPage.tsx"
click node_voice "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/lib/voice-client.ts"
click node_chat_route "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/api/plant-chat/route.ts"
click node_chat_service "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/plant-chat/plant-chat.service.ts"
click node_check_route "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/api/plant-check/route.ts"
click node_check_service "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/plant-check/plant-check.service.ts"
click node_fastapi "https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/main.py"
click node_language_api "https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/api/language.py"
click node_conversation "https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/services/conversation_service.py"
click node_image_analysis "https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/services/image_analysis_service.py"
click node_weather_tool "https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/tools/weather_tool.py"
click node_provider "https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/services/myt_client.py"
click node_weather_ui "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/hooks/useLiveWeather.ts"
click node_weather_route "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/api/weather/route.ts"
click node_weather_service "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/weather/weather.service.ts"
click node_district_ui "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/pages/DistrictDataPage.tsx"
click node_district_data "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/pages/data.service.ts"
click node_home "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/RekoltAlertHome.tsx"
click node_catalogue_ui "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/pages/ShopCataloguePage.tsx"
click node_shop_service "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/pages/shop.service.ts"
click node_cart "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/hooks/useShopCart.ts"
click node_auth_api "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/api/shop-auth/login/route.ts"
click node_auth_service "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/shop-auth/auth.service.ts"
click node_auth_repo "https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/shop-auth/auth.repository.ts"
click node_runtime_db "https://github.com/flamingdemon1/rekolt-alert/blob/main/db/runtime.ts"

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_check_ui,node_voice toneBlue
class node_weather_ui,node_district_ui,node_district_data,node_home,node_d1 toneAmber
class node_catalogue_ui,node_shop_service,node_cart,node_auth_api,node_auth_service,node_auth_repo,node_runtime_db toneMint
class node_chat_route,node_chat_service,node_check_route,node_check_service,node_fastapi,node_language_api,node_conversation,node_image_analysis,node_weather_tool,node_provider,node_weather_route,node_weather_service toneRose
class node_farmer,node_myt,node_legacy toneIndigo
```

## Components

### Farmer assistance

- [Plant assistant UI](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/pages/CheckPlantPage.tsx): `app/components/pages/CheckPlantPage.tsx`
- [Voice client](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/lib/voice-client.ts): `app/lib/voice-client.ts`

### Web experience

- [Weather experience](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/hooks/useLiveWeather.ts): `app/hooks/useLiveWeather.ts`
- [District information](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/pages/DistrictDataPage.tsx): `app/components/pages/DistrictDataPage.tsx`
- [District data service](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/pages/data.service.ts): `app/backend/pages/data.service.ts`
- [Home experience](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/RekoltAlertHome.tsx): `app/components/RekoltAlertHome.tsx`

### Shop and accounts

- [Shop catalogue](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/components/pages/ShopCataloguePage.tsx): `app/components/pages/ShopCataloguePage.tsx`
- [Catalogue service](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/pages/shop.service.ts): `app/backend/pages/shop.service.ts`
- [Cart and checkout](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/hooks/useShopCart.ts): `app/hooks/useShopCart.ts`
- [Shop auth routes](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/api/shop-auth/login/route.ts): `app/api/shop-auth/login/route.ts`
- [Account sessions](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/shop-auth/auth.service.ts): `app/backend/shop-auth/auth.service.ts`
- [Auth repository](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/shop-auth/auth.repository.ts): `app/backend/shop-auth/auth.repository.ts`
- [D1 runtime binding](https://github.com/flamingdemon1/rekolt-alert/blob/main/db/runtime.ts): `db/runtime.ts`

### Backend services

- [Chat endpoint](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/api/plant-chat/route.ts): `app/api/plant-chat/route.ts`
- [Chat guidance](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/plant-chat/plant-chat.service.ts): `app/backend/plant-chat/plant-chat.service.ts`
- [Image check endpoint](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/api/plant-check/route.ts): `app/api/plant-check/route.ts`
- [Plant screening](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/plant-check/plant-check.service.ts): `app/backend/plant-check/plant-check.service.ts`
- [FastAPI entry](https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/main.py): `backend/app/main.py`
- [Language API](https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/api/language.py): `backend/app/api/language.py`
- [Conversation agent](https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/services/conversation_service.py): `backend/app/services/conversation_service.py`
- [Image analysis](https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/services/image_analysis_service.py): `backend/app/services/image_analysis_service.py`
- [Weather assessment](https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/tools/weather_tool.py): `backend/app/tools/weather_tool.py`
- [AI providers](https://github.com/flamingdemon1/rekolt-alert/blob/main/backend/app/services/myt_client.py): `backend/app/services/myt_client.py`
- [Weather endpoint](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/api/weather/route.ts): `app/api/weather/route.ts`
- [Weather service](https://github.com/flamingdemon1/rekolt-alert/blob/main/app/backend/weather/weather.service.ts): `app/backend/weather/weather.service.ts`

### Other components

- **Farmer**
- **Cloudflare D1**
- **my.t services**
- **Gemma and MMS**

## Connections

- Farmer → Plant assistant UI: uses (evidence: `README.md`)
- Plant assistant UI → Voice client: uses (evidence: `app/components/pages/CheckPlantPage.tsx`)
- Voice client → Language API: requests voice
- Plant assistant UI → Chat endpoint: submits chat
- Chat endpoint → Chat guidance: calls (evidence: `app/api/plant-chat/route.ts`)
- Plant assistant UI → Image check endpoint: submits image
- Image check endpoint → Plant screening: screens plant (evidence: `app/api/plant-check/route.ts`)
- Farmer → FastAPI entry: sends requests (evidence: `README.md`)
- FastAPI entry → Language API: registers router (evidence: `backend/app/main.py`)
- Language API → Conversation agent: handles turns
- Language API → Image analysis: handles images
- FastAPI entry → Weather assessment: creates and calls (evidence: `backend/app/main.py`)
- Conversation agent → AI providers: uses provider
- Image analysis → AI providers: uses provider
- FastAPI entry → my.t services: calls AI (evidence: `README.md`)
- FastAPI entry → Gemma and MMS: optional provider (evidence: `README.md`)
- Weather experience → Weather endpoint: requests coordinates (evidence: `app/hooks/useLiveWeather.ts`)
- Weather endpoint → Weather service: calls (evidence: `app/api/weather/route.ts`)
- Farmer → Weather experience: shares location (evidence: `README.md`)
- District information → District data service: loads district data (evidence: `app/components/pages/DistrictDataPage.tsx`)
- Home experience → Farmer: presents guidance
- Shop catalogue → Catalogue service: loads products (evidence: `app/components/pages/ShopCataloguePage.tsx`)
- Shop catalogue → Cart and checkout: uses cart (evidence: `app/components/pages/ShopCataloguePage.tsx`)
- Farmer → Shop catalogue: browses shop (evidence: `README.md`)
- Shop auth routes → Account sessions: calls (evidence: `app/api/shop-auth/login/route.ts`)
- Account sessions → Auth repository: reads and writes (evidence: `app/backend/shop-auth/auth.service.ts`)
- Auth repository → D1 runtime binding: gets database (evidence: `app/backend/shop-auth/auth.repository.ts`)
- D1 runtime binding → Cloudflare D1: binds runtime
