Legiflow
AI for legal documents: lawyers upload case files and ask questions that are answered only from that case, with citations.
- Role
- Associate Software Engineer, Devsarch
- Stack
- FastAPI · Gemini · Next.js
Hover or tap a box to see what it does, or press play.
The problem
Lawyers were reviewing case documents by hand. A chatbot could speed that up, but only if it never mixed one case with another: an answer drawn from the wrong case file is worse than no answer at all. So the hard requirement was that a question could only ever be answered from the case file in scope.
What I built
- Entity extraction that pulls the structure out of each document into structured storage
- Chunking and embeddings stored in PostgreSQL, every chunk tagged with its case file
- Retrieval scoped to a single case file, so no passage from another case can reach the answer
- Answers written by Gemini from the retrieved passages, each with a citation the lawyer can check
- A FastAPI backend, a Next.js app for lawyers, and case files in Wasabi or S3 storage
How it works
- Case files arrive from Wasabi or S3.
- Entities and structure are extracted from each document.
- The text is split into chunks and embedded.
- Chunks are stored in PostgreSQL, each tagged with its case file.
- A lawyer asks a question about one case.
- Retrieval searches only that case file's chunks.
- Gemini answers from those chunks alone, with a citation.
- The answer and its citation appear in the app.
- Nothing outside the case file can reach the answer.
Results
- Reduced manual review time by 40%
- Processes 1,000+ PDFs a month
- Every answer cites its source in the case file, so it can be verified instead of trusted
More on this in the note Keeping a RAG chatbot inside one case file.