How rutukinnal0123/ai-farming-assistant works
AI Farming Assistant combines a Streamlit farmer-facing app with a FastAPI backend for farmer and farm management, chat, activity tracking, reminders, and history. The principal workflow is a text or voice question routed through chat handling, enriched with farmer, farm, activity, reminder, weather, and retrieved agricultural context, then answered by Gemini and returned to the farmer. The graph follows shown calls and README-documented capabilities; some storage and document-ingestion internals are unsampled, so their connections are limited to documented relationships.
Main entry points: chat.py Chat orchestration · app.py FastAPI routes · ai_service.py Recommendation generation · crud.py Farm and history CRUD
Components 23
Farmer application
- Streamlit interface
frontend/app.py
Backend API
- FastAPI routes
backend/app.py - Authentication
backend/auth.py - Chat orchestration
backend/chat.py - API schemas
backend/schemas.py - JWT security
backend/security.py
Advisory services
- Recommendation generation
backend/services/ai_service.py - Activity detection
backend/services/activity_service.py - Language translation
backend/services/translation_service.py - Speech conversion
backend/services/voice_service.py - Weather lookup
backend/services/weather_service.py
Agricultural knowledge
- Semantic retrieval
backend/rag/retriever.py - Embedding setup
backend/rag/embeddings.py - Agricultural documents
backend/documents - Chroma vector store
backend/rag/chroma.sqlite3
Persistence
- Farm and history CRUD
backend/crud.py - Domain models
backend/models.py - Relational database
backend/database.py
Other components
- Farmer
- Google Gemini
- Weather API
- Google Translate
- Speech services
Connections 26
- Farmer → Streamlit interface: uses
README.md - Streamlit interface → FastAPI routes: calls HTTP API
frontend/app.py - FastAPI routes → Authentication: registers router
backend/app.py - FastAPI routes → Chat orchestration: registers router
backend/app.py - FastAPI routes → Farm and history CRUD: calls CRUD
backend/app.py - FastAPI routes → JWT security: checks identity
backend/app.py - Authentication → Farm and history CRUD: looks up farmer
backend/auth.py - Authentication → JWT security: verifies and issues token
backend/auth.py - Chat orchestration → Farm and history CRUD: loads and saves records
backend/chat.py - Chat orchestration → Activity detection: detects activities
backend/chat.py - Chat orchestration → Language translation: translates messages
backend/chat.py - Chat orchestration → Speech conversion: converts speech
backend/chat.py - Chat orchestration → Recommendation generation: requests answer
backend/chat.py - Chat orchestration → API schemas: builds record payloads
backend/chat.py - FastAPI routes → API schemas: validates route data
backend/app.py - Farm and history CRUD → Domain models: persists domain records
- Domain models → Relational database: uses ORM base
backend/models.py - Recommendation generation → Semantic retrieval: retrieves context
backend/services/ai_service.py - Recommendation generation → Weather lookup: gets local weather
backend/services/ai_service.py - Recommendation generation → Google Gemini: generates response
backend/services/ai_service.py - Weather lookup → Weather API: fetches conditions
backend/services/weather_service.py - Language translation → Google Translate: translates text
backend/services/translation_service.py - Speech conversion → Speech services: transcribes and synthesizes
- Semantic retrieval → Chroma vector store: searches vectors
backend/rag/retriever.py - Agricultural documents → Embedding setup: chunks and embeds
README.md - Embedding setup → Chroma vector store: stores embeddings
README.md