The problem
A useful document assistant needs to retrieve the right clauses and show where an answer came from. I built a research application that connects document processing, retrieval and cited responses.
What I built
- Designed and developed the Flutter/Dart frontend, FastAPI backend and PostgreSQL/pgvector database end to end.
- Implemented PDF upload, extraction/OCR, chunking and 384-dimensional SentenceTransformer embeddings.
- Combined semantic and BM25 retrieval with multi-query expansion, reciprocal rank fusion and cross-encoder reranking.
- Added Groq-generated answers with source citations, saved conversations, document comparison and user, legal-professional and administrator workspaces.
- Implemented Firebase authentication, owner-scoped access and duplicate detection, Cloudflare R2 document storage, and role/access tests.
How it fits together
- 01PDF + OCR
- 02Chunks + embeddings
- 03Semantic + BM25
- 04Fusion + reranking
- 05LLM answer + citations
An engineering decision
I combined keyword and semantic retrieval because a legal query can depend on both exact terms and meaning. Reranking and context selection sit before generation, while ownership checks constrain which documents a user can access.
Evaluation & limitations
The project includes access-control and retrieval-related tests. I have not published a comprehensive legal-answer accuracy benchmark. Answers are research assistance and should be checked against the cited source documents.
Next steps
Build a representative retrieval evaluation set, measure citation support, and expand checks for ambiguous or unsupported questions.
