AI Legal Assistant background

RAG Development Case Study

Legal teams managing large contract collections need fast, reliable access to specific clauses and terms. Traditional keyword search struggles when the wording of a question differs from the language in the documents. General-purpose AI tools can answer faster, but without verifiable source references, their responses are difficult to trust with sensitive legal information.

Droxic built a Retrieval-Augmented Generation (RAG) application that lets users ask natural-language questions about individual contracts or an entire document collection. The system finds relevant passages, generates clear answers using Claude AI, and links every response to the exact page and highlighted section in the original PDF all without hallucinating.

01

Context & Problem

Finding specific information across a collection of legal contracts means opening multiple files, searching through pages, and manually comparing clauses. For legal teams reviewing dozens or hundreds of documents, this is slow and repetitive work.

General-purpose AI chatbots can speed things up, but they introduce a different problem. Without clear source references, there is no way to verify where an answer came from. For legal work, where accuracy is non-negotiable, an unsupported answer is worse than no answer at all.

The goal was to build an AI assistant that could answer natural-language questions about legal documents while keeping every response grounded in the original source. Not just an answer, but a citation: the document, the page, and the exact text.

02

Project Gallery

AI Legal Assistant Login Page
AI Legal Assistant Chat Area
03

Our Solution & Technologies

Droxic built the application as a Retrieval-Augmented Generation (RAG) system. During document upload, the system extracts text from each PDF page along with its exact position on the page. The content is split into searchable sections and converted into vector embeddings stored in PostgreSQL with pgvector. When a user asks a question, the system retrieves the most relevant passages and provides them to Claude AI as context for generating the answer.

Every answer includes citations linked to the original document, page number, and text coordinates. Users can open the source PDF directly from the conversation and see the exact clause highlighted on the page. This is the difference between a chatbot that gives plausible answers and a tool that legal teams can actually rely on.

The application supports both single-document and collection-wide search. Users can ask a question about one specific contract or query across all uploaded documents at once. A full conversation history with source references is maintained, so teams can revisit previous questions without repeating the search.

The backend was built with Python and FastAPI, with streaming responses delivered through Server-Sent Events to keep the conversation responsive while the system processes searches and generates answers. The frontend uses React and TypeScript with an integrated PDF viewer for inline source verification. OCR support means the system also handles scanned documents.

Technologies used

React, TypeScript, Python, FastAPI, PostgreSQL, pgvector, Claude AI, Retrieval-Augmented Generation (RAG), PyMuPDF, PDF.js, Server-Sent Events, OCR, REST API

04

Project Timeline & Team

Duration

5 months

Team size

2 people

A two-person team designed and built the full application over five months, from initial architecture through to a working product. The project covered document processing pipeline, vector search infrastructure, conversational AI interface, PDF viewer with citation highlighting, and authentication with audit logging.

05

Impact & Results

The application gives legal teams a faster, more reliable way to find information across contract collections. Instead of opening files and scanning pages manually, they ask a question and get an answer with a direct link to the source.

Every response is traceable. Users can verify any answer against the original document in seconds, which reduces the risk that comes with relying on AI-generated text for legal decisions.

The system handles confidential documents securely, with authentication and audit logging built in from the start. The architecture is ready for larger document collections and additional AI-powered workflows as the client's needs grow.