# debbyg-001/agrova architecture

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

- Interactive diagram: https://gitdiagram.com/debbyg-001/agrova
- Repository: https://github.com/debbyg-001/agrova

## Overview

Agrova is a farm-management application with animal, health, feed and production records, plus a conversational assistant. The main workflow is a farmer’s chat request reaching the API, where the assistant can consult farm records and retrieved knowledge, then return a reply; record changes through chat require confirmation. The frontend also includes onboarding and farm dashboard areas for health, livestock, finance, alerts and AI. Backend and chatbot relationships are supported by excerpts and the source index; frontend-to-API wiring and knowledge ingestion details were not shown.

Main entry points: [`chatbot/chatbot.py`](https://github.com/debbyg-001/agrova/blob/main/chatbot/chatbot.py) (Chat orchestrator), [`backend/main.py`](https://github.com/debbyg-001/agrova/blob/main/backend/main.py) (Farm API), [`backend/database.py`](https://github.com/debbyg-001/agrova/blob/main/backend/database.py) (Database sessions), [`backend/crud.py`](https://github.com/debbyg-001/agrova/blob/main/backend/crud.py) (Record operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Farmer experience"]
  node_web["Web application"]
  node_onboarding["Farm onboarding<br/>[page.tsx]"]
  node_dashboard["Farm dashboard<br/>[page.tsx]"]
  node_health_view["Health view<br/>[page.tsx]"]
  node_livestock_view["Livestock view<br/>[page.tsx]"]
  node_finance_view["Finance view<br/>[page.tsx]"]
  node_alerts_view["Alerts view<br/>[page.tsx]"]
  node_ai_view["AI view<br/>[page.tsx]"]
end

subgraph group_api["Farm API and records"]
  node_api["Farm API<br/>[main.py]"]
  node_schemas["Record schemas<br/>[schemas.py]"]
  node_crud["Record operations<br/>[crud.py]"]
  node_models["Farm record models<br/>[models.py]"]
  node_db_config["Database sessions<br/>[database.py]"]
  node_farm_store[("Farm database<br/>[database.py]")]
end

subgraph group_assistant["Conversational assistant"]
  node_chatbot["Chat orchestrator<br/>[chatbot.py]"]
  node_logging["Confirmed record logging<br/>[record_logging.py]"]
  node_language["Pidgin detection<br/>[lang_utils.py]"]
  node_local_reply["Offline responder<br/>[local_responder.py]"]
end

subgraph group_knowledge["Knowledge base"]
  node_retriever["Knowledge retrieval<br/>[retriever.py]"]
  node_knowledge_index[("Knowledge index<br/>[retriever.py]")]
  node_ingestion["Knowledge ingestion<br/>[ingest.py]"]
end

node_farmer(("Farmer"))

node_farmer -->|"sends chat"| node_api
node_api -->|"validates records"| node_schemas
node_api -->|"dispatches record calls"| node_crud
node_api -->|"calls assistant"| node_chatbot
node_api -->|"opens sessions"| node_db_config
node_crud -->|"queries and writes"| node_models
node_models -->|"uses base"| node_db_config
node_db_config -->|"connects"| node_farm_store
node_chatbot -->|"handles log requests"| node_logging
node_chatbot -->|"retrieves knowledge"| node_retriever
node_chatbot -->|"builds offline replies"| node_local_reply
node_chatbot -->|"detects language"| node_language
node_chatbot -->|"reads farm records"| node_farm_store
node_logging -->|"writes after confirmation"| node_farm_store
node_retriever -->|"loads and searches"| node_knowledge_index
node_farmer -.->|"uses"| node_web

click node_web "https://github.com/debbyg-001/agrova/tree/main/frontend/src/app"
click node_onboarding "https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/onboarding/page.tsx"
click node_dashboard "https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/page.tsx"
click node_health_view "https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/health/page.tsx"
click node_livestock_view "https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/livestock/page.tsx"
click node_finance_view "https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/finance/page.tsx"
click node_alerts_view "https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/alerts/page.tsx"
click node_ai_view "https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/ai/page.tsx"
click node_api "https://github.com/debbyg-001/agrova/blob/main/backend/main.py"
click node_schemas "https://github.com/debbyg-001/agrova/blob/main/backend/schemas.py"
click node_crud "https://github.com/debbyg-001/agrova/blob/main/backend/crud.py"
click node_models "https://github.com/debbyg-001/agrova/blob/main/backend/models.py"
click node_db_config "https://github.com/debbyg-001/agrova/blob/main/backend/database.py"
click node_farm_store "https://github.com/debbyg-001/agrova/blob/main/backend/database.py"
click node_chatbot "https://github.com/debbyg-001/agrova/blob/main/chatbot/chatbot.py"
click node_logging "https://github.com/debbyg-001/agrova/blob/main/chatbot/record_logging.py"
click node_language "https://github.com/debbyg-001/agrova/blob/main/chatbot/lang_utils.py"
click node_local_reply "https://github.com/debbyg-001/agrova/blob/main/chatbot/local_responder.py"
click node_retriever "https://github.com/debbyg-001/agrova/blob/main/knowledge/retriever.py"
click node_knowledge_index "https://github.com/debbyg-001/agrova/blob/main/knowledge/retriever.py"
click node_ingestion "https://github.com/debbyg-001/agrova/blob/main/knowledge/ingest.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_web,node_onboarding,node_dashboard,node_health_view,node_livestock_view,node_finance_view,node_alerts_view,node_ai_view toneBlue
class node_api,node_schemas,node_crud,node_models,node_db_config,node_farm_store toneAmber
class node_chatbot,node_logging,node_language,node_local_reply toneMint
class node_retriever,node_knowledge_index,node_ingestion toneRose
class node_farmer toneIndigo
```

## Components

### Farmer experience

- [Web application](https://github.com/debbyg-001/agrova/tree/main/frontend/src/app): `frontend/src/app`
- [Farm onboarding](https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/onboarding/page.tsx): `frontend/src/app/onboarding/page.tsx`
- [Farm dashboard](https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/page.tsx): `frontend/src/app/app/page.tsx`
- [Health view](https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/health/page.tsx): `frontend/src/app/app/health/page.tsx`
- [Livestock view](https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/livestock/page.tsx): `frontend/src/app/app/livestock/page.tsx`
- [Finance view](https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/finance/page.tsx): `frontend/src/app/app/finance/page.tsx`
- [Alerts view](https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/alerts/page.tsx): `frontend/src/app/app/alerts/page.tsx`
- [AI view](https://github.com/debbyg-001/agrova/blob/main/frontend/src/app/app/ai/page.tsx): `frontend/src/app/app/ai/page.tsx`

### Farm API and records

- [Farm API](https://github.com/debbyg-001/agrova/blob/main/backend/main.py): `backend/main.py`
- [Record schemas](https://github.com/debbyg-001/agrova/blob/main/backend/schemas.py): `backend/schemas.py`
- [Record operations](https://github.com/debbyg-001/agrova/blob/main/backend/crud.py): `backend/crud.py`
- [Farm record models](https://github.com/debbyg-001/agrova/blob/main/backend/models.py): `backend/models.py`
- [Database sessions](https://github.com/debbyg-001/agrova/blob/main/backend/database.py): `backend/database.py`
- [Farm database](https://github.com/debbyg-001/agrova/blob/main/backend/database.py): `backend/database.py`

### Conversational assistant

- [Chat orchestrator](https://github.com/debbyg-001/agrova/blob/main/chatbot/chatbot.py): `chatbot/chatbot.py`
- [Confirmed record logging](https://github.com/debbyg-001/agrova/blob/main/chatbot/record_logging.py): `chatbot/record_logging.py`
- [Pidgin detection](https://github.com/debbyg-001/agrova/blob/main/chatbot/lang_utils.py): `chatbot/lang_utils.py`
- [Offline responder](https://github.com/debbyg-001/agrova/blob/main/chatbot/local_responder.py): `chatbot/local_responder.py`

### Knowledge base

- [Knowledge retrieval](https://github.com/debbyg-001/agrova/blob/main/knowledge/retriever.py): `knowledge/retriever.py`
- [Knowledge index](https://github.com/debbyg-001/agrova/blob/main/knowledge/retriever.py): `knowledge/retriever.py`
- [Knowledge ingestion](https://github.com/debbyg-001/agrova/blob/main/knowledge/ingest.py): `knowledge/ingest.py`

### Other components

- **Farmer**

## Connections

- Farmer → Farm API: sends chat (evidence: `backend/main.py`)
- Farm API → Record schemas: validates records (evidence: `backend/main.py`)
- Farm API → Record operations: dispatches record calls (evidence: `backend/main.py`)
- Farm API → Chat orchestrator: calls assistant (evidence: `backend/main.py`)
- Farm API → Database sessions: opens sessions (evidence: `backend/main.py`)
- Record operations → Farm record models: queries and writes (evidence: `backend/crud.py`)
- Farm record models → Database sessions: uses base (evidence: `backend/models.py`)
- Database sessions → Farm database: connects (evidence: `backend/database.py`)
- Chat orchestrator → Confirmed record logging: handles log requests (evidence: `chatbot/chatbot.py`)
- Chat orchestrator → Knowledge retrieval: retrieves knowledge (evidence: `chatbot/chatbot.py`)
- Chat orchestrator → Offline responder: builds offline replies (evidence: `chatbot/chatbot.py`)
- Chat orchestrator → Pidgin detection: detects language (evidence: `chatbot/chatbot.py`)
- Chat orchestrator → Farm database: reads farm records (evidence: `chatbot/chatbot.py`)
- Confirmed record logging → Farm database: writes after confirmation (evidence: `chatbot/record_logging.py`)
- Knowledge retrieval → Knowledge index: loads and searches (evidence: `knowledge/retriever.py`)
- Farmer → Web application: uses
