Inspiration

Legal documents are often written for legal professionals, not ordinary people. Important clauses, obligations, risks, and differences between agreements can be difficult to understand, especially when documents are long and filled with legal terminology.

We wanted to build something that makes legal information easier to understand without pretending to replace a lawyer. This led us to LegalLens — a GenAI-powered assistant designed to help people understand their own legal documents and prepare better questions for a qualified legal professional.

What it does

LegalLens turns complex legal documents into clear, structured information.

Users can:

  • Upload PDF, DOCX, or TXT legal documents.
  • Simplify documents into elementary, plain-English, or detailed explanations.
  • Extract important clauses such as obligations, termination, payment, confidentiality, liability, and more.
  • Identify potential areas of risk and provide a reason for the classification.
  • Compare 2–5 documents clause-by-clause and identify meaningful differences.
  • Ask questions about uploaded documents using document-grounded AI.
  • View source citations for answers so users can verify where the information came from.
  • Generate summaries, action checklists, comparison reports, and lawyer-preparation briefs.
  • Export results as PDF, DOCX, or Markdown.

LegalLens provides general information about user-provided documents and is not a substitute for professional legal advice.

How we built it

We built LegalLens as a full-stack web application.

The frontend uses Next.js, React, TypeScript, Tailwind CSS, and TanStack Query. The backend is built with Python, FastAPI, SQLAlchemy, and Celery.

For the AI layer, we use Anthropic Claude for document understanding, simplification, clause analysis, comparison, and question answering. Voyage AI embeddings are used to represent document content for semantic retrieval.

Our document Q&A system uses Retrieval-Augmented Generation (RAG). Uploaded documents are parsed, chunked, embedded, and stored using PostgreSQL with pgvector. When a user asks a question, the system retrieves the most relevant passages and provides them to the language model, allowing the response to remain grounded in the user's documents. Answers include citations to relevant source passages.

We use Redis and Celery for background processing and AWS S3/MinIO for document storage. The entire application can be run using Docker and Docker Compose.

We also implemented security measures including Argon2id password hashing, JWT authentication, MFA, file validation, and immutable audit logging.

Challenges we ran into

One of our biggest challenges was making sure the AI did not simply generate a plausible-sounding legal answer. For a legal-document application, answers need to remain grounded in the documents provided by the user.

We addressed this by building a RAG pipeline with document chunking, vector retrieval, source citations, and evaluation tests.

Another challenge was handling long legal documents. Sending an entire document to an AI model is inefficient and can make important information harder to retrieve. We solved this through document processing, chunking, embeddings, retrieval, and multi-step processing for long documents.

Comparing legal documents was another challenge because simple text differences are not always meaningful. LegalLens therefore performs clause-oriented comparison and identifies differences at the clause level rather than treating the documents as ordinary text files.

Accomplishments that we're proud of

We are proud that LegalLens goes beyond a basic legal chatbot.

The system combines document simplification, clause extraction, risk analysis, document comparison, RAG-based Q&A, citations, and actionable outputs in one workflow.

We also built the project as a complete application rather than only a prototype AI prompt. It includes authentication, document processing, vector search, background workers, exports, testing, security controls, and an end-to-end web interface.

Most importantly, we designed the system around the principle that AI should help users understand and prepare, rather than present itself as a replacement for a qualified lawyer.

What we learned

Building LegalLens taught us that applying GenAI to a high-stakes domain requires more than getting good-looking model responses.

We learned the importance of:

  • Grounding AI responses in reliable source material.
  • Providing citations so users can verify information.
  • Designing retrieval systems for long documents.
  • Separating general information from professional advice.
  • Evaluating LLM outputs instead of relying only on subjective quality.
  • Combining traditional software engineering with AI systems.
  • Treating security, privacy, and auditability as core product requirements.

What's next for LegalLens

We plan to make LegalLens more robust and useful across different types of legal documents and jurisdictions.

Future improvements could include stronger multilingual support, improved OCR for scanned documents, more advanced clause relationships, better retrieval evaluation, customizable document workflows, and additional safeguards for high-risk legal information.

Our long-term goal is to make legal documents easier to understand while keeping the human lawyer at the center of important legal decisions.

Built With

Share this project:

Updates

Submission history