How rajgurubhosale/legalsathiai works
LegalSaathi AI is an Indian legal research assistant: users ask questions through a Streamlit interface, which reaches a FastAPI service and an agent-backed RAG workflow that returns streamed, citation-backed answers. The workflow decomposes questions, retrieves and reranks statutory or user-vault passages, then generates an answer; separate branches handle accounts, chat state, private-document management, corpus ingestion, and evaluation. The README documents the hybrid search and model capabilities, but their implementation details are not fully excerpted, so some stage relationships rely on that documentation.
Main entry points: pipeline.py RAG pipeline · main.py FastAPI application · routes.py Chat and vault routes · pipeline_graph.py Legal search agent
Components 21
User interface
- Streamlit interface
frontend/app.py - Frontend API client
frontend/api.py
API and accounts
- FastAPI application
src/backend/main.py - Authentication routes
src/backend/api/routers/auth.py - JWT and passwords
src/backend/core/security.py - User records
src/backend/db/users.py - Chat and vault routes
src/backend/api/routers/routes.py - Chat streaming
src/backend/services/chat.py
Legal answer workflow
- RAG pipeline
src/genration_pipeline/pipeline.py - Legal search agent
src/genration_pipeline/pipeline_graph.py - Legal prompts
src/genration_pipeline/new_prompts.py - Model setup
src/genration_pipeline/model.py - Hybrid retrieval and reranking
src/rag_retrieval/retrival.py
Document stores
- Personal document vault
src/backend/services/vault.py - PostgreSQL
- Chroma vector stores
Corpus and evaluation
- Statute ingestion
src/data_ingestion/ingest_and_chunk.py - Embedding and indexing
src/data_ingestion/embed_and_store.py - RAG evaluation
src/evalutions/main_evalution_pipeline.py
Other components
- Legal researcher
- Groq language models
Connections 31
- Legal researcher → Streamlit interface: asks
README.md - Streamlit interface → Frontend API client: uses
frontend/app.py - Frontend API client → FastAPI application: calls API
- FastAPI application → Authentication routes: registers
src/backend/main.py - FastAPI application → Chat and vault routes: registers
src/backend/main.py - Authentication routes → JWT and passwords: hashes and signs
src/backend/api/routers/auth.py - Authentication routes → User records: reads and writes
src/backend/api/routers/auth.py - Authentication routes → PostgreSQL: uses database session
src/backend/api/routers/auth.py - FastAPI application → RAG pipeline: initializes
src/backend/main.py - FastAPI application → Legal search agent: builds agent
src/backend/main.py - FastAPI application → Personal document vault: initializes
src/backend/main.py - Chat and vault routes → Chat streaming: streams answers
src/backend/api/routers/routes.py - Chat and vault routes → Legal search agent: reads agent state
src/backend/api/routers/routes.py - Chat and vault routes → Personal document vault: processes uploads
src/backend/api/routers/routes.py - Chat and vault routes → User records: manages documents
src/backend/api/routers/routes.py - Chat and vault routes → PostgreSQL: persists chat and metadata
src/backend/api/routers/routes.py - Chat streaming → Legal search agent: streams responses
- Legal search agent → RAG pipeline: searches statutes
src/genration_pipeline/pipeline_graph.py - Legal search agent → Personal document vault: searches user files
src/genration_pipeline/pipeline_graph.py - RAG pipeline → Hybrid retrieval and reranking: retrieves and reranks
src/genration_pipeline/pipeline.py - RAG pipeline → Legal prompts: uses prompts
src/genration_pipeline/pipeline.py - RAG pipeline → Model setup: creates model
src/genration_pipeline/pipeline.py - Legal search agent → Legal prompts: uses system prompt
src/genration_pipeline/pipeline_graph.py - RAG pipeline → Groq language models: generates answers
README.md - Hybrid retrieval and reranking → Chroma vector stores: searches vectors
- Personal document vault → Chroma vector stores: stores and searches
src/backend/services/vault.py - Personal document vault → PostgreSQL: stores metadata
- Statute ingestion → Embedding and indexing: prepares corpus
- Embedding and indexing → Chroma vector stores: indexes embeddings
- RAG evaluation → RAG pipeline: evaluates answers
src/evalutions/main_evalution_pipeline.py - Hybrid retrieval and reranking → Groq language models: uses reranker
README.md