Skip to content
Parthavi2Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

48 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βš–οΈ NyaayAI

AI-Powered Legal Aid Platform for Underserved Communities

Making justice accessible through AI β€” one document at a time.

🌐 Live Application: https://nyaay-ai-taupe.vercel.app
πŸ“– API Documentation: https://nyaayai-tptx.onrender.com/docs
πŸ”— Backend API: https://nyaayai-tptx.onrender.com


πŸ“Œ Overview

NyaayAI is an AI-powered legal aid platform designed to help citizens understand legal documents without requiring expensive legal consultation.

Users can upload legal documents such as:

  • FIRs
  • Court Summons
  • Legal Notices
  • Tax Notices
  • Eviction Notices
  • Contracts
  • Government Communications
  • Scanned Legal Documents

The platform automatically analyzes the uploaded document and provides:

βœ… Plain-language explanation
βœ… Important clauses and obligations
βœ… Fraud/Fake notice detection with risk scoring
βœ… Legal rights and protections
βœ… Recommended next steps
βœ… AI-generated reply drafts
βœ… Legal aid and helpline recommendations
βœ… Multi-language support

NyaayAI aims to bridge the legal knowledge gap by making legal information understandable and accessible to everyone.


✨ Key Features

πŸ“„ Intelligent Document Analysis

  • Upload PDF, image, or scanned legal documents
  • OCR-powered text extraction
  • AI-driven clause extraction
  • Important dates and deadlines detection
  • Obligation and penalty identification
  • Legal risk assessment

🚨 Fraud Detection

The platform evaluates uploaded notices and identifies potential indicators of:

  • Fake legal notices
  • Scam communications
  • Fraudulent demands
  • Suspicious legal threats

Each analysis includes:

  • Fraud probability score
  • Risk explanation
  • Verification recommendations

🧠 AI Legal Guidance

The AI provides:

  • Simplified explanation of legal language
  • Citizen-friendly summaries
  • Rights and protections applicable to the document
  • Suggested actions to take
  • Potential legal concerns

✍️ Draft Reply Generator

Generate professional responses for:

  • Legal notices
  • Government notices
  • Tax communications
  • Consumer complaints
  • Civil disputes

The generated drafts can be reviewed and modified before use.


🌍 Multilingual Support

Supported Languages:

  • English
  • Hindi
  • Marathi
  • Tamil
  • Telugu
  • Bengali
  • Gujarati

Language detection and translation are handled automatically.


πŸ“ž Legal Aid Resources

Based on case type and user location, NyaayAI can recommend:

  • Government legal aid services
  • Consumer helplines
  • Women's helplines
  • Cybercrime reporting channels
  • Legal assistance resources

πŸ” Secure Authentication

  • JWT Authentication
  • Password Hashing (bcrypt)
  • OAuth2 Password Flow
  • Protected User Dashboard

πŸ“‚ User Dashboard

Users can:

  • View previous analyses
  • Re-open documents
  • Re-analyze documents
  • Download reports
  • Track case history

πŸ— System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     User Browser                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Next.js Frontend                    β”‚
β”‚         React + TypeScript + Tailwind CSS            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚ HTTPS / REST
                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   FastAPI Backend                    β”‚
β”‚      Authentication β€’ Analysis β€’ OCR β€’ AI           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                 β”‚
        β–Ό                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SQLite /      β”‚   β”‚ Groq API (LLaMA 3 70B)        β”‚
β”‚ PostgreSQL    β”‚   β”‚ OpenAI (Optional Fallback)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚ Claude (Optional Fallback)    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ OCR Services      β”‚
                    β”‚ Tesseract         β”‚
                    β”‚ EasyOCR           β”‚
                    β”‚ PyMuPDF           β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›  Tech Stack

Frontend

  • Next.js 14 (App Router)
  • React
  • TypeScript
  • Tailwind CSS
  • Lucide React

Backend

  • Python 3.13
  • FastAPI
  • SQLAlchemy
  • SQLite
  • PostgreSQL (Production Ready)
  • Pydantic
  • Pydantic Settings

AI & LLM

  • Groq API (LLaMA 3 70B)
  • OpenAI GPT-4o (Optional)
  • Anthropic Claude (Optional)

OCR & Document Processing

  • PyMuPDF
  • Pytesseract
  • EasyOCR
  • pdf2image
  • Pillow
  • Google Cloud Vision (Optional)

NLP

  • spaCy
  • LangDetect

Authentication

  • JWT Tokens
  • python-jose
  • Passlib (bcrypt)
  • OAuth2

Deployment

Service Platform
Frontend Vercel
Backend Render
Database SQLite / PostgreSQL

πŸ“ Project Structure

NyaayAI/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py
β”‚   β”‚   β”‚   β”œβ”€β”€ routes.py
β”‚   β”‚   β”‚   └── deps.py
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py
β”‚   β”‚   β”‚   └── security.py
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ db/
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py
β”‚   β”‚   β”‚   └── crud.py
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ db_models.py
β”‚   β”‚   β”‚   β”œβ”€β”€ user_models.py
β”‚   β”‚   β”‚   └── schemas.py
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ llm_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ ocr_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ fraud_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ guidance_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ legal_aid_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ translation_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ resource_service.py
β”‚   β”‚   β”‚   └── pipeline.py
β”‚   β”‚   β”‚
β”‚   β”‚   └── main.py
β”‚   β”‚
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── .env
β”‚
└── frontend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ app/
    β”‚   β”œβ”€β”€ components/
    β”‚   β”œβ”€β”€ context/
    β”‚   β”œβ”€β”€ lib/
    β”‚   └── types/
    β”‚
    β”œβ”€β”€ package.json
    β”œβ”€β”€ next.config.js
    └── .env.local

πŸ“‘ API Endpoints

Method Endpoint Description
GET / Health Check
POST /auth/register Register User
POST /auth/login Login User
GET /auth/me Current User
POST /analyze-document Upload & Analyze Document
POST /case-assistant Ask Questions About Case
GET /support/options Legal Aid Resources
POST /analysis/translate Translate Analysis
GET /health API Health Status

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Tesseract OCR
  • Groq API Key

Backend Setup

cd backend

python -m venv venv

# Windows
venv\Scripts\activate

# Linux / Mac
source venv/bin/activate

pip install -r requirements.txt

python -m spacy download en_core_web_sm

Create .env

GROQ_API_KEY=gsk_your_key_here

SECRET_KEY=change-this-in-production

DATABASE_URL=sqlite:///./nyaay_ai.db

LLM_PROVIDER=groq

Run Backend:

uvicorn app.main:app --reload --port 8000

Backend:

http://localhost:8000

Swagger Docs:

http://localhost:8000/docs

Frontend Setup

cd frontend

npm install

Create .env.local

NEXT_PUBLIC_API_URL=http://localhost:8000

NEXT_PUBLIC_USE_MOCK=false

Run:

npm run dev

Frontend:

http://localhost:3000

☁️ Deployment

Backend (Render)

Setting Value
Root Directory backend
Build Command pip install -r requirements.txt
Start Command uvicorn app.main:app --host 0.0.0.0 --port $PORT

Environment Variables:

GROQ_API_KEY=your_key

SECRET_KEY=your_secret

DATABASE_URL=sqlite:///./nyaay_ai.db

Frontend (Vercel)

Setting Value
Framework Next.js
Root Directory frontend

Environment Variables:

NEXT_PUBLIC_API_URL=https://nyaayai-tptx.onrender.com

NEXT_PUBLIC_USE_MOCK=false

πŸ” Environment Variables

Backend

GROQ_API_KEY=gsk_...

SECRET_KEY=...

DATABASE_URL=sqlite:///./nyaay_ai.db

LLM_PROVIDER=groq

Frontend

NEXT_PUBLIC_API_URL=https://nyaayai-tptx.onrender.com

NEXT_PUBLIC_USE_MOCK=false

πŸ› Common Issues

Problem Solution
Failed to fetch Backend may be sleeping on Render free tier
CORS error Add frontend URL to allow_origins
Database error Verify DATABASE_URL
OCR not working Ensure Tesseract is installed
Vercel build fails Confirm frontend root directory
Groq errors Verify GROQ_API_KEY

πŸ—Ί Roadmap

  • Voice-based legal assistance
  • AI legal chatbot for follow-up questions
  • Lawyer referral network
  • Case tracking dashboard
  • PDF report export
  • WhatsApp integration
  • Regional language expansion
  • PostgreSQL migration with Alembic
  • Mobile application (Android & iOS)

❀️ Mission

Millions of people struggle to understand legal notices, government communications, and court documents.

NyaayAI aims to make legal information understandable, accessible, and actionable for everyone through responsible AI.

Justice should not depend on whether someone can afford a lawyer.


πŸ‘¨β€πŸ’» Built With

FastAPI β€’ Next.js β€’ Groq LLaMA β€’ OCR β€’ SQLAlchemy β€’ Tailwind CSS β€’ JWT Authentication


πŸ“œ License

This project is licensed under the MIT License.


⭐ If you found this project useful, consider giving it a star on GitHub.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages