How sunil8521/nyayaai works
NyayaAI is a legal research assistant for Indian legal materials, with chat-based research and a separate legal-document ingestion hub. Users ask questions through the chat UI; the backend chat controller invokes a LangGraph workflow, with chat history and agent checkpoints managed alongside MongoDB-backed chat records. For the knowledge base, users can preview and sync Drive PDFs or upload files; ingestion queues processing and indexes document chunks for retrieval. The README also describes legal drafting and Indian case-law/statute access. Workflow and processor internals are represented from the documented architecture and tree; their wiring was not sampled.
Main entry points: langgraph.controller.ts Chat controller · ingestion.controller.ts Ingestion controller · ingestion.processor.ts Document processor · qdrant.service.ts Vector search service
Components 23
User Experience
- Chat pages
client/app/ask/page.tsx - Chat interface
client/components/chat/AskContainer.tsx - Chat API client
client/lib/api/chat.ts - Ingestion dashboard
client/components/ingestion/IngestionDashboard.tsx - Ingestion API client
client/lib/api/ingestion.ts
Legal Research
- Chat controller
backend/src/langgraph/langgraph.controller.ts - Agent workflow
backend/src/langgraph/workflow.service.ts - Legal tools
backend/src/langgraph/tools.service.ts - Chat records
backend/src/langgraph/schemas/chat.schema.ts - Message records
backend/src/langgraph/schemas/message.schema.ts
Knowledge Ingestion
- Ingestion controller
backend/src/ingestion/ingestion.controller.ts - Drive connector
backend/src/ingestion/google-drive.service.ts - Processing queue
backend/src/ingestion/ingestion.module.ts - Document processor
backend/src/ingestion/ingestion.processor.ts - Chunking
backend/src/ingestion/chunking.util.ts - Embedding service
backend/src/ingestion/embedding.service.ts - Ingestion records
backend/src/ingestion/schemas/ingested-document.schema.ts
Persistence and Retrieval
- Vector search service
backend/src/qdrant/qdrant.service.ts - MongoDB
- Qdrant
Other components
- Legal user
- Google Drive
- Embedding server
Connections 25
- Legal user → Chat pages: asks questions
- Chat pages → Chat interface: renders
- Chat interface → Chat API client: sends messages
- Chat API client → Chat controller: calls chat routes
- Chat controller → Agent workflow: executes workflow
- Chat controller → Chat records: reads and creates
- Chat controller → Message records: reads history
- Agent workflow → Legal tools: uses tools
- Chat controller → MongoDB: persists chat records
- Legal user → Ingestion dashboard: manages documents
- Ingestion dashboard → Ingestion API client: requests ingestion
- Ingestion API client → Ingestion controller: calls ingestion routes
- Ingestion controller → Drive connector: lists Drive PDFs
- Drive connector → Google Drive: fetches files
- Ingestion controller → Ingestion records: tracks status
- Ingestion controller → MongoDB: reads and writes records
- Ingestion controller → Processing queue: queues documents
- Processing queue → Document processor: dispatches jobs
- Document processor → Chunking: chunks documents
- Document processor → Embedding service: requests vectors
- Embedding service → Embedding server: requests embeddings
- Document processor → Vector search service: indexes chunks
- Vector search service → Qdrant: stores and searches vectors
- Legal tools → Vector search service: retrieves legal chunks
- Vector search service → Embedding service: reranks results