Demystifying complex legal documents with the power of AI. SahayAI transforms dense legal jargon into clear, actionable insights, empowering you to make informed decisions with confidence.
Navigating legal documents can be an intimidating and confusing process for anyone without a law degree. The complex language, critical deadlines, and hidden obligations can lead to misunderstandings and costly mistakes.
SahayAI was built to solve this problem. It's an intelligent legal analysis tool that acts as your personal guide. Simply upload a document, and SahayAI instantly breaks it down, providing you with a clear summary, answers to your questions, and a personalized checklist of actions.
Watch the full walkthrough: SahayAI Demo Video
Try it yourself: Live Application
SahayAI offers a multi-faceted analysis through a clean, intuitive interface:
Instantly extracts the most critical information from your documentโparties involved, key dates, notice periods, and important termsโand presents it in a simple, structured format.
Delivers plain-English summaries and clear explanations of key clauses, helping you understand the implications of each section without getting lost in jargon.
An interactive Q&A feature powered by the document's content. Get direct answers to your specific questions, with guided prompts to help you explore the text.
Generates a custom action plan based on the document's content, with categorized tasks and responsibilities so you know exactly what you need to do next.
| Component | Purpose | Key Files |
|---|---|---|
| Backend (Legal_Mcp) | Receives uploaded files, extracts text, runs a processing pipeline, and provides a chat-based Q&A interface over the document. | app.py, tasks.py, requirements.txt, DockerFile |
| Frontend (sahayai) | A modern Next.js (React) UI that lets users upload documents, view analysis results, and chat with the AI. | src/app/**, src/components/**, next.config.ts, DockerFile |
| Infrastructure | Docker-compose and Cloud Build configs to containerise and deploy both services. | docker-compose.yml, cloudbuild.yaml |
| Assets | Sample legal notice images used for testing or UI illustration. | Legal Documents/* |
-
Flask API exposing two main routes:
POST /process-documentโ accepts a file + user role, validates, and runs process_document_pipelinePOST /chatโ forwards a question/context pair to chat_with_document
-
Technology Stack:
- Google Cloud Vision for OCR
- Google Generative AI for LLM interaction
- LangChain for document processing
- PyMuPDF and Pillow for PDF handling
- Containerised with Python 3.9 and Gunicorn for production
-
Built with:
- Next.js 15 (standalone output mode)
- TypeScript
- Tailwind CSS
- shadcn/ui components
- lucide-react icons
-
Features:
- Global state management via React context (
stateContext.tsx) - API routes (
/api/process,/api/chat) proxy requests to Flask backend - Responsive design with modern UI components
- Global state management via React context (
Ensure you have Docker and Docker Compose installed on your system:
-
Clone the repository
git clone https://github.com/HrushikeshAnandSarangi/SahayAI.git
-
Navigate to the project directory
cd SahayAI -
Set up environment variables
Create a
.envfile in the root directory:# .env example API_KEY="YOUR_API_KEY"
-
Build and run the application
docker-compose up --build
-
Access the application
The application will be available at
http://localhost:3000
A Google Cloud Build script (cloudbuild.yaml) is included to build and push both the frontend and backend images to Google Artifact Registry, preparing them for deployment on services like Cloud Run.
.
โโโ Legal_Mcp/ # Flask backend
โ โโโ app.py
โ โโโ tasks.py
โ โโโ DockerFile
โ โโโ requirements.txt
โโโ sahayai/ # Next.js frontend
โ โโโ src/app/ # Pages and API routes
โ โโโ src/components/ # UI components
โ โโโ src/context/ # Global state
โ โโโ DockerFile
โ โโโ package.json
โโโ Legal Documents/ # Sample legal notice images
โโโ docker-compose.yml
โโโ cloudbuild.yaml
โโโ README.md
SahayAI is designed for a wide range of users who need to navigate the complexities of legal language:
Anyone dealing with personal contracts like rental agreements, employment offers, or terms of service who wants to understand their rights and obligations.
For quickly reviewing contracts, NDAs, partnership agreements, and other legal documents, especially when they don't have an in-house legal team.
Paralegals, law clerks, and even lawyers can use it to get a quick first-pass analysis of documents, saving time and highlighting key areas for deeper review.
A useful tool for law students or academics who need to analyze and summarize large volumes of legal text.
Those looking for a practical, end-to-end example of a modern AI application combining a Python backend with a Next.js frontend, ready for containerized deployment.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or support, please reach out through the GitHub repository issues.
SahayAI - Empowering everyone to understand legal documents with AI ๐