Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

139 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LegalKlarity Banner

LegalKlarity

Simplifying legal complexity in seconds. Understand contracts, detect risks, and protect yourself with AI.

Gen AI Exchange Live Demo License Status


Preview

Dashboard Preview

Instant semantic analysis of complex legal jargon.


Table of Contents


Problem Statement

Legal Jargon = Risk. The average person signs dozens of Terms of Service agreements, employment contracts, and NDAs without reading them. Why? Because legal documents are purposefully dense, lengthy, and written in legalese that requires a law degree to decode. This asymmetry of information leaves individuals exposed to predatory clauses, hidden fees, and compromised data rights.


Solution Overview

LegalKlarity leverages advanced Generative AI to democratize legal comprehension. Users upload any legal document, and the platform instantly translates it into plain English.

It highlights critical obligations, flags hidden risks (like auto-renewals or data sharing), and provides an interactive chat interface to interrogate the document.

  • Instant Summarization: Distills 50-page contracts into 5 key points.
  • Risk Flagging: Autonomously detects predatory clauses.
  • Document Q&A: Ask specific questions ("Can they sell my data?").

Core Features

📄 Semantic Contract Summarization

  • What it does: Converts complex legal text into grade 8 reading level summaries.
  • Why it matters: Saves hours of reading and ensures true consent.
  • Technical implementation: Chunking large PDFs and running map-reduce summarization via LLM APIs.

🚩 Automated Risk Detection

  • What it does: Scans for standard predatory clauses against a known vector database of legal risks.
  • Why it matters: Protects users from signing away crucial rights.
  • Technical implementation: Similarity search against a Pinecone index of known bad clauses.

💬 Conversational Interrogation

  • What it does: A chat interface bound strictly to the document's context.
  • Why it matters: Allows users to dynamically query edge cases in the contract.
  • Technical implementation: RAG system with strict temperature limits to prevent hallucination.

System Architecture

Architecture Diagram

Data Flow

  1. Document Upload: PDF parsed via OCR / text extraction on the edge.
  2. Chunking & Embedding: Text is split into semantic nodes and embedded.
  3. Risk Analysis: Embeddings compared against Risk Vector DB.
  4. LLM Synthesis: RAG pipeline synthesizes summaries and answers.

Tech Stack

Category Technology Purpose
Frontend React, Netlify Seamless user experience
Backend Node.js, Express PDF parsing & orchestration
AI/LLM Google Gemini API Deep contextual reasoning
Database MongoDB User histories & document metadata
Vector DB Pinecone Semantic search

Project Structure

src/
 ┣ client/         # React SPA
 ┣ backend/        # Express API
 ┃ ┣ parsers/      # OCR and PDF text extraction
 ┃ ┣ ai/           # LLM chains and prompts
 ┃ ┣ routes/       # API endpoints
 ┃ ┗ utils/        # Error handlers, middlewares
 ┗ shared/         # Common types

Installation Guide

1. Prerequisites

  • Node.js (v18+)

2. Clone & Install

git clone https://github.com/oyelurker/LegalKlarity.git
cd LegalKlarity

# Install backend
cd backend
npm install

# Install frontend
cd ../client
npm install

3. Run Development Server

# Terminal 1: Backend
npm run start:dev

# Terminal 2: Frontend
npm run start

Environment Variables

Variable Description Required
GEMINI_API_KEY Google GenAI API access Yes
MONGO_URI Database connection string Yes
PINECONE_API_KEY Vector database access Yes

AI/ML/LLM Pipeline

LegalKlarity uses a precision-tuned LLM pipeline designed to eliminate hallucinations, as legal advice requires high fidelity.

  • Strict Grounding: The LLM is given system prompts that force it to quote directly from the provided text. If an answer isn't in the document, it must output "Not stated".
  • Multi-Shot Prompting: Risk detection uses few-shot examples of predatory clauses to guide the model's anomaly detection.

Security Measures

  • Zero Data Retention: Uploaded documents are processed in memory and immediately purged post-analysis unless the user explicitly saves them.
  • Encryption in Transit: Strict TLS enforcing.
  • Rate Limiting: Prevent abuse of expensive LLM endpoints.

Roadmap

  • PDF Parsing & Summarization
  • Basic Risk Flagging
  • Interactive Q&A
  • Multi-document cross-reference (e.g., comparing two versions of a contract)
  • Browser Extension for live ToS scanning

License

This project is licensed under the MIT License - see the LICENSE file for details.


Built for the Gen AI Exchange Hackathon '25

About

Instant semantic analysis to simplify legal complexity, decode jargon, and autonomously detect contract risks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages