Nyaya.AI
RAG based Legal AI agent
The problem Nyaya.AI solves
Navigating India’s legal system is intimidating for most people. Legal language is complicated, relevant case laws are hard to find, and expert guidance is expensive or inaccessible—especially for individuals and small businesses.
Nyaya.ai solves this by providing instant, AI-powered legal assistance in plain English. Our platform enables users to ask legal questions and receive clear, context-aware answers, referencing real case laws from our vast database. Whether you’re confused about a notice, need to understand your rights, or want to prepare before talking to a lawyer, Nyaya.ai gives you understandable, trustworthy guidance—anytime, anywhere. This empowers users to make informed decisions, reduces anxiety, and makes justice accessible to everyone.
Challenges we ran into
- Managing Large Legal Datasets
We quickly realized that legal case files, embeddings, and model artifacts can be massive. GitHub’s 100MB file size limit repeatedly blocked our pushes and made team collaboration difficult. We solved this by restructuring our repo, removing large files from version control, using .gitignore to keep only code/config, and handling large data exclusively on our backend.
- Secret & API Key Leaks
At several points, our API keys (OpenAI, Gemini, Groq) accidentally made their way into the repo, triggering GitHub’s secret scanning and blocking further pushes. We learned to use environment variables, added .env to .gitignore, and carefully purged secrets from our git history to maintain security.
- Frontend–Backend Connectivity (CORS)
The React frontend often failed to communicate with our Flask backend due to CORS issues, especially in local development. We resolved this by adding Flask-CORS middleware to safely allow cross-origin API requests.
- Retrieval-Augmented Generation (RAG) Tweaks
Switching from OpenAI’s embeddings API (with frequent errors or missing access) to a local FAISS-based approach was tricky. We further improved relevance by automatically summarizing retrieved legal cases before sending them to the LLM, ensuring that Gemini’s context window was never overloaded.
- Keeping the UI Modern and User-Friendly
Our team experimented with multiple UI versions, resulting in confusion over design consistency. We merged the best of both worlds—using a modern, visually clean React interface (with bubbles, subtle gradients, and a collapsible debug window) while retaining the straightforward usability of our first prototype.
- Making the AI Genuinely Helpful
Early on, Gemini would often avoid specific answers or say “I can’t give legal advice.” Through extensive prompt engineering, we crafted a system prompt that makes Nyaya AI reassuring, positive, and always eager to explain legal principles, reference IPC sections, and outline next steps—without using confusing markdown formatting.
- Version Control & DevOps Hurdles
We faced issues with oversized files, branch mismatches (master/main), and line ending conflicts (LF/CRLF) on Windows. With careful git history rewriting, force pushes, and a standard .gitignore, we delivered a clean, deployable repository.
Tracks Applied (1)
