How kathirvbk/ai-agriculture-assistant works
AgriSense is an agricultural advisory platform: users authenticate, submit text or voice consultations (optionally with a soil report), and receive structured, context-aware guidance. The backend API delegates consultation processing to a rules-and-crop pipeline, which can use local retrieval, web search, and an LLM; the API also manages sessions and persisted chat history. The graph preserves documented voice capabilities, though the excerpts do not show their full wiring. Some backend relationships are supported by the source index rather than complete call-site excerpts.
Main entry points: pipeline.py Query Pipeline · app.py FastAPI Routes · query.py Context Retrieval · App.js Consultation UI
Components 20
Web Client
- Consultation UI
frontend/src/App.js - Authentication UI
frontend/src/components/Auth/AuthPage.js
API and Sessions
- FastAPI Routes
backend/app.py - Chat Persistence
backend/core/database.py
Advisory Workflow
- Query Pipeline
backend/core/pipeline.py - Crop Filtering
backend/core/crop_engine.py - Crop Knowledge
backend/knowledge/crop_info.py - Query Validation
backend/utils/validator.py - Agricultural Guardrails
backend/utils/guardrails.py - Context Manifest
backend/utils/context_classifier.py
Knowledge and Synthesis
- Context Retrieval
backend/rag/query.py - Semantic Retrieval
backend/rag/rag_pipeline.py - Vector Store
backend/rag/vector_store.py - Embeddings
backend/rag/embeddings.py - Web Search
backend/agents/web_agent.py - Answer Generation
backend/rag/llm.py
Identity and Voice
- Firebase Client
frontend/src/firebase.js - Backend Token Verification
backend/utils/firebase_auth.py - Voice Services
backend/voice
Other components
- Farmer
Connections 23
- Farmer → Consultation UI: consults through
README.md - Consultation UI → FastAPI Routes: sends API requests
README.md - Consultation UI → Authentication UI: renders
frontend/src/App.js - Authentication UI → Firebase Client: signs in with
frontend/src/components/Auth/AuthPage.js - Consultation UI → Firebase Client: signs out with
frontend/src/App.js - FastAPI Routes → Backend Token Verification: verifies tokens
backend/app.py - FastAPI Routes → Chat Persistence: persists sessions
backend/app.py - FastAPI Routes → Query Pipeline: runs queries
backend/app.py - FastAPI Routes → Query Validation: validates requests
backend/app.py - FastAPI Routes → Voice Services: serves voice features
README.md - Query Pipeline → Crop Filtering: filters crops
backend/core/pipeline.py - Query Pipeline → Query Validation: validates and grounds
backend/core/pipeline.py - Query Pipeline → Agricultural Guardrails: applies guardrails
backend/core/pipeline.py - Query Pipeline → Context Retrieval: retrieves context
backend/core/pipeline.py - Query Pipeline → Answer Generation: generates guidance
backend/core/pipeline.py - Query Pipeline → Context Manifest: assembles source context
backend/core/pipeline.py - Crop Filtering → Crop Knowledge: uses crop data
backend/core/crop_engine.py - Context Retrieval → Query Validation: checks and grounds
backend/rag/query.py - Context Retrieval → Semantic Retrieval: retrieves local context
backend/rag/query.py - Context Retrieval → Web Search: fetches web context
backend/rag/query.py - Context Retrieval → Answer Generation: synthesizes response
backend/rag/query.py - Semantic Retrieval → Vector Store: searches vectors
backend/rag/rag_pipeline.py - Vector Store → Embeddings: uses embeddings
backend/rag/vector_store.py