Skip to content

tosoham/LawAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LawAI

Multi-agent Indian Legal AI System for Lawyers, Courts, and Public

License: MIT Python 3.10+ Next.js 14


🎯 Overview

LawAI is an advanced AI-powered legal assistant system designed specifically for the Indian legal framework. It leverages IBM watsonx.ai's Granite-13b-chat-v2 model, LangGraph for agent orchestration, and ChromaDB for vector search to provide intelligent legal assistance.

Key Features

  • πŸ” RAG Search - Query Indian legal corpus (BNS, BNSS, BSA, Supreme Court judgements)
  • πŸ“ Draft Document - Generate legal drafts (bail applications, petitions, notices)
  • πŸ“„ Analyze Document - Extract and analyze uploaded legal documents (PDF/DOCX)
  • πŸ’¬ Chat - Context-aware legal Q&A with accurate citations

Legal Framework (2023+)

  • BNS - Bharatiya Nyaya Sanhita, 2023 (replaces IPC)
  • BNSS - Bharatiya Nagarik Suraksha Sanhita, 2023 (replaces CrPC)
  • BSA - Bharatiya Sakshya Adhiniyam, 2023 (replaces Evidence Act)
  • SC Judgements - Supreme Court rulings under new legal framework

πŸ—οΈ Architecture

Tech Stack

  • LLM: IBM watsonx.ai - Granite-13b-chat-v2
  • Agent Framework: LangGraph for complex workflows
  • Vector DB: ChromaDB (local deployment)
  • Backend: FastAPI with async/await and streaming
  • Frontend: Next.js 14 with TypeScript and Tailwind CSS

System Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Frontend (Next.js)                    β”‚
β”‚  Chat Interface | Search | Document Gen | Doc Analysis  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Backend (FastAPI)                       β”‚
β”‚                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚         LangGraph Agent Orchestrator            β”‚    β”‚
β”‚  β”‚  (Intent Classification & Tool Routing)         β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                            β”‚                             β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚         β–Ό                  β–Ό                  β–Ό         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚   RAG    β”‚      β”‚  Draft   β”‚      β”‚ Analyze  β”‚     β”‚
β”‚  β”‚  Search  β”‚      β”‚ Document β”‚      β”‚   Doc    β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚         β”‚                  β”‚                  β”‚         β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚                            β–Ό                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚         IBM watsonx.ai (Granite-13b)           β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                            β”‚                             β”‚
β”‚                            β–Ό                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  ChromaDB (BNS, BNSS, BSA, SC Judgements)     β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • IBM watsonx.ai account and credentials

Backend Setup

# Navigate to backend directory
cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Copy environment file and configure
cp .env.example .env
# Edit .env with your IBM watsonx.ai credentials

# Run development server
uvicorn main:app --reload

Backend will be available at http://localhost:8000 API documentation at http://localhost:8000/docs

Frontend Setup

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Copy environment file
cp .env.local.example .env.local

# Run development server
npm run dev

Frontend will be available at http://localhost:3000


πŸ“š Documentation


πŸ§ͺ Testing

Backend Tests

cd backend

# Run all tests
pytest

# Run with coverage
pytest --cov=backend --cov-report=html

# Run specific test file
pytest tests/test_main.py -v

Frontend Tests

cd frontend

# Run all tests
npm test

# Run with coverage
npm test -- --coverage

# Run in watch mode
npm run test:watch

🎯 Demo Flows

1. Bail Application Generation

User: "Client arrested under BNS 103"
System: 
  β†’ RAG Search (finds relevant BNSS sections 479/482)
  β†’ Draft Document (generates bail application)
  β†’ Returns downloadable .docx file

2. Case Law Search

User: "SC anticipatory bail rulings last 5 years"
System:
  β†’ RAG Search (queries SC judgements collection)
  β†’ Synthesizes answer with accurate citations
  β†’ Returns formatted response

3. Document Analysis

User: Uploads rental agreement PDF
System:
  β†’ Analyze Document (extracts text and clauses)
  β†’ Identifies risks (termination clauses, indemnity)
  β†’ Returns comprehensive risk summary

πŸ“‹ Project Status

Current Phase: Phase 1 - Project Foundation & Setup βœ…

See COMPLETE_IMPLEMENTATION_PLAN.md for detailed roadmap.


πŸ”’ Security & Compliance

  • βœ… No PII stored in vector database
  • βœ… Input validation and sanitization
  • βœ… Rate limiting on all endpoints
  • βœ… JWT authentication
  • βœ… Legal disclaimers for AI-generated content
  • βœ… Audit logging for document generation

🀝 Contributing

This project follows strict development guidelines. Please read:

  1. RULES.md - Master rulebook for development
  2. AGENTS.md - Agent-specific guidance
  3. CONTRIBUTING.md (Coming soon)

Development Workflow

  1. Plan first, build later
  2. Create feature branch (feature/your-feature)
  3. Write tests alongside code
  4. Ensure all tests pass
  5. Submit pull request
  6. Code review required

πŸ“„ License

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


⚠️ Legal Disclaimer

IMPORTANT: LawAI is an AI-powered legal assistance tool and does NOT replace professional legal advice. All generated content should be reviewed by qualified legal professionals before use. The system is designed to assist, not replace, lawyers and legal experts.


πŸ‘₯ Authors


πŸ™ Acknowledgments

  • IBM watsonx.ai for Granite-13b-chat-v2 model
  • LangChain and LangGraph for agent framework
  • ChromaDB for vector database
  • FastAPI and Next.js communities

Built with ❀️ for the Indian Legal Community

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors