Skip to content

KKabilan07/scheme-navigator-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Scheme Navigator AI

Scheme Navigator React FastAPI Groq ChromaDB

Scheme Navigator AI is an intelligent government scheme advisory platform powered by multi-agent AI. It analyzes user profiles, intelligently matches them to eligible schemes, identifies missed benefits, and provides actionable guidance for scheme applications.


πŸ› οΈ Tech Stack

Languages
Python 3.10+ JavaScript

Frameworks & UI
React 19 FastAPI Vite TailwindCSS

Databases & Search
MongoDB ChromaDB Vector Embeddings

Services & AI
Groq LLM Firebase Auth Axios


✨ Key Features

πŸ€– 1. Multi-Agent AI System

  • Query Agent: Understands user intent and extracts demographic information (age, income, location, sector)
  • RAG Agent: Retrieves relevant government schemes from vector database with semantic search
  • Eligibility Agent: Validates scheme eligibility based on government criteria and user profile
  • Compliance Agent: Ensures accurate, hallucination-free responses with government policy validation
  • Action Agent: Provides step-by-step application guidance for scheme enrollment
  • Alert Agent: Tracks user profile and alerts on new scheme eligibility

🎯 2. Scheme Discovery & Matching

  • Intelligent Matching: Semantic matching of user profiles to government schemes
  • 23+ Schemes Indexed: Complete database of Indian government welfare schemes
  • Multi-Criteria Filtering: Income levels, age groups, occupation, region-specific eligibility
  • Missed Benefits Identification: Highlights schemes user qualifies for but hasn't applied
  • Real-time Eligibility Check: Instant validation against scheme criteria
  • Ranking Algorithm: Prioritizes schemes by relevance and applicability

πŸ‘€ 3. Smart User Profiling

  • Profile Creation: Capture income, age, occupation, state, and family details
  • Dynamic Classification: Automatically categorize users (farmer, student, elderly, entrepreneur)
  • Profile Updates: Track eligibility changes as user profile evolves
  • Secure Storage: Firebase authentication + MongoDB persistence
  • WhatsApp Integration: Receive scheme alerts on WhatsApp

πŸ“Š 4. Application Tracking Dashboard

  • Eligibility Summary: View all schemes user qualifies for
  • Application Status: Track submitted applications
  • Benefit Status: Monitor active benefits and payments
  • Eligibility Timeline: See when new schemes become available
  • Alerts Panel: Real-time notifications for new opportunities

πŸ—£οΈ 5. Voice-Enabled Interaction

  • Voice Input: Speak queries in natural language
  • Voice Output: Listen to scheme details and application steps
  • Multi-Language Ready: Foundation for Hindi, Tamil, Kannada, Bengali support
  • Accessibility: Helps illiterate and elderly users navigate schemes

πŸ“± 6. Responsive Mobile-First Design

  • Mobile Optimized: Works seamlessly on phones, tablets, desktops
  • Offline Capable: Core functionality works without internet
  • Touch-Friendly: Large buttons and swipe navigation
  • Dark Mode Ready: Eye-friendly interface for long sessions
  • Progressive Enhancement: Graceful degradation for older devices

πŸ” 7. Enterprise-Grade Security

  • Firebase Auth: Secure user authentication with MFA support
  • Data Privacy: Encrypted user profiles and application data
  • Role-Based Access: Admin dashboards and user restrictions
  • Audit Logging: Track all user interactions for compliance
  • HTTPS Only: Secure communication across all layers

⚑ 8. Performance Optimizations

  • Vector Search: Fast semantic matching with ChromaDB
  • Keyword Fallback: Ensures results even with vector search misses
  • Response Caching: Frequently accessed schemes cached in-memory
  • Lazy Loading: Progressive loading of scheme details
  • Optimized Embeddings: 25 pre-computed embeddings for instant search

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   PRESENTATION LAYER                        β”‚
β”‚          (React 19 + Vite on Development)                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  β€’ User Login & Authentication                       β”‚   β”‚
β”‚  β”‚  β€’ Profile Creation & Management                     β”‚   β”‚
β”‚  β”‚  β€’ Chat Interface with Voice I/O                     β”‚   β”‚
β”‚  β”‚  β€’ Scheme Discovery Dashboard                        β”‚   β”‚
β”‚  β”‚  β€’ Eligibility & Application Tracking                β”‚   β”‚
β”‚  β”‚  β€’ Alerts & Notifications                            β”‚   β”‚
β”‚  β”‚  β€’ WhatsApp Integration                              β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                    ↓ (Axios REST)                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                   API GATEWAY LAYER                         β”‚
β”‚           (FastAPI + Python on Port 8000)                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Routes:                                             β”‚   β”‚
β”‚  β”‚  β€’ POST /chat - Query processing with agents         β”‚   β”‚
β”‚  β”‚  β€’ POST /eligibility - Scheme eligibility check      β”‚   β”‚
β”‚  β”‚  β€’ POST /profile - User profile management           β”‚   β”‚
β”‚  β”‚  β€’ GET /schemes - Scheme browsing & filtering        β”‚   β”‚
β”‚  β”‚  β€’ POST /apply - Application submission              β”‚   β”‚
β”‚  β”‚  β€’ GET /alerts - Alert management                    β”‚   β”‚
β”‚  β”‚                                                      β”‚   β”‚
β”‚  β”‚  Middleware:                                         β”‚   β”‚
β”‚  β”‚  β€’ Firebase authentication                           β”‚   β”‚
β”‚  β”‚  β€’ CORS protection                                   β”‚   β”‚
β”‚  β”‚  β€’ Request validation & logging                      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                ↓ (Python)       ↓ (HTTP)                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           AI AGENTS LAYER         β”‚   DATA LAYER            β”‚
β”‚       (Multi-Agent Orchestration) β”‚ (Persistence & Search)  β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ 1. Query Agent              β”‚   β”‚ β”‚ MongoDB:            β”‚ β”‚
β”‚ β”‚    β€’ Intent extraction      β”‚   β”‚ β”‚  β€’ Users            β”‚ β”‚
β”‚ β”‚    β€’ Entity recognition     β”‚   β”‚ β”‚  β€’ Profiles         β”‚ β”‚
β”‚ β”‚                             β”‚   β”‚ β”‚  β€’ Applications     β”‚ β”‚
β”‚ β”‚ 2. RAG Agent                β”‚   β”‚ β”‚  β€’ Scheme data      β”‚ β”‚
β”‚ β”‚    β€’ Vector search          β”‚   β”‚ β”‚                     β”‚ β”‚
β”‚ β”‚    β€’ Semantic matching      β”‚   β”‚ β”‚ ChromaDB:           β”‚ β”‚
β”‚ β”‚    β€’ Fallback keyword       β”‚   β”‚ β”‚  β€’ Embeddings       β”‚ β”‚
β”‚ β”‚                             β”‚   β”‚ β”‚  β€’ Vector index     β”‚ β”‚
β”‚ β”‚ 3. Eligibility Agent        β”‚   β”‚ β”‚                     β”‚ β”‚
β”‚ β”‚    β€’ Rule-based logic       β”‚   β”‚ β”‚ Firebase:           β”‚ β”‚
β”‚ β”‚    β€’ Criteria validation    β”‚   β”‚ β”‚  β€’ Auth tokens      β”‚ β”‚
β”‚ β”‚    β€’ Score calculation      β”‚   β”‚ β”‚  β€’ User sessions    β”‚ β”‚
β”‚ β”‚                             β”‚   β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚ 4. Compliance Agent         β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Response validation    β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Hallucination blocking β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Source citation        β”‚   β”‚                         β”‚
β”‚ β”‚                             β”‚   β”‚                         β”‚
β”‚ β”‚ 5. Action Agent             β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Step generation        β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Document requirements  β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Timeline estimation    β”‚   β”‚                         β”‚
β”‚ β”‚                             β”‚   β”‚                         β”‚
β”‚ β”‚ 6. Alert Agent              β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Profile monitoring     β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Eligibility tracking   β”‚   β”‚                         β”‚
β”‚ β”‚    β€’ Notification creation  β”‚   β”‚                         β”‚
β”‚ β”‚                             β”‚   β”‚                         β”‚
β”‚ β”‚  ↓ (Groq LLM API)           β”‚   β”‚                         β”‚
β”‚ β”‚  Groq (llama-3.3-70b)       β”‚   β”‚                         β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Complete Setup Guide

Step 1: Clone Repository

git clone https://github.com/your-repo/scheme-navigator-ai.git
cd scheme-navigator-ai

Step 2: Environment Configuration

Create .env file in project root:

# LLM Configuration
GROQ_API_KEY=your_groq_api_key_here

# Firebase Configuration
FIREBASE_API_KEY=your_firebase_api_key
FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_STORAGE_BUCKET=your-project.appspot.com
FIREBASE_MESSAGING_SENDER_ID=your_sender_id
FIREBASE_APP_ID=your_app_id

# MongoDB
MONGODB_URL=mongodb+srv://user:password@cluster.mongodb.net/scheme-navigator

# Server Configuration
API_HOST=0.0.0.0
API_PORT=8000

Step 3: Install Dependencies

Backend:

cd backend
pip install -r requirements.txt

Frontend:

cd frontend
npm install

Step 4: Start Services (3 Terminals)

Terminal 1: Backend API

cd backend
python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Runs on http://localhost:8000
# Swagger UI: http://localhost:8000/docs

Terminal 2: Frontend Application

cd frontend
npm run dev
# Runs on http://localhost:5173

Terminal 3: Run Tests (Optional)

cd backend
python test_api.py

Open Browser: http://localhost:5173


πŸ“– Usage Examples

Example 1: Profile-Based Scheme Discovery

User: "I'm a 32-year-old farmer from Maharashtra with β‚Ή2.5L annual income"
System: 
  Identified as: Farmer, Below middle income
  Found 12 eligible schemes
  Top 3: PM-KISAN, PMAY, Pradhan Mantri Yojana

Example 2: Direct Eligibility Check

User: "Am I eligible for PM-KISAN?"
System:
  YES - You qualify!
  Monthly benefit: β‚Ή500-1000
  Application deadline: Open
  Next steps: Upload land documents

Example 3: Missed Benefits Alert

User: "Show me schemes I might have missed"
System:
  Missed 3 schemes!
  β€’ Pradhan Mantri Gramin Awas Yojana (Housing)
  β€’ PM-WANI (Internet access)
  β€’ State-specific agriculture subsidies

πŸ§ͺ Testing

# Run all tests
cd backend
python test_api.py

# Expected Output:
# Test 1: Query intent extraction - PASSED
# Test 2: RAG scheme retrieval - PASSED
# Test 3: Eligibility validation - PASSED
# Test 4: Compliance check - PASSED
# Test 5: Action guidance - PASSED
# Test 6: Alert generation - PASSED
# Test 7: End-to-end chat - PASSED
# 
# Result: 7/7 PASSED (100%)

πŸ“ Project Structure

scheme-navigator-ai/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py                    # FastAPI server
β”‚   β”œβ”€β”€ orchestrator.py            # Agent coordination
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ query_agent.py         # Intent extraction
β”‚   β”‚   β”œβ”€β”€ rag_agent.py           # Scheme retrieval
β”‚   β”‚   β”œβ”€β”€ eligibility_agent.py   # Eligibility check
β”‚   β”‚   β”œβ”€β”€ compliance_agent.py    # Response validation
β”‚   β”‚   β”œβ”€β”€ action_agent.py        # Application steps
β”‚   β”‚   └── alert_agent.py         # Profile management
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ settings.py            # Configuration
β”‚   β”‚   └── prompts.py             # Agent prompts
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ schemes_data.json      # Scheme database
β”‚   β”‚   └── chroma_db/             # Vector embeddings
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ llm_service.py         # Groq LLM interface
β”‚   β”‚   β”œβ”€β”€ firebase_service.py    # Authentication
β”‚   β”‚   └── database.py            # Data persistence
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatInterface.jsx     # Main chat UI
β”‚   β”‚   β”‚   β”œβ”€β”€ ProfileForm.jsx       # User profiles
β”‚   β”‚   β”‚   β”œβ”€β”€ SchemeCard.jsx        # Scheme display
β”‚   β”‚   β”‚   β”œβ”€β”€ VoiceInputButton.jsx  # Voice input
β”‚   β”‚   β”‚   β”œβ”€β”€ MissedBenefitsPanel.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AlertsPanel.jsx       # Notifications
β”‚   β”‚   β”‚   └── MessageBubble.jsx
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   β”œβ”€β”€ useChat.js
β”‚   β”‚   β”‚   β”œβ”€β”€ useProfile.js
β”‚   β”‚   β”‚   └── useSpeechRecognition.js
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ api.js               # Backend API client
β”‚   β”‚   β”‚   └── voiceService.js      # Voice processing
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProfilePage.jsx
β”‚   β”‚   β”‚   └── AlertsPage.jsx
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── tailwind.config.js
β”‚
β”œβ”€β”€ .env                          # Environment variables
β”œβ”€β”€ README.md                     # This file
β”œβ”€β”€ QUICK_START.md               # 30-second setup
└── requirements.txt

πŸ”„ Data Flow Pipelines

Chat Query: User β†’ Query Agent (intent extraction) β†’ RAG Agent (semantic search) β†’ Eligibility Agent (criteria check) β†’ Compliance Agent (validation) β†’ Response

User Profile: Profile Form β†’ Firebase/MongoDB β†’ Alert Agent (scheme matching) β†’ Notifications (in-app/email/WhatsApp)

Application Help: User Query β†’ Action Agent (step-by-step guide) β†’ Document templates + FAQ β†’ Formatted response


🌟 API Endpoints

Method Endpoint Purpose
POST /chat Process user query through agent pipeline
POST /eligibility Check scheme eligibility for user
POST /profile Create/update user profile
GET /schemes Browse all indexed schemes
POST /apply Submit scheme application
GET /alerts Fetch user alerts & notifications
POST /voice Process voice input

πŸ”§ API Endpoints

Health Check

GET http://localhost:8000/

Chat Query

POST http://localhost:8000/chat
Content-Type: application/json

{
  "query": "I am a farmer from Maharashtra",
  "profile": {
    "age": 30,
    "state": "Maharashtra",
    "occupation": "farmer",
    "income": 250000
  }
}

Get All Schemes

GET http://localhost:8000/schemes

Save Profile

POST http://localhost:8000/profile
Content-Type: application/json

{
  "profile": {
    "age": 30,
    "income": 250000,
    "state": "Maharashtra",
    "occupation": "farmer"
  }
}

Missed Benefits

GET http://localhost:8000/missed?age=30&state=Maharashtra&occupation=farmer

πŸ“Š Data Ingestion

Load scheme data into ChromaDB for semantic search:

python -m backend.data.ingestion add       # Add schemes to ChromaDB
python -m backend.data.ingestion list      # List indexed schemes
python -m backend.data.ingestion reset     # Clear database

πŸ§ͺ Testing

Run All Tests

python test_api.py

Manual Testing

  1. Open http://localhost:5173 in browser
  2. Fill profile (age, state, occupation)
  3. Send message: "I am a farmer from Maharashtra"
  4. Verify schemes appear with details
  5. Test voice input
  6. Check missed benefits section

🀝 Architecture Overview (Multi-Agent RAG Pipeline)

        Web Browser (React)
             ↓ (API)
         Frontend UI
             ↓ (HTTP POST /chat, /profile)
       FastAPI Backend
             ↓
      Pipeline Orchestrator
             ↓
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    ↓                   ↓
  Agents            Database (ChromaDB + JSON)
  1. Query          23 Government Schemes
    2. RAG (ChromaDB)  User Profiles (MongoDB)
  3. Eligibility    
  4. Compliance
  5. LLM Service (Groq Llama-3.3)
  6. Action
  7. Alert (Missed Benefits)

πŸ“ˆ Performance

  • API Response Time: <2 seconds
  • Frontend Load: <1 second
  • Memory Usage: <500MB

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.


πŸ™ Acknowledgments

  • Built for Economic Times GenAI Hackathon
  • Government scheme data from official sources
  • LLM powered by Groq
  • Vector embeddings with ChromaDB

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors