RAG / Legal AI · Independent project
Law Agent: Multilingual Legal RAG Application
Dmitri Derevjanko built Law Agent, a multilingual legal RAG application that answers questions about Estonian law with source citations.
This is one of 10+ independent public projects by Dmitri Derevjanko. 100+ additional workflows were delivered professionally, mostly under confidentiality, and are not documented here.
Open live demo Back to portfolio
Problem
Generic chat models can sound fluent on legal questions while citing the wrong statute, mixing versions of the law, or inventing provisions. People looking up Estonian law need answers tied to the text in force, not a plausible summary.
Solution
Law Agent is a source-grounded legal assistant. It retrieves statutory chunks from a maintained Estonian law corpus, answers in Estonian, English, or Russian, and shows the provisions used. Weak evidence makes the system more conservative instead of more confident.
What Dmitri Derevjanko built
Dmitri designed and implemented the full product: Riigi Teataja ingestion, chunking, embeddings, version-aware retrieval, confidence and strict-mode behaviour, the ET/EN/RU interface, citation inspection, benchmark pages, and 24/7 deployment with Docker, TLS, rate limits, and scheduled corpus sync.
Architecture
- Ingest Estonian statutes from Riigi Teataja, normalize structure, and split them into searchable legal chunks.
- Store embeddings in PostgreSQL with pgvector and refresh the corpus on a schedule instead of one-off reindexing.
- Retrieve by semantic match plus the law in force on the requested date, including current-law filtering.
- Generate answers that prefer quoted excerpts and direct citations; downgrade certainty when support is thin.
- Expose the product through a multilingual UI with citation inspection, corpus stats, and a public benchmark against a generic GPT baseline.
- Run behind Nginx with Docker, GitHub Actions, Redis, structured logging, backups, and smoke checks.
Technologies
- FastAPI
- PostgreSQL
- pgvector
- Redis
- OpenAI API
- Docker
- GitHub Actions
- Nginx
Result
A public legal RAG demo with 181k chunks over 16k+ legal records, automatic corpus updates, citation-first answers, and a benchmark that compares grounded replies with generic model output.
Limitations
- This is a personal demo of a legal RAG system, not a law firm, not legal advice, and not a substitute for a qualified lawyer.
- Coverage is Estonian statutory material in the indexed corpus, not every commentary, court decision, or private contract.
- Retrieval and model limits still apply; users should open the cited provision before relying on an answer.
Live demo and source
Live demo: https://counsel.dmitriderevjanko.com/
GitHub: source is not public. The live demo is the public artifact for this project.
Portfolio case study: https://dmitriderevjanko.com/projects/law-agent/