How kushagrittan/sahaybot works
SahayBot is a bilingual cooperative-governance and legal-assistance chatbot. A user submits text or browser-recognized speech through the chat UI; the app calls the FastAPI query endpoint, which retrieves document context from Chroma and uses Ollama to generate a grounded answer with source metadata. Users can also upload PDFs: the API invokes ingestion, which loads and chunks documents, embeds them, and updates the vector store. The README also describes Hindi/English voice interaction and page citations. The map reflects sampled source; unsampled UI and runtime details are represented only where documented.
Main entry points: ingest.py Ingestion pipeline · main.py FastAPI endpoints · App.tsx Chat app · api.ts API client
Components 18
Chat interface
- Message input
frontend/src/components/MessageInput.tsx - Chat app
frontend/src/App.tsx - Chat display
frontend/src/components/ChatWindow.tsx - API client
frontend/src/services/api.ts
API orchestration
- FastAPI endpoints
backend/main.py
Document ingestion
- Ingestion pipeline
backend/ingest.py - PDF documents
data/.gitkeep - PDF loading
backend/ingest.py - Text chunking
backend/ingest.py - Multilingual embeddings
backend/ingest.py - Ingestion manifest
backend/ingest.py
Grounded answering
- Chroma vector store
backend/main.py - Retrieval QA
backend/main.py - Grounding prompt
backend/main.py - Answer and sources
backend/main.py
Other components
- User
- Browser speech APIs
- Ollama LLM
Connections 22
- User → Message input: enters question
- Message input → Chat app: sends text
- Message input → Browser speech APIs: uses speech input
- Chat app → Browser speech APIs: speaks answer
- Chat app → Chat display: renders messages
- Chat app → API client: requests query or upload
- API client → FastAPI endpoints: calls endpoint
- FastAPI endpoints → Ingestion pipeline: invokes ingestion
- Ingestion pipeline → PDF documents: reads PDFs
- Ingestion pipeline → Ingestion manifest: reads and updates hashes
- Ingestion pipeline → PDF loading: loads pages
- Ingestion pipeline → Text chunking: splits documents
- Ingestion pipeline → Multilingual embeddings: creates embeddings
- Ingestion pipeline → Chroma vector store: adds chunks
- FastAPI endpoints → Chroma vector store: opens store
- FastAPI endpoints → Retrieval QA: builds and invokes chain
- Retrieval QA → Chroma vector store: retrieves context
- FastAPI endpoints → Grounding prompt: configures grounding
- Retrieval QA → Ollama LLM: generates answer
- FastAPI endpoints → Answer and sources: packages answer and citations
- Answer and sources → API client: returns response
- API client → Chat app: returns data