# gittaboina1-ops/agriculture architecture

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

- Interactive diagram: https://gitdiagram.com/gittaboina1-ops/agriculture
- Repository: https://github.com/gittaboina1-ops/agriculture

## Overview

AgriGraph serves farmers through a web UI and terminal assistant: questions are classified, matched to agricultural entities, traversed against a knowledge graph, enriched with provenance, conflict and sensor-quality checks, then answered with grounded language-model output. Admins upload resources that pass through extraction, indexing, normalization and validation before graph updates. The web UI also exposes multilingual answers and admin views for graph, sources, conflicts and data quality. Backend excerpts and the README support the main pipeline; some ingestion steps and UI links are documented but their implementation details were not sampled.

Main entry points: [`backend/ingestion/document_service.py`](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/document_service.py) (Ingestion Orchestrator), [`backend/retrieval/service.py`](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/retrieval/service.py) (Query Retrieval), [`backend/main.py`](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/main.py) (HTTP API), [`frontend/src/api/api.js`](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/api/api.js) (API Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User Interfaces"]
  node_web_app["Web App<br/>[App.jsx]"]
  node_farmer_ui["Farmer Experience<br/>[FarmerHome.jsx]"]
  node_query_controls["Query and Voice<br/>[QueryBox.jsx]"]
  node_answer_evidence["Answer and Evidence<br/>[AnswerCard.jsx]"]
  node_admin_ui["Admin Console<br/>[AdminHome.jsx]"]
  node_admin_upload_ui["Resource Upload<br/>[AdminUpload.jsx]"]
  node_api_client["API Client<br/>[api.js]"]
  node_auth_context["Session Context<br/>[AuthContext.jsx]"]
end

subgraph group_api["Backend API"]
  node_http_api["HTTP API<br/>[main.py]"]
  node_auth["Authentication<br/>[auth_service.py]"]
  node_cli["Terminal Assistant<br/>[cli.py]"]
end

subgraph group_knowledge["Knowledge Pipeline"]
  node_ingestion["Ingestion Orchestrator"]
  node_pdf_extract["Document Extraction<br/>[pdf_extractor.py]"]
  node_chunking["Chunking and Index<br/>[semantic_index.py]"]
  node_entity_extract["Entity Extraction"]
  node_normalizer["Entity Normalization<br/>[normalizer.py]"]
  node_ingest_validation["Schema Validation<br/>[validator.py]"]
end

subgraph group_services["Domain Services"]
  node_retrieval["Query Retrieval<br/>[service.py]"]
  node_intent["Intent Detection<br/>[intent.py]"]
  node_graph_service["Graph Traversal<br/>[service.py]"]
  node_graph_store[("Knowledge Graph<br/>[service.py]")]
  node_provenance["Source Provenance<br/>[tracker.py]"]
  node_conflict["Conflict Detection<br/>[engine.py]"]
  node_sensor_validation["Sensor Guardrails<br/>[validator.py]"]
  node_llm["Grounded Answer<br/>[llm_service.py]"]
  node_translation["Translation"]
  node_mongo[("Query History<br/>[mongo_service.py]")]
end

node_farmer(("Farmer"))
node_admin(("Admin"))

node_farmer -->|"uses"| node_web_app
node_admin -->|"uses"| node_web_app
node_web_app -->|"routes to"| node_farmer_ui
node_web_app -->|"routes to"| node_admin_ui
node_farmer_ui -->|"renders"| node_query_controls
node_farmer_ui -->|"renders"| node_answer_evidence
node_admin_ui -->|"links to"| node_admin_upload_ui
node_query_controls -.->|"submits query"| node_api_client
node_farmer_ui -->|"requests answers"| node_api_client
node_admin_upload_ui -->|"uploads resources"| node_api_client
node_api_client -->|"calls API"| node_http_api
node_auth_context -->|"calls auth endpoints"| node_api_client
node_http_api -->|"routes query"| node_retrieval
node_http_api -->|"checks identity"| node_auth
node_http_api -->|"handles uploads"| node_ingestion
node_cli -->|"runs queries"| node_retrieval
node_retrieval -->|"classifies query"| node_intent
node_retrieval -->|"requests traversal"| node_graph_service
node_graph_service -->|"reads and updates"| node_graph_store
node_retrieval -->|"resolves sources"| node_provenance
node_retrieval -->|"checks claims"| node_conflict
node_retrieval -->|"checks telemetry"| node_sensor_validation
node_retrieval -->|"builds answer"| node_llm
node_retrieval -->|"logs query"| node_mongo
node_http_api -->|"translates text"| node_translation
node_ingestion -->|"extracts text"| node_pdf_extract
node_ingestion -->|"chunks and indexes"| node_chunking
node_ingestion -->|"extracts entities"| node_entity_extract
node_ingestion -->|"normalizes entities"| node_normalizer
node_ingestion -->|"validates relations"| node_ingest_validation
node_ingestion -->|"attaches provenance"| node_provenance
node_ingestion -->|"audits claims"| node_conflict
node_ingestion -->|"updates graph"| node_graph_service

click node_web_app "https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/App.jsx"
click node_farmer_ui "https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/pages/FarmerHome.jsx"
click node_query_controls "https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/components/QueryBox.jsx"
click node_answer_evidence "https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/components/AnswerCard.jsx"
click node_admin_ui "https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/pages/AdminHome.jsx"
click node_admin_upload_ui "https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/pages/AdminUpload.jsx"
click node_api_client "https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/api/api.js"
click node_auth_context "https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/auth/AuthContext.jsx"
click node_http_api "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/main.py"
click node_auth "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/services/auth_service.py"
click node_cli "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/cli.py"
click node_ingestion "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/document_service.py"
click node_pdf_extract "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/pdf_extractor.py"
click node_chunking "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/semantic_index.py"
click node_entity_extract "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/entity_extractor.py"
click node_normalizer "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/normalizer.py"
click node_ingest_validation "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/validator.py"
click node_retrieval "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/retrieval/service.py"
click node_intent "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/retrieval/intent.py"
click node_graph_service "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/graph/service.py"
click node_graph_store "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/graph/service.py"
click node_provenance "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/provenance/tracker.py"
click node_conflict "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/conflict/engine.py"
click node_sensor_validation "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/validation/validator.py"
click node_llm "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/services/llm_service.py"
click node_translation "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/services/translation_service.py"
click node_mongo "https://github.com/gittaboina1-ops/agriculture/blob/main/backend/services/mongo_service.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_app,node_farmer_ui,node_query_controls,node_answer_evidence,node_admin_ui,node_admin_upload_ui,node_api_client,node_auth_context toneBlue
class node_http_api,node_auth,node_cli toneAmber
class node_ingestion,node_pdf_extract,node_chunking,node_entity_extract,node_normalizer,node_ingest_validation toneMint
class node_retrieval,node_intent,node_graph_service,node_graph_store,node_provenance,node_conflict,node_sensor_validation,node_llm,node_translation,node_mongo toneRose
class node_farmer,node_admin toneIndigo
```

## Components

### User Interfaces

- [Web App](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Farmer Experience](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/pages/FarmerHome.jsx): `frontend/src/pages/FarmerHome.jsx`
- [Query and Voice](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/components/QueryBox.jsx): `frontend/src/components/QueryBox.jsx`
- [Answer and Evidence](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/components/AnswerCard.jsx): `frontend/src/components/AnswerCard.jsx`
- [Admin Console](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/pages/AdminHome.jsx): `frontend/src/pages/AdminHome.jsx`
- [Resource Upload](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/pages/AdminUpload.jsx): `frontend/src/pages/AdminUpload.jsx`
- [API Client](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/api/api.js): `frontend/src/api/api.js`
- [Session Context](https://github.com/gittaboina1-ops/agriculture/blob/main/frontend/src/auth/AuthContext.jsx): `frontend/src/auth/AuthContext.jsx`

### Backend API

- [HTTP API](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/main.py): `backend/main.py`
- [Authentication](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/services/auth_service.py): `backend/services/auth_service.py`
- [Terminal Assistant](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/cli.py): `backend/cli.py`

### Knowledge Pipeline

- [Ingestion Orchestrator](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/document_service.py): `backend/ingestion/document_service.py`
- [Document Extraction](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/pdf_extractor.py): `backend/ingestion/pdf_extractor.py`
- [Chunking and Index](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/semantic_index.py): `backend/ingestion/semantic_index.py`
- [Entity Extraction](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/entity_extractor.py): `backend/ingestion/entity_extractor.py`
- [Entity Normalization](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/normalizer.py): `backend/ingestion/normalizer.py`
- [Schema Validation](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/ingestion/validator.py): `backend/ingestion/validator.py`

### Domain Services

- [Query Retrieval](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/retrieval/service.py): `backend/retrieval/service.py`
- [Intent Detection](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/retrieval/intent.py): `backend/retrieval/intent.py`
- [Graph Traversal](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/graph/service.py): `backend/graph/service.py`
- [Knowledge Graph](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/graph/service.py): `backend/graph/service.py`
- [Source Provenance](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/provenance/tracker.py): `backend/provenance/tracker.py`
- [Conflict Detection](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/conflict/engine.py): `backend/conflict/engine.py`
- [Sensor Guardrails](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/validation/validator.py): `backend/validation/validator.py`
- [Grounded Answer](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/services/llm_service.py): `backend/services/llm_service.py`
- [Translation](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/services/translation_service.py): `backend/services/translation_service.py`
- [Query History](https://github.com/gittaboina1-ops/agriculture/blob/main/backend/services/mongo_service.py): `backend/services/mongo_service.py`

### Other components

- **Farmer**
- **Admin**

## Connections

- Farmer → Web App: uses (evidence: `README.md`)
- Admin → Web App: uses (evidence: `README.md`)
- Web App → Farmer Experience: routes to (evidence: `frontend/src/App.jsx`)
- Web App → Admin Console: routes to (evidence: `frontend/src/App.jsx`)
- Farmer Experience → Query and Voice: renders (evidence: `frontend/src/pages/FarmerHome.jsx`)
- Farmer Experience → Answer and Evidence: renders (evidence: `frontend/src/pages/FarmerHome.jsx`)
- Admin Console → Resource Upload: links to (evidence: `frontend/src/App.jsx`)
- Query and Voice → API Client: submits query
- Farmer Experience → API Client: requests answers (evidence: `frontend/src/pages/FarmerHome.jsx`)
- Resource Upload → API Client: uploads resources (evidence: `frontend/src/pages/AdminUpload.jsx`)
- API Client → HTTP API: calls API (evidence: `README.md`)
- Session Context → API Client: calls auth endpoints (evidence: `frontend/src/auth/AuthContext.jsx`)
- HTTP API → Query Retrieval: routes query (evidence: `backend/main.py`)
- HTTP API → Authentication: checks identity (evidence: `backend/main.py`)
- HTTP API → Ingestion Orchestrator: handles uploads (evidence: `backend/main.py`)
- Terminal Assistant → Query Retrieval: runs queries (evidence: `backend/cli.py`)
- Query Retrieval → Intent Detection: classifies query (evidence: `backend/retrieval/service.py`)
- Query Retrieval → Graph Traversal: requests traversal (evidence: `backend/retrieval/service.py`)
- Graph Traversal → Knowledge Graph: reads and updates (evidence: `backend/graph/service.py`)
- Query Retrieval → Source Provenance: resolves sources (evidence: `backend/retrieval/service.py`)
- Query Retrieval → Conflict Detection: checks claims (evidence: `backend/retrieval/service.py`)
- Query Retrieval → Sensor Guardrails: checks telemetry (evidence: `backend/retrieval/service.py`)
- Query Retrieval → Grounded Answer: builds answer (evidence: `backend/retrieval/service.py`)
- Query Retrieval → Query History: logs query (evidence: `backend/retrieval/service.py`)
- HTTP API → Translation: translates text (evidence: `backend/main.py`)
- Ingestion Orchestrator → Document Extraction: extracts text (evidence: `backend/ingestion/document_service.py`)
- Ingestion Orchestrator → Chunking and Index: chunks and indexes (evidence: `backend/ingestion/document_service.py`)
- Ingestion Orchestrator → Entity Extraction: extracts entities (evidence: `backend/ingestion/document_service.py`)
- Ingestion Orchestrator → Entity Normalization: normalizes entities (evidence: `backend/ingestion/document_service.py`)
- Ingestion Orchestrator → Schema Validation: validates relations (evidence: `backend/ingestion/document_service.py`)
- Ingestion Orchestrator → Source Provenance: attaches provenance (evidence: `README.md`)
- Ingestion Orchestrator → Conflict Detection: audits claims (evidence: `README.md`)
- Ingestion Orchestrator → Graph Traversal: updates graph (evidence: `README.md`)
