How dsaiteja007/kisan-ai-sahayak works
Sampurn Kisan AI is an agricultural assistant with a web interface and a FastAPI service. The principal chat workflow hydrates farmer context, runs an agent orchestrator, formats a cited response, and updates memory. The interface also exposes crop, fertilizer, weather, market, soil, satellite, and government-scheme features. Sampled source confirms memory and document-ingestion internals; several API and agent subsystems are represented by tree paths only, so their internal wiring is not inferred.
Main entry points: manager.py Memory manager · chat_service.py Chat service · ingestion.py Document ingestion · App.jsx Web application
Components 29
Farmer interface
- Web application
frontend/src/App.jsx - Shared farm context
frontend/src/context/GlobalContext.jsx - Farming feature pages
frontend/src/pages
API service
- Weather endpoint
src/api/v1/agriculture.py - FastAPI application
src/api/app.py - Chat endpoint
src/api/v1/chat.py - Agriculture endpoints
src/api/v1/agriculture.py
Assistant runtime
- Chat service
src/services/chat_service.py - Agent orchestrator
src/orchestrator/graph.py - Agent nodes
src/orchestrator/nodes.py - Intent routing
src/orchestrator/router_interface.py - Agriculture tools
src/tools/implementations - Tool registry
src/tools/registry.py - Prompt construction
src/prompts/builder.py - LLM providers
src/llm/providers
Knowledge and memory
- Memory manager
src/memory/manager.py - Working memory
src/memory/working_memory.py - Short-term memory
src/memory/short_term.py - Long-term memory
src/memory/long_term.py - Semantic memory
src/memory/semantic_memory.py - History summarizer
src/memory/summarizer.py - Document ingestion
src/rag/ingestion.py - Document retrieval
src/rag/retriever.py - Vector store
src/rag/vector_store.py - Embedding manager
src/rag/embeddings.py - Text splitter
src/rag/text_splitter.py
Agriculture integrations
- Agriculture API clients
src/integrations
Other components
- Farmer
- Agriculture data services
Connections 21
- Farmer → Web application: uses
- Web application → Farming feature pages: routes to
- Web application → Shared farm context: provides context
- Shared farm context → Weather endpoint: fetches weather
- Farmer → FastAPI application: API requests
- FastAPI application → Chat endpoint: mounts routes
- FastAPI application → Agriculture endpoints: mounts routes
- Chat endpoint → Chat service: processes chat
- Chat service → Memory manager: hydrates and updates
- Chat service → Agent orchestrator: executes
- Chat service → Farmer: returns response
- Memory manager → Short-term memory: reads and writes
- Memory manager → Long-term memory: reads and writes
- Memory manager → Semantic memory: reads and writes
- Memory manager → History summarizer: checks history
- Memory manager → Working memory: hydrates
- Agent orchestrator → Agent nodes: dispatches
- Document ingestion → Text splitter: splits text
- Document ingestion → Embedding manager: creates vectors
- Document ingestion → Vector store: upserts documents
- Agriculture API clients → Agriculture data services: calls APIs