DroitDraft is a state-of-the-art AI-powered legal document generation platform. This repository is a monorepo containing both the FastAPI backend and the Next.js frontend.
- Docker: For running the PostgreSQL database.
- Python 3.9+: For the backend.
- Node.js 18+: For the frontend.
- Git: For version control.
The project relies on three key Docker services:
- PostgreSQL: Primary data store for users and templates.
- MinIO: S3-compatible storage for uploaded evidence files.
- ChromaDB: Vector database for legal research and RAG.
-
Start all required containers:
docker-compose up -d
-
Database Permissions (First-time setup):
docker exec -it postgres_db psql -U droitdraft_user -d droitdraft_dev -c "GRANT ALL ON SCHEMA public TO droitdraft_user;"
- Navigate to backend:
cd backend - Setup Venv:
python -m venv .venvand activate it. - Install Core:
pip install -r requirements.txt - Environment: Create
.env. EnsureGROQ_API_KEYandGEMINI_API_KEYare present. - Seeding: To load the professional Maharashtra templates:
python scripts/seed_db.py - Run:
uvicorn app.main:app --host 0.0.0.0 --port 8002 --reload
- Navigate to frontend:
cd frontend - Install:
npm install - Run:
npm run dev -- -p 3001Available athttp://localhost:3001
To validate the system's legal accuracy and retrieval performance:
- Navigate to backend:
cd backend - Run Evaluation Suite:
python scripts/run_evaluation.py - View Report: Open
backend/evaluation/mumbai_benchmark_report.mdfor the latest metrics on MRR, Recall, and Faithfulness.
- Maharashtra Template Library: 7 verified proformas for Wills, Sale Deeds, Probate Petitions, and Legal Notices.
- Generative Information Extraction (GIE): Upload PDF/Image evidence (Death Certificates, IDs). The AI autonomously extracts structured legal facts and auto-fills the templates.
- MinIO Storage: Secure S3-compatible storage for uploaded evidence files.
- Legal Research Sandbox: Interactive sidebar for real-time legal Q&A using RAG.
- ChromaDB Vector Store: 56+ legal documents indexed for research.
- Natural Legal Citations: AI cites Acts and Sections naturally (e.g., "Section 10 of the Indian Contract Act, 1872").
- Insert to Draft: One-click transfer of cited authorities into the editor.
- Ghost Typing: AI-powered inline autocomplete that suggests the next legal sentence in gray text.
- Tab-to-Accept: Press
Tabto accept AI suggestions instantly. - Context-Awareness: Suggestions adapt based on the current draft and extracted case facts.
- Comprehensive Documentation: Full 7-chapter project report for Semester VIII submission.
- Evaluation Framework: Automated benchmarks for retrieval recall, faithfulness, and system latency.
- Agentic Remediation: Automated repair passes for drafts that fail validation checks.
- Multi-Format Export: One-click generation of court-ready PDF and editable DOCX files.
- Professional Styling: Automated layout mapping ensuring documents meet legal formatting standards.
- Binary Stream Proxy: Secure server-side generation with authentication-wrapped binary delivery.
- Agentic Drafting Flow: Powered by Llama 3.3 70B (Groq) with Gemini 1.5 fallback for zero-downtime reliability.
- Smart Editor: Rich-text editing with automatic date injection and citation mapping.
- Professional Export: High-fidelity PDF and DOCX generation using server-side rendering.
- JWT & Session Security: Secure token-based authentication with 24h session persistence.
- Major Project Documentation (Sem VIII): Extremely detailed technical report covering 7 chapters.
- docs/system_architecture_diagram.md: Highly detailed architecture diagrams and agentic interaction sequences.
- docs/evaluation_framework.md: Breakdown of metrics (MRR, Faithfulness, F1) used to validate system performance.
- roadmap.md: Development roadmap and future plans.