# chimertech-innovations/ragul architecture

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

- Interactive diagram: https://gitdiagram.com/chimertech-innovations/ragul
- Repository: https://github.com/chimertech-innovations/ragul

## Overview

RAGUL is a multilingual, voice-first dairy-farm assistant. A farmer speaks or types in the web dashboard; the browser sends voice or chat to the FastAPI service, which manages session context and routes requests through the LLM and farm tools or veterinary/product retrieval. It returns answers for the conversation and voice interface, while the dashboard also presents farm telemetry. The graph preserves the README’s voice, interruption, multilingual, cloud-LLM, Supabase, RAG, and dashboard capabilities. Some links rely on README statements because the relevant source excerpts are partial.

Main entry points: [`backend/app/main.py`](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/main.py) (FastAPI service), [`frontend/src/App.tsx`](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/App.tsx) (Dashboard app), [`backend/app/llm/router.py`](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/llm/router.py) (Agent tool router), [`frontend/src/services/audioEngine.ts`](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/services/audioEngine.ts) (Browser audio)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web dashboard"]
  node_dashboard["Dashboard app<br/>[App.tsx]"]
  node_audio_browser["Browser audio<br/>[audioEngine.ts]"]
  node_ui_state["UI session state<br/>[useRagulStore.ts]"]
  node_conversation["Conversation feed"]
  node_telemetry["Farm telemetry"]
  node_avatar["3D avatar<br/>[TalkingRagul3D.tsx]"]
  node_quick_queries["Quick queries<br/>[QuickQueryBar.tsx]"]
end

subgraph group_voice["Voice and sessions"]
  node_api["FastAPI service<br/>[main.py]"]
  node_vad["Speech detection<br/>[vad.py]"]
  node_stt["Speech transcription<br/>[stt.py]"]
  node_tts["Speech output<br/>[tts.py]"]
  node_sessions["Conversation memory<br/>[session_manager.py]"]
end

subgraph group_reasoning["Farm reasoning"]
  node_router["Agent tool router<br/>[router.py]"]
  node_prompts["Dairy prompts<br/>[prompts.py]"]
  node_llm_client["LLM client<br/>[client.py]"]
  node_rag["Veterinary and product RAG<br/>[rag_engine.py]"]
end

subgraph group_data["Farm data"]
  node_farm_tools["Farm query tools<br/>[farm_tools.py]"]
  node_db_client["PostgreSQL client<br/>[supabase_client.py]"]
  node_db_models["Farm data models<br/>[models.py]"]
end

node_farmer(("Farmer"))
node_supabase[("Supabase PostgreSQL")]
node_jarvislabs["JarvisLabs LLM"]

node_farmer -->|"uses"| node_dashboard
node_dashboard -->|"controls audio"| node_audio_browser
node_dashboard -->|"reads and updates"| node_ui_state
node_dashboard -->|"renders"| node_conversation
node_dashboard -->|"renders"| node_telemetry
node_dashboard -->|"renders"| node_avatar
node_dashboard -.->|"offers"| node_quick_queries
node_dashboard -->|"posts chat"| node_api
node_audio_browser -->|"streams voice"| node_api
node_api -->|"detects speech"| node_vad
node_api -->|"transcribes audio"| node_stt
node_api -->|"produces speech"| node_tts
node_api -->|"loads and saves context"| node_sessions
node_api -->|"routes requests"| node_router
node_router -->|"builds messages"| node_prompts
node_router -->|"requests completion"| node_llm_client
node_llm_client -->|"calls model"| node_jarvislabs
node_router -->|"executes tools"| node_farm_tools
node_router -->|"retrieves guidance"| node_rag
node_farm_tools -->|"queries records"| node_db_client
node_db_client -->|"reads and writes"| node_supabase
node_db_models -.->|"defines farm records"| node_supabase
node_rag -->|"loads knowledge data"| node_farmer
node_api -.->|"serves farm overview"| node_telemetry
node_api -.->|"returns voice response"| node_audio_browser

click node_dashboard "https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/App.tsx"
click node_audio_browser "https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/services/audioEngine.ts"
click node_ui_state "https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/store/useRagulStore.ts"
click node_conversation "https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/components/ConversationFeed.tsx"
click node_telemetry "https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/components/FarmTelemetryPanel.tsx"
click node_avatar "https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/components/TalkingRagul3D.tsx"
click node_quick_queries "https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/components/QuickQueryBar.tsx"
click node_api "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/main.py"
click node_vad "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/audio/vad.py"
click node_stt "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/audio/stt.py"
click node_tts "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/audio/tts.py"
click node_sessions "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/memory/session_manager.py"
click node_router "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/llm/router.py"
click node_prompts "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/llm/prompts.py"
click node_llm_client "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/llm/client.py"
click node_rag "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/knowledge/rag_engine.py"
click node_farm_tools "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/tools/farm_tools.py"
click node_db_client "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/database/supabase_client.py"
click node_db_models "https://github.com/chimertech-innovations/ragul/blob/main/backend/app/database/models.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_audio_browser,node_ui_state,node_conversation,node_telemetry,node_avatar,node_quick_queries toneBlue
class node_api,node_vad,node_stt,node_tts,node_sessions,node_supabase toneAmber
class node_router,node_prompts,node_llm_client,node_rag toneMint
class node_farm_tools,node_db_client,node_db_models toneRose
class node_farmer,node_jarvislabs toneIndigo
```

## Components

### Web dashboard

- [Dashboard app](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Browser audio](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/services/audioEngine.ts): `frontend/src/services/audioEngine.ts`
- [UI session state](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/store/useRagulStore.ts): `frontend/src/store/useRagulStore.ts`
- [Conversation feed](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/components/ConversationFeed.tsx): `frontend/src/components/ConversationFeed.tsx`
- [Farm telemetry](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/components/FarmTelemetryPanel.tsx): `frontend/src/components/FarmTelemetryPanel.tsx`
- [3D avatar](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/components/TalkingRagul3D.tsx): `frontend/src/components/TalkingRagul3D.tsx`
- [Quick queries](https://github.com/chimertech-innovations/ragul/blob/main/frontend/src/components/QuickQueryBar.tsx): `frontend/src/components/QuickQueryBar.tsx`

### Voice and sessions

- [FastAPI service](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/main.py): `backend/app/main.py`
- [Speech detection](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/audio/vad.py): `backend/app/audio/vad.py`
- [Speech transcription](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/audio/stt.py): `backend/app/audio/stt.py`
- [Speech output](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/audio/tts.py): `backend/app/audio/tts.py`
- [Conversation memory](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/memory/session_manager.py): `backend/app/memory/session_manager.py`

### Farm reasoning

- [Agent tool router](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/llm/router.py): `backend/app/llm/router.py`
- [Dairy prompts](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/llm/prompts.py): `backend/app/llm/prompts.py`
- [LLM client](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/llm/client.py): `backend/app/llm/client.py`
- [Veterinary and product RAG](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/knowledge/rag_engine.py): `backend/app/knowledge/rag_engine.py`

### Farm data

- [Farm query tools](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/tools/farm_tools.py): `backend/app/tools/farm_tools.py`
- [PostgreSQL client](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/database/supabase_client.py): `backend/app/database/supabase_client.py`
- [Farm data models](https://github.com/chimertech-innovations/ragul/blob/main/backend/app/database/models.py): `backend/app/database/models.py`

### Other components

- **Farmer**
- **Supabase PostgreSQL**
- **JarvisLabs LLM**

## Connections

- Farmer → Dashboard app: uses (evidence: `README.md`)
- Dashboard app → Browser audio: controls audio (evidence: `frontend/src/App.tsx`)
- Dashboard app → UI session state: reads and updates (evidence: `frontend/src/App.tsx`)
- Dashboard app → Conversation feed: renders (evidence: `frontend/src/App.tsx`)
- Dashboard app → Farm telemetry: renders (evidence: `frontend/src/App.tsx`)
- Dashboard app → 3D avatar: renders (evidence: `frontend/src/App.tsx`)
- Dashboard app → Quick queries: offers
- Dashboard app → FastAPI service: posts chat (evidence: `frontend/src/App.tsx`)
- Browser audio → FastAPI service: streams voice (evidence: `README.md`)
- FastAPI service → Speech detection: detects speech (evidence: `backend/app/main.py`)
- FastAPI service → Speech transcription: transcribes audio (evidence: `backend/app/main.py`)
- FastAPI service → Speech output: produces speech (evidence: `backend/app/main.py`)
- FastAPI service → Conversation memory: loads and saves context (evidence: `backend/app/main.py`)
- FastAPI service → Agent tool router: routes requests (evidence: `backend/app/main.py`)
- Agent tool router → Dairy prompts: builds messages (evidence: `backend/app/llm/router.py`)
- Agent tool router → LLM client: requests completion (evidence: `backend/app/llm/router.py`)
- LLM client → JarvisLabs LLM: calls model (evidence: `README.md`)
- Agent tool router → Farm query tools: executes tools (evidence: `backend/app/llm/router.py`)
- Agent tool router → Veterinary and product RAG: retrieves guidance (evidence: `backend/app/llm/router.py`)
- Farm query tools → PostgreSQL client: queries records (evidence: `backend/app/tools/farm_tools.py`)
- PostgreSQL client → Supabase PostgreSQL: reads and writes (evidence: `README.md`)
- Farm data models → Supabase PostgreSQL: defines farm records
- Veterinary and product RAG → Farmer: loads knowledge data (evidence: `backend/app/knowledge/rag_engine.py`)
- FastAPI service → Farm telemetry: serves farm overview (evidence: `README.md`)
- FastAPI service → Browser audio: returns voice response (evidence: `README.md`)
