कानुन साथी (Kanun Sathi)
Jan 2026 · Team of four · AI / full stack · by Abhiyan Khanal
We built an AI legal companion for Nepali citizens. You ask a legal question in Nepali or English and get an answer grounded in the actual legal documents, with the source cited down to the page so you can check it yourself. Lawyers get their own dashboard to upload documents and research across them.

Features
- Chat in Nepali with answers that cite filename and page
- Retrieval-augmented generation over PDFs such as the Constitution of Nepal
- Lawyer dashboard: upload documents, select which to search, and ask questions
- Saved chat history, login and lawyer registration
The problem
Many young people in Nepal have no reliable way to check what the law actually says. They end up relying on social media or on relatives' personal experience. We wanted a tool where every answer can be traced back to a specific provision in a specific document, instead of a confident-sounding reply from a chatbot.
How it works
- Legal PDFs (the Constitution, criminal and family law, transport regulations and so on) are uploaded and processed in the background by ARQ workers on Redis, so a large document never blocks the API.
- Each document is split into overlapping chunks (2,000 characters with 200 overlap) and turned into 768-dimension embeddings with Ollama's nomic-embed-text model. The vectors live in PostgreSQL using the pgvector extension.
- A question is matched against the stored chunks by similarity search. The best passages are passed to Gemini 2.5 Flash, which was chosen because it handled Nepali better than the local models we tried.
- The prompt forces the model to answer only from the retrieved context and to put a [filename, page X] citation after every fact. The interface pulls those out into a Sources card under the answer.
Frontend
A React and TypeScript app built with Vite and Tailwind CSS. It has a landing page with example questions, a chat view with a sidebar of saved conversations, answer and citation cards, login and sign-up, and a lawyer dashboard with My Documents, Legal Research, Clients and Profile sections. In Legal Research a lawyer ticks which uploaded documents to search, asks a question in Nepali or English, and gets an answer with sources and a history of past queries. Lawyer registration is its own feature module with validation schemas and tests.
Infrastructure
The whole stack runs from Docker Compose: the FastAPI service, PostgreSQL with pgvector, Redis and Ollama. The backend builds on the open-source Morphik Core RAG framework, which we configured for Nepali legal documents rather than writing the retrieval engine from scratch.
Tech stack
More projects by Abhiyan Khanal
- Gantabya: Started at KU HackFest 2024 · Team project · Full stack
- Janakpur Fish House: Client project · Web · Live at janakpurfishhouse.com
- CogniCare: Nov 2024 · Team of five · Mobile + backend
- Evolutionary Creatures: Jun – Aug 2024 · Team of two · C++ simulation
- Hamro Bus: Oct 2024 · Team project · Web, built in a few days
- DDA Drug Registration Portal: Jan 2026, revamped Nov 2026 · Team of four · Full stack