Skip to content

raghav26102000/DocuMind-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Typing SVG

๐Ÿ‡ฎ๐Ÿ‡ณ Saral Seva โ€” DocuMindAI

Bridging Citizens and Government Schemes through Intelligent AI

Python FastAPI Next.js MongoDB Redis Docker AWS S3 License


Saral Seva is an AI-powered Indian Government Schemes Help Portal that leverages RAG pipelines, multilingual LLMs, and intelligent document processing to help citizens discover, understand, and apply for the welfare schemes they deserve.


๐Ÿš€ Quick Start ยท โœจ Features ยท ๐Ÿ— Architecture ยท ๐Ÿ“ก API Reference ยท ๐Ÿค Contributing



โœจ Features


๐Ÿค– AI-Powered Chatbot

  • Conversational AI built on the smolagents framework
  • Multilingual support โ€” responds in Hindi, Tamil, Telugu, Bengali, and 18+ Indian languages
  • Context-aware responses with smart follow-up question suggestions
  • Automated grievance redressal via email for unresolved complaints

๐Ÿ“Š RAG Document Pipeline

  • DPR (Dense Passage Retrieval) embeddings for accurate scheme matching
  • Vector-based semantic search across the full scheme corpus
  • Automatic extraction of citations and references from source documents
  • Real-time scheme eligibility matching against uploaded user documents

๐Ÿ” Advanced Web Search

  • Brave Search API integration for up-to-date scheme information
  • Concurrent URL content extraction and full-text parsing via Playwright
  • Intelligent relevance scoring and filtering pipeline

๐Ÿ“„ Smart Document Management

  • Multi-format support: PDF, DOCX, Excel, and images
  • Tesseract OCR for text extraction from scanned documents
  • AI-powered document authenticity and completeness verification
  • Automatic DPR (Document Processing Report) generation
  • Secure cloud storage via AWS S3

๐Ÿ” Authentication & Access Control

  • OTP-based authentication โ€” no passwords required
  • JWT session management with configurable expiry
  • Built-in API rate limiting and in-memory caching (FastAPI-cache2)

โšก Async Infrastructure

  • Celery workers with Redis broker for background processing
  • Real-time WebSocket notifications
  • Nginx reverse proxy with load balancing
  • Multi-stage Docker builds for all services


๐Ÿ— Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        CLIENT LAYER                          โ”‚
โ”‚     Next.js 15 ยท React 19 ยท TailwindCSS ยท Bootstrap 5       โ”‚
โ”‚          FilePond (uploads) ยท React-Markdown ยท WebSocket     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚  HTTP / WebSocket
                      โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”
                      โ”‚   Nginx   โ”‚  โ† Reverse Proxy + Load Balancer
                      โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      SERVICE LAYER                           โ”‚
โ”‚          FastAPI ยท Celery Workers ยท WebSocket Server         โ”‚
โ”‚                   JWT Auth ยท OTP Verification                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€-โ”˜
       โ”‚                    โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  DATA LAYER โ”‚    โ”‚              AI / ML LAYER               โ”‚
โ”‚  MongoDB    โ”‚    โ”‚  smolagents ยท LiteLLM ยท OpenAI ยท Gemini  โ”‚
โ”‚  Redis      โ”‚    โ”‚  Hugging Face DPR ยท Brave Search         โ”‚
โ”‚  AWS S3     โ”‚    โ”‚  Tesseract OCR ยท PyMuPDF ยท Playwright    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€-โ”˜


๐Ÿง  AI Pipeline โ€” How It Works

 Citizen Query / Document Upload
           โ”‚
           โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  Multilingual NLP   โ”‚  โ† Detects language, normalises input
 โ”‚  Intent Detection   โ”‚  โ† smolagents classifies query type
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  Document Pipeline  โ”‚  โ† Tesseract OCR + PyMuPDF extraction
 โ”‚  (if file uploaded) โ”‚  โ† AI categorises by scheme relevance
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚   RAG Retrieval     โ”‚  โ† DPR embeddings โ†’ Vector search
 โ”‚   + Brave Search    โ”‚  โ† Live web context fetched & ranked
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚   LLM Generation    โ”‚  โ† GPT-4o / Gemini via LiteLLM
 โ”‚   (Grounded)        โ”‚  โ† Eligibility check against documents
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  DPR + Guidance     โ”‚  โ† Document Processing Report
 โ”‚  Delivery           โ”‚  โ† Step-by-step application guide
 โ”‚                     โ”‚  โ† Auto grievance email if needed
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


๐Ÿ›  Tech Stack

Layer Technology Purpose
Backend FastAPI + Python 3.11 REST API, business logic
Frontend Next.js 15 + React 19 Modern, responsive UI
Database MongoDB + Motor (async) Scheme & user data
Cache / Queue Redis + Celery Sessions, background tasks
AI Agents smolagents Intelligent automation
LLM Interface LiteLLM GPT-4o, Gemini, unified API
Embeddings Hugging Face DPR Semantic vector search
OCR Tesseract + PyMuPDF Document text extraction
Web Scraping Playwright + BeautifulSoup Scheme data collection
Search Brave Search API Live web information
File Storage AWS S3 Secure document storage
Infra Docker + Nginx Containers, load balancing
Styling TailwindCSS + Bootstrap 5 UI components
File Upload React FilePond Drag-and-drop uploads


๐Ÿ“ฆ Project Structure

DocuMindAI/
โ”œโ”€โ”€ backend/                    # FastAPI backend
โ”‚   โ”œโ”€โ”€ main.py                 # App entrypoint
โ”‚   โ”œโ”€โ”€ routers/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.py             # OTP auth endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ chatbot.py          # AI chat endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ schemes.py          # Scheme search & details
โ”‚   โ”‚   โ””โ”€โ”€ documents.py        # Document upload & verify
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”œโ”€โ”€ chatbot_agent.py    # smolagents chatbot
โ”‚   โ”‚   โ””โ”€โ”€ document_agent.py   # Document processing agent
โ”‚   โ”œโ”€โ”€ rag/
โ”‚   โ”‚   โ”œโ”€โ”€ embeddings.py       # DPR embedding pipeline
โ”‚   โ”‚   โ””โ”€โ”€ retriever.py        # Vector search
โ”‚   โ”œโ”€โ”€ tasks.py                # Celery async tasks
โ”‚   โ””โ”€โ”€ requirements.txt
โ”‚
โ”œโ”€โ”€ saral-sewa/                 # Next.js frontend
โ”‚   โ”œโ”€โ”€ app/                    # App Router pages
โ”‚   โ”œโ”€โ”€ components/             # Reusable UI components
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ pipeline/                   # Data ingestion pipeline
โ”‚   โ”œโ”€โ”€ main.py                 # Scheme scraping + indexing
โ”‚   โ””โ”€โ”€ requirements.txt
โ”‚
โ”œโ”€โ”€ docker-compose.yaml         # All services orchestration
โ”œโ”€โ”€ nginx.conf                  # Reverse proxy config
โ””โ”€โ”€ .env.example                # Environment variable template


๐Ÿš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • OpenAI API key, Gemini API key, Brave Search API key
  • Hugging Face token
  • AWS S3 bucket + credentials

1. Clone the Repository

git clone https://github.com/your-org/DocuMindAI.git
cd DocuMindAI

2. Configure Environment Variables

Backend (backend/.env):

# Database
MONGO_URI=mongodb://localhost:27017/schemes_db

# AI / ML
HF_TOKEN=your_huggingface_token
GEMINI_API_KEY=your_gemini_api_key
OPENAI_API_KEY=your_openai_api_key
BRAVE_API_KEY=your_brave_search_api_key

# Storage
AWS_ACCESS_KEY_ID=your_aws_key
AWS_SECRET_ACCESS_KEY=your_aws_secret
AWS_STORAGE_BUCKET_NAME=your_bucket_name
AWS_S3_REGION_NAME=ap-south-1

# App
SESSION_SECRET=your_session_secret
SUPPORT_EMAIL=support@saralsewa.com
SMTP_SERVER=smtp.gmail.com

Frontend (saral-sewa/.env.local):

NEXT_PUBLIC_API_BASE_URL=http://localhost:8000/api/master

3. Build & Launch All Services

DOCKER_BUILDKIT=1 docker compose build --build-arg CACHE_BUSTER=$(date +%s)
docker compose up -d

4. Index Government Schemes

docker compose exec pipeline python main.py

5. Open the App

Service URL
๐ŸŒ Frontend http://localhost:3000
โš™๏ธ API http://localhost:8000/api/master
๐Ÿ“– API Docs http://localhost:8000/docs

Local Development (without Docker)

Backend:

cd backend
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload --host 0.0.0.0 --port 8000

Frontend:

cd saral-sewa
npm install && npm run dev

Pipeline:

cd pipeline
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt && python main.py


๐Ÿ“ก API Reference

All endpoints are prefixed with /api/master and require a JWT bearer token (except auth routes).

Authentication

Method Endpoint Description
POST /auth/send-otp Send OTP to registered phone
POST /auth/verify-otp Verify OTP, receive JWT token
POST /auth/logout Invalidate current session

Chatbot

Method Endpoint Description
POST /chatbot/chat Send message to AI assistant

Schemes

Method Endpoint Description
GET /schemes List all indexed schemes
GET /schemes/{slug} Get full scheme details
GET /schemes/search?q= Full-text scheme search

Documents

Method Endpoint Description
POST /documents/upload Upload documents to S3
GET /documents List user's documents
POST /documents/verify Verify document authenticity


๐ŸŽฏ Who Is This For?

Citizen Schemes They Can Discover
๐Ÿ‘จโ€๐ŸŒพ Farmers PM Kisan Yojana, crop insurance, soil health card
๐Ÿ‘ฉโ€๐ŸŽ“ Students Scholarships, skill development, fellowships
๐Ÿคฑ Women Mahila schemes, maternity benefits, SHG support
๐Ÿ—๏ธ Labour MGNREGS, PMAY housing, pension schemes
๐Ÿง“ Senior Citizens Atal Pension Yojana, Ayushman Bharat
๐Ÿข MSMEs Mudra loans, startup grants, credit guarantee


๐Ÿค Contributing

Contributions are welcome!

# Fork the repo, then:
git clone https://github.com/your-username/DocuMindAI.git
git checkout -b feature/your-feature-name

# Make your changes, then:
git commit -m "feat: describe your change"
git push origin feature/your-feature-name
# Open a Pull Request


๐Ÿ†˜ Support

Channel Details
๐Ÿ“ง Email support@saralsewa.com
๐Ÿค– Chatbot Available 24/7 on the platform
๐Ÿ› Issues Open a GitHub Issue


๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.



Made with โค๏ธ for Bharat ๐Ÿ‡ฎ๐Ÿ‡ณ

DocuMindAI โ€” Making Government Schemes Accessible to Every Citizen

GitHub stars GitHub forks

About

AI-powered government schemes platform that helps citizens discover welfare programs using multilingual AI, RAG, intelligent document processing, and personalized eligibility assistance.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors