# nyikomnisii/llm_api-wrapper architecture

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

- Interactive diagram: https://gitdiagram.com/nyikomnisii/llm_api-wrapper
- Repository: https://github.com/nyikomnisii/llm_api-wrapper

## Overview

AgriLite AI is a farm-management and agronomy-advice product: users manage farm records and activities, view alerts and weather, and ask for structured AI advice. The Expo app uses Supabase for authentication and persistent farm data, and calls a FastAPI backend for chat and weather services. The backend assembles an agronomist workflow around Gemini function calling and Open-Meteo risk data. Several screen and route implementations were not excerpted; those branches reflect README capabilities and the source index, with edges limited to documented or indexed relationships.

Main entry points: [`backend/app/api/router.py`](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/router.py) (FastAPI routes), [`backend/app/services/agronomist_service.py`](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/agronomist_service.py) (Advice orchestration), [`backend/app/services/gemini_service.py`](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/gemini_service.py) (Gemini tool loop), [`frontend/app/(tabs)/index.tsx`](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/(tabs)/index.tsx) (Home dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Mobile app"]
  node_screens["Farm screens<br/>[my-farm.tsx]"]
  node_activity["Activity entry<br/>[new.tsx]"]
  node_chat_screen["Chat screen<br/>[index.tsx]"]
  node_home["Home dashboard<br/>[index.tsx]"]
  node_location["Location selection"]
  node_auth["Authentication<br/>[useAuth.tsx]"]
  node_api_client["Backend API client<br/>[client.ts]"]
  node_geocoding["Location geocoding<br/>[geocoding.ts]"]
  node_weather_ui["Weather display<br/>[useWeather.ts]"]
end

subgraph group_data["Farm data"]
  node_farm_hooks["Farm data hooks<br/>[useFarm.tsx]"]
  node_supabase_api["Supabase data access<br/>[farms.ts]"]
  node_supabase[("Supabase")]
  node_profile["Profile and alerts<br/>[useAlerts.ts]"]
  node_chat_history["Chat history<br/>[chat.ts]"]
end

subgraph group_backend["Agronomy backend"]
  node_api["FastAPI routes<br/>[router.py]"]
  node_chat_route["Chat endpoint<br/>[chat.py]"]
  node_agronomist["Advice orchestration"]
  node_gemini_service["Gemini tool loop<br/>[gemini_service.py]"]
  node_tool_executor["Tool executor<br/>[tool_executor.py]"]
  node_gemini_client["Gemini client<br/>[gemini.py]"]
  node_prompts["Agronomist prompt<br/>[agronomist.py]"]
  node_health["Health endpoint<br/>[health.py]"]
end

subgraph group_weather["Weather services"]
  node_weather_route["Weather endpoint<br/>[weather.py]"]
  node_weather_service["Weather risk service<br/>[weather_service.py]"]
  node_weather_tool["Weather tool<br/>[weather.py]"]
  node_openmeteo["Open-Meteo client<br/>[openmeteo.py]"]
  node_weather_provider["Open-Meteo"]
end

node_farmer(("Farmer"))

node_farmer -->|"manages farm"| node_screens
node_farmer -->|"records activity"| node_activity
node_farmer -->|"asks advice"| node_chat_screen
node_farmer -->|"views dashboard"| node_home
node_screens -->|"uses farm data"| node_farm_hooks
node_activity -->|"writes activities"| node_supabase_api
node_farm_hooks -->|"loads farms"| node_supabase_api
node_auth -->|"authenticates"| node_supabase
node_supabase_api -->|"reads and writes"| node_supabase
node_profile -->|"loads alerts"| node_supabase
node_chat_history -->|"stores conversations"| node_supabase
node_home -->|"shows forecast"| node_weather_ui
node_home -->|"resolves location"| node_location
node_location -->|"searches places"| node_geocoding
node_chat_screen -->|"sends chat request"| node_api_client
node_api_client -->|"calls backend"| node_api
node_api -->|"routes requests"| node_chat_route
node_api -->|"routes requests"| node_weather_route
node_api -->|"routes requests"| node_health
node_chat_route -.->|"requests advice"| node_agronomist
node_agronomist -->|"generates reply"| node_gemini_service
node_agronomist -->|"registers weather tool"| node_tool_executor
node_agronomist -->|"builds tool spec"| node_weather_tool
node_gemini_service -->|"dispatches calls"| node_tool_executor
node_gemini_service -->|"generates content"| node_gemini_client
node_gemini_service -->|"uses system prompt"| node_prompts
node_weather_tool -->|"gets forecast"| node_weather_service
node_weather_route -.->|"serves forecasts"| node_weather_service
node_weather_service -->|"geocodes and forecasts"| node_openmeteo
node_openmeteo -.->|"requests weather data"| node_weather_provider
node_weather_ui -.->|"requests forecast"| node_api_client

click node_screens "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/(tabs)/my-farm.tsx"
click node_activity "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/activity/new.tsx"
click node_chat_screen "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/chat/index.tsx"
click node_home "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/(tabs)/index.tsx"
click node_location "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useResolvedLocation.tsx"
click node_auth "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useAuth.tsx"
click node_api_client "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/api/client.ts"
click node_farm_hooks "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useFarm.tsx"
click node_supabase_api "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/api/supabase/farms.ts"
click node_api "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/router.py"
click node_chat_route "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/routes/chat.py"
click node_agronomist "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/agronomist_service.py"
click node_gemini_service "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/gemini_service.py"
click node_tool_executor "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/tool_executor.py"
click node_gemini_client "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/clients/gemini.py"
click node_prompts "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/prompts/agronomist.py"
click node_weather_route "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/routes/weather.py"
click node_weather_service "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/weather_service.py"
click node_weather_tool "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/tools/weather.py"
click node_openmeteo "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/clients/openmeteo.py"
click node_geocoding "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/api/geocoding.ts"
click node_profile "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useAlerts.ts"
click node_chat_history "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/api/supabase/chat.ts"
click node_weather_ui "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useWeather.ts"
click node_health "https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/routes/health.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_screens,node_activity,node_chat_screen,node_home,node_location,node_auth,node_api_client,node_geocoding,node_weather_ui toneBlue
class node_farm_hooks,node_supabase_api,node_supabase,node_profile,node_chat_history toneAmber
class node_api,node_chat_route,node_agronomist,node_gemini_service,node_tool_executor,node_gemini_client,node_prompts,node_health toneMint
class node_weather_route,node_weather_service,node_weather_tool,node_openmeteo,node_weather_provider toneRose
class node_farmer toneIndigo
```

## Components

### Mobile app

- [Farm screens](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/(tabs)/my-farm.tsx): `frontend/app/(tabs)/my-farm.tsx`
- [Activity entry](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/activity/new.tsx): `frontend/app/activity/new.tsx`
- [Chat screen](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/chat/index.tsx): `frontend/app/chat/index.tsx`
- [Home dashboard](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/app/(tabs)/index.tsx): `frontend/app/(tabs)/index.tsx`
- [Location selection](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useResolvedLocation.tsx): `frontend/src/hooks/useResolvedLocation.tsx`
- [Authentication](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useAuth.tsx): `frontend/src/hooks/useAuth.tsx`
- [Backend API client](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Location geocoding](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/api/geocoding.ts): `frontend/src/api/geocoding.ts`
- [Weather display](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useWeather.ts): `frontend/src/hooks/useWeather.ts`

### Farm data

- [Farm data hooks](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useFarm.tsx): `frontend/src/hooks/useFarm.tsx`
- [Supabase data access](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/api/supabase/farms.ts): `frontend/src/api/supabase/farms.ts`
- **Supabase**
- [Profile and alerts](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/hooks/useAlerts.ts): `frontend/src/hooks/useAlerts.ts`
- [Chat history](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/frontend/src/api/supabase/chat.ts): `frontend/src/api/supabase/chat.ts`

### Agronomy backend

- [FastAPI routes](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/router.py): `backend/app/api/router.py`
- [Chat endpoint](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/routes/chat.py): `backend/app/api/routes/chat.py`
- [Advice orchestration](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/agronomist_service.py): `backend/app/services/agronomist_service.py`
- [Gemini tool loop](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/gemini_service.py): `backend/app/services/gemini_service.py`
- [Tool executor](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/tool_executor.py): `backend/app/services/tool_executor.py`
- [Gemini client](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/clients/gemini.py): `backend/app/clients/gemini.py`
- [Agronomist prompt](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/prompts/agronomist.py): `backend/app/prompts/agronomist.py`
- [Health endpoint](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/routes/health.py): `backend/app/api/routes/health.py`

### Weather services

- [Weather endpoint](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/api/routes/weather.py): `backend/app/api/routes/weather.py`
- [Weather risk service](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/services/weather_service.py): `backend/app/services/weather_service.py`
- [Weather tool](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/tools/weather.py): `backend/app/tools/weather.py`
- [Open-Meteo client](https://github.com/nyikomnisii/llm_api-wrapper/blob/main/backend/app/clients/openmeteo.py): `backend/app/clients/openmeteo.py`
- **Open-Meteo**

### Other components

- **Farmer**

## Connections

- Farmer → Farm screens: manages farm (evidence: `README.md`)
- Farmer → Activity entry: records activity (evidence: `README.md`)
- Farmer → Chat screen: asks advice (evidence: `README.md`)
- Farmer → Home dashboard: views dashboard (evidence: `frontend/app/(tabs)/index.tsx`)
- Farm screens → Farm data hooks: uses farm data
- Activity entry → Supabase data access: writes activities (evidence: `frontend/app/activity/new.tsx`)
- Farm data hooks → Supabase data access: loads farms (evidence: `frontend/src/hooks/useFarm.tsx`)
- Authentication → Supabase: authenticates (evidence: `frontend/src/hooks/useAuth.tsx`)
- Supabase data access → Supabase: reads and writes (evidence: `frontend/src/api/supabase/farms.ts`)
- Profile and alerts → Supabase: loads alerts (evidence: `frontend/src/hooks/useAlerts.ts`)
- Chat history → Supabase: stores conversations (evidence: `README.md`)
- Home dashboard → Weather display: shows forecast (evidence: `frontend/app/(tabs)/index.tsx`)
- Home dashboard → Location selection: resolves location (evidence: `frontend/app/(tabs)/index.tsx`)
- Location selection → Location geocoding: searches places (evidence: `frontend/src/hooks/useResolvedLocation.tsx`)
- Chat screen → Backend API client: sends chat request (evidence: `frontend/app/chat/index.tsx`)
- Backend API client → FastAPI routes: calls backend (evidence: `frontend/src/api/client.ts`)
- FastAPI routes → Chat endpoint: routes requests (evidence: `backend/app/api/router.py`)
- FastAPI routes → Weather endpoint: routes requests (evidence: `backend/app/api/router.py`)
- FastAPI routes → Health endpoint: routes requests (evidence: `backend/app/api/router.py`)
- Chat endpoint → Advice orchestration: requests advice
- Advice orchestration → Gemini tool loop: generates reply (evidence: `backend/app/services/agronomist_service.py`)
- Advice orchestration → Tool executor: registers weather tool (evidence: `backend/app/services/agronomist_service.py`)
- Advice orchestration → Weather tool: builds tool spec (evidence: `backend/app/services/agronomist_service.py`)
- Gemini tool loop → Tool executor: dispatches calls (evidence: `backend/app/services/gemini_service.py`)
- Gemini tool loop → Gemini client: generates content (evidence: `backend/app/services/gemini_service.py`)
- Gemini tool loop → Agronomist prompt: uses system prompt (evidence: `backend/app/main.py`)
- Weather tool → Weather risk service: gets forecast (evidence: `backend/app/services/agronomist_service.py`)
- Weather endpoint → Weather risk service: serves forecasts
- Weather risk service → Open-Meteo client: geocodes and forecasts (evidence: `backend/app/services/weather_service.py`)
- Open-Meteo client → Open-Meteo: requests weather data
- Weather display → Backend API client: requests forecast
