AI-powered government form assistant for rural India
Voice-first Β· Multilingual Β· Zero typing required
GramSetu (βVillage Bridgeβ) is an autonomous AI agent that fills Indian government forms on behalf of citizens β in their own language, using their real data from DigiLocker, with zero manual typing.
A citizen opens the web app and says: βΰ€°ΰ€Ύΰ€Άΰ€¨ ΰ€ΰ€Ύΰ€°ΰ₯ΰ€‘ ΰ€ΰ€Ύΰ€Ήΰ€Ώΰ€β (I need a ration card). GramSetu detects the intent, fetches the citizenβs Aadhaar, PAN, and address from DigiLocker, validates every field with deterministic checks, fills the government portal using live browser automation (Playwright), handles the OTP β and sends back a confirmation with a downloadable receipt.
The user never types their Aadhaar number, address, or any document numbers.
XXXX-XXXX-1234| Feature | Description |
|---|---|
| π£οΈ Realtime Voice STT | WebSocket-based live transcription via Sarvam AI β speak and see words appear instantly |
| π€ 11 Government Forms | Ration card, PAN, Voter ID, Pension, Ayushman Bharat, MNREGA, PM-KISAN, and more |
| π Scheme Discovery | LLM-powered search across myscheme.gov.in, india.gov.in to find eligible schemes |
| π DigiLocker Auto-Fill | All personal data fetched automatically β user only confirms |
| π Live Browser Automation | Playwright fills real government portals; live JPEG screenshots stream to the UI |
| β Deterministic Safety | Verhoeff checksum for Aadhaar, PAN format validation, cross-field consistency checks |
| π Text-to-Speech | Sarvam Bulbul TTS for spoken responses in 11 Indian languages |
| π 11 Languages | Hindi, English, Bengali, Tamil, Telugu, Marathi, Gujarati, Kannada, Malayalam, Punjabi, Urdu |
User (Web App β Voice / Text)
β
βΌ
FastAPI server.py (:8000)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β /api/chat β Text conversation β
β /api/voice β Audio upload β Sarvam/Groq/NVIDIA STT β
β /api/voice/realtime β WebSocket live STT (Sarvam streaming) β
β /api/schemes β LLM-powered scheme discovery β
β /api/tts β Text-to-speech (Sarvam Bulbul) β
β /ws/browser/{id} β Live Playwright screenshot stream β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
LangGraph v3 State Machine (5 Nodes)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. TRANSCRIBE β Sarvam / Groq Whisper / NeMo β
β 2. DETECT_INTENT β Keyword + LLM fallback β
β 3. DIGILOCKER β Auto-fetch all citizen data β
β 4. CONFIRM β User verifies (YES/NO only) β
β 5. FILL_FORM β Playwright live browser fill β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
Reliability Layer
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Verhoeff checksum (Aadhaar) β
β β’ PAN / IFSC / PIN code format validation β
β β’ Cross-field consistency (name β father, etc.) β
β β’ Confidence threshold gate (0.98+) β
β β’ Human review for risky/low-confidence submissions β
β β’ Dry-run fill plan before live automation β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Task | Primary | Fallback |
|---|---|---|
| Intent Classification | Groq llama-3.1-8b-instant (~50ms) |
Keyword-based (instant) |
| Conversational Chat | Groq llama-3.3-70b-versatile |
NVIDIA NIM |
| Speech-to-Text | Sarvam Saaras v1 | Groq Whisper Large v3 β NVIDIA Parakeet |
| Text-to-Speech | Sarvam Bulbul v1 | β |
| Scheme Research | Groq 70B with web search | Local curated database |
| Field Extraction | Groq 70B | β |
| Vision (Portal OCR) | NVIDIA LLaMA 3.2 11B Vision | Groq Vision Preview |
| Translation | Groq 70B | β |
| Category | Form | Real Portal |
|---|---|---|
| π Welfare | Ration Card (BPL/APL) | nfsa.gov.in |
| π Welfare | Old Age / Widow / Disability Pension | nsap.nic.in |
| π Welfare | Ayushman Bharat PMJAY (βΉ5L health cover) | pmjay.gov.in |
| π Welfare | MNREGA Job Card (100 days work) | nrega.nic.in |
| πͺͺ Identity | PAN Card | onlineservices.nsdl.com |
| πͺͺ Identity | Voter ID | voters.eci.gov.in |
| πͺͺ Identity | Caste Certificate (SC/ST/OBC) | services.india.gov.in |
| πͺͺ Identity | Birth Certificate | crsorgi.gov.in |
| πΎ Agriculture | PM-KISAN Samman Nidhi (βΉ6,000/year) | pmkisan.gov.in |
| πΎ Agriculture | Kisan Credit Card (farm loans) | kisancreditcard.in |
| π¦ Banking | Jan Dhan Account (zero balance) | pmjdy.gov.in |
Adding a new form = 1 Pydantic model + 1 entry in SCHEMA_REGISTRY. Voice, validation, DigiLocker auto-fill, and browser automation work automatically.
# Clone
git clone https://github.com/Vickyrrrrrr/gramsetu.git
cd gramsetu
# Configure
cp .env.example .env
# β Fill in GROQ_API_KEY and SARVAM_API_KEY
# Build and run everything
docker compose up --build
# Clone
git clone https://github.com/Vickyrrrrrr/gramsetu.git
cd gramsetu
# Python backend
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS/Linux
pip install -r requirements.txt
playwright install chromium
# Configure environment
cp .env.example .env
# β Fill in GROQ_API_KEY and SARVAM_API_KEY
# Start backend
python server.py
# β http://localhost:8000
# Start frontend (new terminal)
cd webapp
npm install
npm run dev
# β http://localhost:3000
# ββ Required ββββββββββββββββββββββββββββββββββββββββββ
GROQ_API_KEY=gsk_your_key_here # LLM inference (free tier)
SARVAM_API_KEY=sk_your_key_here # Indian STT/TTS
# ββ Optional ββββββββββββββββββββββββββββββββββββββββββ
NVIDIA_API_KEY=nvapi-your-key-here # Vision + ASR fallback
NVIDIA_BASE_URL=https://integrate.api.nvidia.com/v1
# ββ Server ββββββββββββββββββββββββββββββββββββββββββββ
PORT=8000
HOST=0.0.0.0
BACKEND_URL=http://localhost:8000 # Used by Next.js proxy
gramsetu/
βββ server.py # FastAPI entrypoint β all API endpoints
βββ requirements.txt # Python dependencies
βββ Dockerfile # Backend container (uvicorn server:app)
βββ docker-compose.yml # Full-stack: backend + webapp
βββ .env.example # Environment template
β
βββ backend/
β βββ agents/
β β βββ graph.py # LangGraph 5-node state machine (core pipeline)
β β βββ schema.py # Pydantic models for all 11 forms + SCHEMA_REGISTRY
β β βββ portal_registry.py # Government portal URLs and selectors
β β βββ form_fill_agent.py # Playwright browser automation agent
β β
β βββ llm_client.py # Multi-provider LLM client (Groq + NVIDIA + Sarvam)
β βββ schemes.py # LLM-powered scheme discovery engine
β βββ database.py # SQLite/Supabase storage layer
β βββ digilocker_client.py # DigiLocker API client (demo data for now)
β βββ security.py # Rate limiter, PII encryption, input sanitization
β βββ reliability.py # Deterministic safety layer before automation
β βββ voice_tts.py # Text-to-speech (Sarvam Bulbul)
β βββ sarvam_client.py # Sarvam AI direct API wrapper
β βββ stagehand_client.py # Browser fill plan generator
β
βββ agent_core/
β βββ validator.py # Rule-based validators (Aadhaar, PAN, IFSC, DOB, etc.)
β
βββ lib/
β βββ language_utils.py # Script-based language detection (11 languages)
β βββ voice_handler.py # Audio transcription (Sarvam β Groq β NVIDIA cascade)
β
βββ webapp/ # Next.js 14 frontend
β βββ app/app/page.tsx # Main chat UI (1600+ lines)
β βββ next.config.js # API proxy configuration
β βββ Dockerfile # Frontend container
β
βββ public/
β βββ mock_portal.html # Pixel-faithful GOI portal replica for demos
β βββ admin.html # Admin dashboard
β
βββ data/
β βββ checkpoints.db # LangGraph session checkpoints (SQLite)
β βββ gramsetu.db # Application database
β βββ schemes.json # Fallback scheme data
β
βββ deploy/
β βββ prometheus/ # Prometheus config
β βββ grafana/ # Grafana dashboards
β
βββ tests/ # Test suite
β
βββ .github/workflows/ # CI/CD (lint, test, Docker build, deploy)
Base URL: http://localhost:8000
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/chat |
Send a text message, get AI response |
POST |
/api/voice |
Upload audio file β transcribed text + AI response |
WS |
/api/voice/realtime |
Realtime STT β stream PCM audio, get live transcripts |
POST |
/api/otp/{user_id} |
Submit OTP to resume a suspended form session |
POST |
/api/schemes |
Discover eligible government schemes |
POST |
/api/tts |
Text-to-speech (returns audio/wav) |
GET |
/api/mcp-status |
Status of all backend services |
GET |
/api/health |
Health check + active session count |
GET |
/api/impact |
Impact metrics (forms filled, users served) |
GET |
/api/receipt/{id} |
Downloadable HTML receipt for submitted forms |
WS |
/ws/browser/{user_id} |
Live JPEG stream of Playwright browser automation |
// Connect
const ws = new WebSocket('ws://localhost:8000/api/voice/realtime')
// Start session
ws.send(JSON.stringify({ type: 'start', language: 'hi' }))
// Stream 16kHz PCM audio
ws.send(pcmAudioBuffer) // ArrayBuffer of Int16Array
// Receive transcripts
ws.onmessage = (event) => {
const data = JSON.parse(event.data)
// { type: 'transcript', text: 'ΰ€°ΰ€Ύΰ€Άΰ€¨ ΰ€ΰ€Ύΰ€°ΰ₯ΰ€‘ ΰ€ΰ€Ύΰ€Ήΰ€Ώΰ€', is_final: true }
}
// Stop
ws.send(JSON.stringify({ type: 'stop' }))
1. User speaks or types: "I need a ration card" (any language)
β
βΌ
2. TRANSCRIBE β Sarvam Saaras converts voice β text
β
βΌ
3. DETECT INTENT β Keywords + LLM identify: form_type = "ration_card"
β
βΌ
4. DIGILOCKER β Auto-fetch Aadhaar, PAN, address, bank details
β
βΌ
5. CONFIRM β Show pre-filled form summary with confidence scores
π’ High confidence (DigiLocker) π‘ Estimated π΄ Needs review
User says YES or corrects specific fields
β
βΌ
6. RELIABILITY GATE β Verhoeff checksum, format validation,
cross-field checks, confidence threshold, human review gate
β
βΌ
7. FILL FORM β Playwright opens real portal, fills field by field
Live screenshots stream to the web app via WebSocket
β
βΌ
8. OTP β Portal asks for OTP β graph SUSPENDS β user sends OTP
β
βΌ
9. DONE β Confirmation + reference number + downloadable receipt
GramSetu never trusts the LLM blindly. A deterministic safety layer runs before any live form submission:
| Check | What It Does |
|---|---|
| Verhoeff Checksum | Validates Aadhaar numbers mathematically (12-digit + checksum) |
| PAN Format | Validates ABCDE1234F pattern + holder category letter |
| IFSC Format | 4 letters + 0 + 6 alphanumeric |
| Phone Validation | 10 digits, starts with 6-9, strips +91 prefix |
| PIN Code | 6 digits, first digit 1-9 |
| Date of Birth | Age β₯ 18, β€ 150, not in future |
| Cross-Field | Name β father name, mobile prefix valid, PIN code valid |
| Confidence Gate | All fields must be β₯ 98% confidence for auto-submit |
| Human Review | Low-confidence, OTP steps, or PII changes require explicit review |
| Dry-Run Plan | Generate fill plan before touching real portals |
| Language | Code | Script Detection |
|---|---|---|
| Hindi | hi |
Devanagari \u0900-\u097F |
| Bengali | bn |
Bengali \u0980-\u09FF |
| Tamil | ta |
Tamil \u0B80-\u0BFF |
| Telugu | te |
Telugu \u0C00-\u0C7F |
| Marathi | mr |
Devanagari + keyword disambiguation |
| Gujarati | gu |
Gujarati \u0A80-\u0AFF |
| Kannada | kn |
Kannada \u0C80-\u0CFF |
| Malayalam | ml |
Malayalam \u0D00-\u0D7F |
| Punjabi | pa |
Gurmukhi \u0A00-\u0A7F |
| Urdu | ur |
Arabic \u0600-\u06FF |
| English | en |
Latin (default fallback) |
Language is auto-detected from the Unicode script of the input text. Romanized Hindi/Tamil/Telugu are detected via keyword matching.
| Feature | Implementation |
|---|---|
| PII Encryption | Fernet (AES-128-CBC) for all PII in checkpoints |
| PII Redaction | Aadhaar shown as XXXX-XXXX-1234 in logs and UI |
| Rate Limiting | 60 req/min per IP (in-memory, no Redis needed) |
| Input Sanitization | XSS prevention, control char removal, length limits |
| OTP Validation | 4-6 digits only, supports Hindi word-to-digit (βΰ€ΰ€ ΰ€¦ΰ₯ ΰ€€ΰ₯ΰ€¨β) |
| Session Cleanup | Auto-expire after 24 hours |
| Git Security | .env gitignored, API keys never committed |
cp .env.example .env
# Fill in API keys
docker compose up --build
| Service | Port | Description |
|---|---|---|
gramsetu-backend |
8000 | FastAPI + all endpoints |
gramsetu-webapp |
3000 | Next.js frontend |
docker compose up --build backend
The backend Dockerfile:
python:3.12-slimffmpeg for audio processing/api/healthuvicorn server:apppython -m pytest tests/ -v
Your Laptop
βββ FastAPI server.py β localhost:8000
βββ Next.js web app β localhost:3000
# Terminal 1 β Backend
cd gramsetu
.venv\Scripts\activate
python server.py
# Terminal 2 β Frontend
cd gramsetu\webapp
npm run dev
localhost:3000 on the big screengit checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)MIT
Built for the people who need it most.
GramSetu β bridging the digital divide, one form at a time. πΎ