KoustavBera/MySarkar

5

stars

18

commits

JavaScript

primary language

Sep 6, 2025

updated

mysarkar.vercel.app

README

๐Ÿ›๏ธ MySarkar - AI-Powered Government Scheme Discovery Platform

Bridging Citizens and Government Services through Intelligent Technology


๐ŸŒŸ Moto

"If AI can revolutionize e-commerce recommendations, why not help citizens discover the government schemes they deserve?"

MySarkar is a comprehensive multilingual AI platform that makes government scheme discovery intelligent, accessible, and inclusive โ€” supporting everything from smartphone apps to keypad phone IVR calls.


Team AKAASHVANI - Koustav, Swetanjana, Vidhya, Tanishq, Shahid

๐Ÿงฉ Core Features

๐Ÿ” 1. Intelligent Scheme Discovery

โœ… Vector-powered search using:

  • ๐Ÿง  Semantic embeddings with Xenova/all-MiniLM-L6-v2 + multilingual transformers
  • ๐Ÿ“ Location-based filtering (state/district)
  • ๐Ÿ‘ค Profile-based personalization
  • ๐ŸŽฏ Real-time eligibility checking
{
  "query": "farmer loan scheme west bengal",
  "results": [
    {
      "name": "PM-KISAN Samman Nidhi",
      "eligibility_score": 0.94,
      "benefits": "โ‚น6,000/year direct transfer"
    }
  ]
}

๐Ÿค– 2. Universal Government AI Assistant

Powered by Google Gemini + Hugging Face Models with comprehensive knowledge:

  • ๐Ÿฅ Healthcare & Insurance (Ayushman Bharat, PMJJBY)
  • ๐ŸŽ“ Education & Scholarships (NSP, PM YASASVI)
  • ๐Ÿ’ผ Employment & Skills (MGNREGA, PMKVY)
  • ๐Ÿ’ฐ Financial Services (Jan Dhan, Mudra Loans)
  • ๐Ÿ“„ Digital Services (Aadhaar, PAN, Passport)
{
  "query": "West Bengal health insurance schemes",
  "response": "Available schemes: Ayushman Bharat (โ‚น5L coverage), Swasthya Sathi (โ‚น5L state scheme)..."
}

๐Ÿ“ž 3. Multilingual IVR System (Twilio + Ngrok)

Press 1 for scheme information
Press 2 for eligibility check
Press 3 to speak with AI assistant

Supports keypad phones with:

  • ๐Ÿ”„ Twilio Voice API integration
  • ๐ŸŒ Ngrok tunneling for local development
  • ๐Ÿ—ฃ๏ธ Text-to-Speech with IndicTrans2 for Indian languages
  • ๐Ÿ“ž DTMF navigation for feature phones
  • ๐Ÿง  Hugging Face models for voice processing

๐Ÿ“„ 4. Document Intelligence & OCR

Smart form assistance using:

  • ๐Ÿ‘๏ธ Tesseract OCR for document scanning
  • ๐Ÿง  AI-powered field extraction
  • ๐Ÿ“ Step-by-step form filling guidance
  • ๐Ÿ”Š Audio instructions via TTS
{
  "extracted_fields": ["name", "aadhaar", "income"],
  "help_text": "Fill Aadhaar as 12-digit number without spaces",
  "audio_url": "/audio/form_help_hindi.mp3"
}

๐Ÿ‘ฅ 5. Community Engagement Platform

Role-based social features:

  • ๐Ÿ’ฌ Community posts and discussions
  • ๐Ÿท๏ธ Special badges for govt officials & NGOs
  • ๐Ÿ“Š AI sentiment analysis of community feedback
  • ๐Ÿšซ Hate speech detection and moderation
  • ๐Ÿ”” Real-time notification system

โš™๏ธ Tech Stack

LayerTechnologyPurpose
๐ŸŽจ FrontendReact 19 + Vite + Tailwind CSSModern responsive UI
๐Ÿ”ง BackendNode.js + Express + MongoDBRESTful API & data management
๐Ÿง  AI ServicesFastAPI + Python + TransformersML/AI processing pipeline
๐Ÿ—„๏ธ DatabaseMongoDB Atlas + Vector SearchSemantic scheme discovery
๐Ÿ“ž VoiceTwilio + NgrokIVR calling system
๐ŸŒ TranslationIndicTrans2 + Google TranslateMulti-language support
๐Ÿค– ML ModelsHugging Face + Custom ModelsNLP & Computer Vision
๐Ÿ” AuthJWT + bcryptSecure authentication

๐Ÿ—๏ธ Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   React Frontend โ”‚โ”€โ”€โ”€โ”€โ”‚  Node.js Backend โ”‚โ”€โ”€โ”€โ”€โ”‚  FastAPI AI Hub โ”‚
โ”‚   (Port 3000)   โ”‚    โ”‚   (Port 5000)   โ”‚    โ”‚   (Port 8000)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚  MongoDB Atlas  โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚ (Vector Search) โ”‚
                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚   Twilio IVR System     โ”‚
                    โ”‚   (Ngrok Tunneling)     โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

๐Ÿ“‹ Prerequisites

Node.js 18+, Python 3.9+, MongoDB Atlas account
Twilio account, Google API keys, Ngrok

๐Ÿ”ง Installation

1๏ธโƒฃ Backend Setup

cd backend
npm install
cp .env.example .env
# Configure: MONGODB_URI, JWT_SECRET, CORS_ORIGIN
npm run dev  # Runs on port 5000

2๏ธโƒฃ Frontend Setup

cd frontend
npm install
cp .env.example .env
# Configure: VITE_BACKEND_URL, VITE_GEMINI_API_KEY
npm run dev  # Runs on port 3000

3๏ธโƒฃ AI Services Setup

cd fastAPI
python -m venv myenv
source myenv/bin/activate  # Windows: myenv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Configure: GOOGLE_API_KEY, BACKEND_URL
python -m uvicorn app.main:app --reload  # Runs on port 8000

4๏ธโƒฃ IVR System Setup

# Install ngrok globally
npm install -g ngrok

# Expose FastAPI to internet
ngrok http 8000

# Configure Twilio webhook URL:
# https://your-ngrok-url.ngrok.io/ivr/voice

๐Ÿ“Š API Endpoints

๐Ÿ” Authentication

MethodEndpointDescription
POST/api/v1/auth/registerUser registration
POST/api/v1/auth/loginUser login
GET/api/v1/auth/meGet current user

๐ŸŽฏ Schemes

MethodEndpointDescription
GET/api/v1/schemesList all schemes
POST/api/v1/schemes/searchVector search schemes
GET/api/v1/schemes/eligible/meGet eligible schemes

๐Ÿค– AI Services

MethodEndpointDescription
POST/chatAI assistant chat
POST/analyze-formOCR + form help
POST/detect-hatespeechContent moderation
POST/translateText translation

๐Ÿ“ž IVR System

MethodEndpointDescription
POST/ivr/voiceTwilio voice webhook
POST/ivr/gatherDTMF input processing
GET/ivr/tts/{text}Text-to-speech audio

๐Ÿง  AI/ML Components

๐Ÿ” Vector Search Engine

// Semantic scheme matching with state-of-the-art embeddings
const embedder = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2");
const queryEmbedding = await embedder(userQuery);
const results = await collection.aggregate([
  {
    $vectorSearch: {
      queryVector: queryEmbedding,
      path: "embedding",
      numCandidates: 200,
      limit: 5
    }
  }
]);

๐ŸŒ Advanced Translation Pipeline

# IndicTrans2 for Indian languages
from IndicTransToolkit import IndicProcessor
ip = IndicProcessor(inference=True)
input_sentences = ["Government scheme information"]
batch = ip.preprocess_batch(input_sentences, src_lang="eng_Latn", tgt_lang="hin_Deva")
translated = model(batch)
output = ip.postprocess_batch(translated, lang="hin_Deva")

๐Ÿง  Multi-Model AI Pipeline

# Hugging Face Transformers integration
from transformers import pipeline, AutoTokenizer, AutoModel

# Sentiment analysis for community posts
sentiment_analyzer = pipeline("sentiment-analysis", 
                            model="cardiffnlp/twitter-roberta-base-sentiment-latest")

# Multilingual embeddings
embedding_model = AutoModel.from_pretrained("sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")

# Google Gemini for conversational AI
model = genai.GenerativeModel('gemini-1.5-flash')
response = model.generate_content(f"""
You are an Indian Government Services Assistant.
Query: {user_query}
Schemes: {relevant_schemes}
Respond directly with helpful information.
""")

๐Ÿ‘๏ธ Computer Vision & OCR

# Advanced document processing pipeline
import pytesseract
from PIL import Image
from transformers import pipeline

# OCR with preprocessing
ocr_result = pytesseract.image_to_string(preprocessed_image, lang='eng+hin+ben')

# Document classification
doc_classifier = pipeline("image-classification", 
                         model="microsoft/dit-base-finetuned-rvlcdip")

# Form field extraction with NER
ner_pipeline = pipeline("ner", 
                       model="dbmdz/bert-large-cased-finetuned-conll03-english")
fields = ner_pipeline(ocr_result)

๐Ÿ›ก๏ธ Content Moderation

# Custom hate speech detection model
import pickle
from sklearn.feature_extraction.text import TfidfVectorizer

# Load pre-trained models
tfidf = pickle.load(open('vectorizer.pkl', 'rb'))
hate_model = pickle.load(open('model.pkl', 'rb'))

# Multi-language hate speech detection
transformed_text = transform_text(user_input)
vector_input = tfidf.transform([transformed_text])
is_hate_speech = hate_model.predict(vector_input)[0]

๐ŸŽญ User Roles & Permissions

RolePermissionsUI Features
๐Ÿ‘ค CitizenView schemes, apply, community postsStandard interface
๐Ÿ›๏ธ Govt OfficialManage schemes, approve applicationsGold highlighting, admin badge
๐Ÿค NGOCreate schemes, community engagementGreen highlighting, NGO badge
โšก AdminFull system access, user managementRed highlighting, admin badge

๐Ÿ“ฑ Multi-Platform Support

๐ŸŒ Web Application

  • Responsive design for desktop/mobile
  • Progressive Web App (PWA) ready
  • Offline scheme browsing capability

๐Ÿ“ž IVR System Flow

๐Ÿ“ž User calls Twilio number
    โ†“
๐ŸŽต Welcome message in preferred language
    โ†“
๐Ÿ”ข DTMF menu options
    โ†“ (Press 1)
๐Ÿ” Scheme information service
    โ†“ (Press 2)  
โœ… Eligibility checking
    โ†“ (Press 3)
๐Ÿค– AI assistant conversation

๐Ÿ“ฑ Mobile Features

  • Touch-friendly interface
  • Voice input support
  • Camera document scanning
  • Push notifications

๐Ÿ›ก๏ธ Security & Compliance

๐Ÿ” Authentication & Authorization

// JWT-based security
const token = jwt.sign({ userId, role }, JWT_SECRET, { expiresIn: '7d' });
// Role-based access control
const hasPermission = user.permissions.includes('manage_schemes');

๐Ÿšซ Content Moderation

# Hate speech detection
transformed_text = transform_text(user_input)
vector_input = tfidf.transform([transformed_text])
is_hate_speech = hate_model.predict(vector_input)[0]

๐Ÿ“Š Data Privacy

  • GDPR-compliant data handling
  • Encrypted sensitive information
  • Audit logs for all operations
  • User consent management

๐Ÿ“ˆ Real-World Impact

Traditional ProcessWith MySarkarImprovement
Manual scheme searchAI-powered discovery10x faster
Language barriersMulti-lingual support100% accessible
Complex formsOCR + AI assistance80% error reduction
Limited accessIVR for feature phonesUniversal reach
Scattered informationUnified platformSingle source of truth

๐Ÿงช Sample Workflows

โœ… Scheme Discovery

POST /api/v1/schemes/search
{
  "query": "farmer subsidy odisha",
  "user_profile": {
    "state": "Odisha",
    "category": "farmer",
    "income": 200000
  }
}

๐Ÿค– AI Chat Assistance

POST /chat
{
  "message": "เคฎเฅเคเฅ‡ เคธเฅเคตเคพเคธเฅเคฅเฅเคฏ เคฌเฅ€เคฎเคพ เคšเคพเคนเคฟเค",
  "language": "Hindi"
}

๐Ÿ“„ Document Analysis

POST /analyze-form
{
  "image_data": "base64_encoded_image",
  "language": "Bengali"
}

๐Ÿ”„ Development Workflow

๐Ÿงช Testing

# Backend tests
cd backend && npm test

# AI services tests
cd fastAPI && python test_services.py

# Frontend tests
cd frontend && npm run test

๐Ÿš€ Deployment

# Production build
npm run build

# Docker deployment
docker-compose up -d

# Environment setup
cp .env.production .env

๐Ÿ“Š Monitoring & Analytics

๐Ÿ“ˆ Key Metrics

  • Scheme discovery success rate
  • User engagement analytics
  • IVR call completion rates
  • AI response accuracy scores
  • Community sentiment trends

๐Ÿ” Logging

// Structured logging
logger.info('Scheme search', {
  userId,
  query,
  resultsCount,
  responseTime: Date.now() - startTime
});

๐Ÿ“Š Monitoring & Logging

ToolPurposeExample Metrics / Logs
PrometheusMetrics collectionAPI latency, request count, DB query time
GrafanaDashboards & alertsAPI health, inference latency, IVR funnel
LokiCentralized loggingErrors, OCR failures, Twilio webhook logs
TempoDistributed tracingEnd-to-end request traces across services
SentryError monitoringBackend crashes, React errors

๐ŸŒŸ Future Roadmap

๐Ÿ”ฎ Phase 2 Features

  • ๐Ÿ”— Direct government API integrations
  • ๐Ÿ“ฑ Native mobile applications
  • ๐ŸŽ™๏ธ Advanced voice interactions
  • ๐Ÿค– Chatbot for WhatsApp/Telegram
  • ๐Ÿ“Š Advanced analytics dashboard

๐ŸŒ Expansion Plans

  • Support for all 22 official Indian languages
  • Integration with state government portals
  • Blockchain-based application tracking
  • AI-powered policy recommendation engine

๐Ÿค Contributing

๐Ÿ› ๏ธ Development Setup

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

๐Ÿ“ Code Standards

  • ESLint for JavaScript/React
  • Black formatter for Python
  • Conventional commits
  • 80%+ test coverage

๐Ÿ“„ License

MIT ยฉ 2025 MySarkar Team
Built for Digital India Initiative


๐Ÿ™ Acknowledgments

  • Google Gemini for conversational AI
  • MongoDB Atlas for vector search capabilities
  • Twilio for voice communication infrastructure
  • Hugging Face for transformer models
  • Government of India for open data initiatives

๐Ÿš€ Making Government Services Accessible to Every Indian Citizen

Contributors

KoustavBera

6 commits

swetanjana

4 commits

VidhyaVijay26

2 commits

KoustavBera/MySarkar

5

stars

18

commits

JavaScript

primary language

Sep 6, 2025

updated

mysarkar.vercel.app

README

๐Ÿ›๏ธ MySarkar - AI-Powered Government Scheme Discovery Platform

Bridging Citizens and Government Services through Intelligent Technology


๐ŸŒŸ Moto

"If AI can revolutionize e-commerce recommendations, why not help citizens discover the government schemes they deserve?"

MySarkar is a comprehensive multilingual AI platform that makes government scheme discovery intelligent, accessible, and inclusive โ€” supporting everything from smartphone apps to keypad phone IVR calls.


Team AKAASHVANI - Koustav, Swetanjana, Vidhya, Tanishq, Shahid

๐Ÿงฉ Core Features

๐Ÿ” 1. Intelligent Scheme Discovery

โœ… Vector-powered search using:

  • ๐Ÿง  Semantic embeddings with Xenova/all-MiniLM-L6-v2 + multilingual transformers
  • ๐Ÿ“ Location-based filtering (state/district)
  • ๐Ÿ‘ค Profile-based personalization
  • ๐ŸŽฏ Real-time eligibility checking
{
  "query": "farmer loan scheme west bengal",
  "results": [
    {
      "name": "PM-KISAN Samman Nidhi",
      "eligibility_score": 0.94,
      "benefits": "โ‚น6,000/year direct transfer"
    }
  ]
}

๐Ÿค– 2. Universal Government AI Assistant

Powered by Google Gemini + Hugging Face Models with comprehensive knowledge:

  • ๐Ÿฅ Healthcare & Insurance (Ayushman Bharat, PMJJBY)
  • ๐ŸŽ“ Education & Scholarships (NSP, PM YASASVI)
  • ๐Ÿ’ผ Employment & Skills (MGNREGA, PMKVY)
  • ๐Ÿ’ฐ Financial Services (Jan Dhan, Mudra Loans)
  • ๐Ÿ“„ Digital Services (Aadhaar, PAN, Passport)
{
  "query": "West Bengal health insurance schemes",
  "response": "Available schemes: Ayushman Bharat (โ‚น5L coverage), Swasthya Sathi (โ‚น5L state scheme)..."
}

๐Ÿ“ž 3. Multilingual IVR System (Twilio + Ngrok)

Press 1 for scheme information
Press 2 for eligibility check
Press 3 to speak with AI assistant

Supports keypad phones with:

  • ๐Ÿ”„ Twilio Voice API integration
  • ๐ŸŒ Ngrok tunneling for local development
  • ๐Ÿ—ฃ๏ธ Text-to-Speech with IndicTrans2 for Indian languages
  • ๐Ÿ“ž DTMF navigation for feature phones
  • ๐Ÿง  Hugging Face models for voice processing

๐Ÿ“„ 4. Document Intelligence & OCR

Smart form assistance using:

  • ๐Ÿ‘๏ธ Tesseract OCR for document scanning
  • ๐Ÿง  AI-powered field extraction
  • ๐Ÿ“ Step-by-step form filling guidance
  • ๐Ÿ”Š Audio instructions via TTS
{
  "extracted_fields": ["name", "aadhaar", "income"],
  "help_text": "Fill Aadhaar as 12-digit number without spaces",
  "audio_url": "/audio/form_help_hindi.mp3"
}

๐Ÿ‘ฅ 5. Community Engagement Platform

Role-based social features:

  • ๐Ÿ’ฌ Community posts and discussions
  • ๐Ÿท๏ธ Special badges for govt officials & NGOs
  • ๐Ÿ“Š AI sentiment analysis of community feedback
  • ๐Ÿšซ Hate speech detection and moderation
  • ๐Ÿ”” Real-time notification system

โš™๏ธ Tech Stack

LayerTechnologyPurpose
๐ŸŽจ FrontendReact 19 + Vite + Tailwind CSSModern responsive UI
๐Ÿ”ง BackendNode.js + Express + MongoDBRESTful API & data management
๐Ÿง  AI ServicesFastAPI + Python + TransformersML/AI processing pipeline
๐Ÿ—„๏ธ DatabaseMongoDB Atlas + Vector SearchSemantic scheme discovery
๐Ÿ“ž VoiceTwilio + NgrokIVR calling system
๐ŸŒ TranslationIndicTrans2 + Google TranslateMulti-language support
๐Ÿค– ML ModelsHugging Face + Custom ModelsNLP & Computer Vision
๐Ÿ” AuthJWT + bcryptSecure authentication

๐Ÿ—๏ธ Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   React Frontend โ”‚โ”€โ”€โ”€โ”€โ”‚  Node.js Backend โ”‚โ”€โ”€โ”€โ”€โ”‚  FastAPI AI Hub โ”‚
โ”‚   (Port 3000)   โ”‚    โ”‚   (Port 5000)   โ”‚    โ”‚   (Port 8000)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚  MongoDB Atlas  โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚ (Vector Search) โ”‚
                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚   Twilio IVR System     โ”‚
                    โ”‚   (Ngrok Tunneling)     โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

๐Ÿ“‹ Prerequisites

Node.js 18+, Python 3.9+, MongoDB Atlas account
Twilio account, Google API keys, Ngrok

๐Ÿ”ง Installation

1๏ธโƒฃ Backend Setup

cd backend
npm install
cp .env.example .env
# Configure: MONGODB_URI, JWT_SECRET, CORS_ORIGIN
npm run dev  # Runs on port 5000

2๏ธโƒฃ Frontend Setup

cd frontend
npm install
cp .env.example .env
# Configure: VITE_BACKEND_URL, VITE_GEMINI_API_KEY
npm run dev  # Runs on port 3000

3๏ธโƒฃ AI Services Setup

cd fastAPI
python -m venv myenv
source myenv/bin/activate  # Windows: myenv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Configure: GOOGLE_API_KEY, BACKEND_URL
python -m uvicorn app.main:app --reload  # Runs on port 8000

4๏ธโƒฃ IVR System Setup

# Install ngrok globally
npm install -g ngrok

# Expose FastAPI to internet
ngrok http 8000

# Configure Twilio webhook URL:
# https://your-ngrok-url.ngrok.io/ivr/voice

๐Ÿ“Š API Endpoints

๐Ÿ” Authentication

MethodEndpointDescription
POST/api/v1/auth/registerUser registration
POST/api/v1/auth/loginUser login
GET/api/v1/auth/meGet current user

๐ŸŽฏ Schemes

MethodEndpointDescription
GET/api/v1/schemesList all schemes
POST/api/v1/schemes/searchVector search schemes
GET/api/v1/schemes/eligible/meGet eligible schemes

๐Ÿค– AI Services

MethodEndpointDescription
POST/chatAI assistant chat
POST/analyze-formOCR + form help
POST/detect-hatespeechContent moderation
POST/translateText translation

๐Ÿ“ž IVR System

MethodEndpointDescription
POST/ivr/voiceTwilio voice webhook
POST/ivr/gatherDTMF input processing
GET/ivr/tts/{text}Text-to-speech audio

๐Ÿง  AI/ML Components

๐Ÿ” Vector Search Engine

// Semantic scheme matching with state-of-the-art embeddings
const embedder = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2");
const queryEmbedding = await embedder(userQuery);
const results = await collection.aggregate([
  {
    $vectorSearch: {
      queryVector: queryEmbedding,
      path: "embedding",
      numCandidates: 200,
      limit: 5
    }
  }
]);

๐ŸŒ Advanced Translation Pipeline

# IndicTrans2 for Indian languages
from IndicTransToolkit import IndicProcessor
ip = IndicProcessor(inference=True)
input_sentences = ["Government scheme information"]
batch = ip.preprocess_batch(input_sentences, src_lang="eng_Latn", tgt_lang="hin_Deva")
translated = model(batch)
output = ip.postprocess_batch(translated, lang="hin_Deva")

๐Ÿง  Multi-Model AI Pipeline

# Hugging Face Transformers integration
from transformers import pipeline, AutoTokenizer, AutoModel

# Sentiment analysis for community posts
sentiment_analyzer = pipeline("sentiment-analysis", 
                            model="cardiffnlp/twitter-roberta-base-sentiment-latest")

# Multilingual embeddings
embedding_model = AutoModel.from_pretrained("sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")

# Google Gemini for conversational AI
model = genai.GenerativeModel('gemini-1.5-flash')
response = model.generate_content(f"""
You are an Indian Government Services Assistant.
Query: {user_query}
Schemes: {relevant_schemes}
Respond directly with helpful information.
""")

๐Ÿ‘๏ธ Computer Vision & OCR

# Advanced document processing pipeline
import pytesseract
from PIL import Image
from transformers import pipeline

# OCR with preprocessing
ocr_result = pytesseract.image_to_string(preprocessed_image, lang='eng+hin+ben')

# Document classification
doc_classifier = pipeline("image-classification", 
                         model="microsoft/dit-base-finetuned-rvlcdip")

# Form field extraction with NER
ner_pipeline = pipeline("ner", 
                       model="dbmdz/bert-large-cased-finetuned-conll03-english")
fields = ner_pipeline(ocr_result)

๐Ÿ›ก๏ธ Content Moderation

# Custom hate speech detection model
import pickle
from sklearn.feature_extraction.text import TfidfVectorizer

# Load pre-trained models
tfidf = pickle.load(open('vectorizer.pkl', 'rb'))
hate_model = pickle.load(open('model.pkl', 'rb'))

# Multi-language hate speech detection
transformed_text = transform_text(user_input)
vector_input = tfidf.transform([transformed_text])
is_hate_speech = hate_model.predict(vector_input)[0]

๐ŸŽญ User Roles & Permissions

RolePermissionsUI Features
๐Ÿ‘ค CitizenView schemes, apply, community postsStandard interface
๐Ÿ›๏ธ Govt OfficialManage schemes, approve applicationsGold highlighting, admin badge
๐Ÿค NGOCreate schemes, community engagementGreen highlighting, NGO badge
โšก AdminFull system access, user managementRed highlighting, admin badge

๐Ÿ“ฑ Multi-Platform Support

๐ŸŒ Web Application

  • Responsive design for desktop/mobile
  • Progressive Web App (PWA) ready
  • Offline scheme browsing capability

๐Ÿ“ž IVR System Flow

๐Ÿ“ž User calls Twilio number
    โ†“
๐ŸŽต Welcome message in preferred language
    โ†“
๐Ÿ”ข DTMF menu options
    โ†“ (Press 1)
๐Ÿ” Scheme information service
    โ†“ (Press 2)  
โœ… Eligibility checking
    โ†“ (Press 3)
๐Ÿค– AI assistant conversation

๐Ÿ“ฑ Mobile Features

  • Touch-friendly interface
  • Voice input support
  • Camera document scanning
  • Push notifications

๐Ÿ›ก๏ธ Security & Compliance

๐Ÿ” Authentication & Authorization

// JWT-based security
const token = jwt.sign({ userId, role }, JWT_SECRET, { expiresIn: '7d' });
// Role-based access control
const hasPermission = user.permissions.includes('manage_schemes');

๐Ÿšซ Content Moderation

# Hate speech detection
transformed_text = transform_text(user_input)
vector_input = tfidf.transform([transformed_text])
is_hate_speech = hate_model.predict(vector_input)[0]

๐Ÿ“Š Data Privacy

  • GDPR-compliant data handling
  • Encrypted sensitive information
  • Audit logs for all operations
  • User consent management

๐Ÿ“ˆ Real-World Impact

Traditional ProcessWith MySarkarImprovement
Manual scheme searchAI-powered discovery10x faster
Language barriersMulti-lingual support100% accessible
Complex formsOCR + AI assistance80% error reduction
Limited accessIVR for feature phonesUniversal reach
Scattered informationUnified platformSingle source of truth

๐Ÿงช Sample Workflows

โœ… Scheme Discovery

POST /api/v1/schemes/search
{
  "query": "farmer subsidy odisha",
  "user_profile": {
    "state": "Odisha",
    "category": "farmer",
    "income": 200000
  }
}

๐Ÿค– AI Chat Assistance

POST /chat
{
  "message": "เคฎเฅเคเฅ‡ เคธเฅเคตเคพเคธเฅเคฅเฅเคฏ เคฌเฅ€เคฎเคพ เคšเคพเคนเคฟเค",
  "language": "Hindi"
}

๐Ÿ“„ Document Analysis

POST /analyze-form
{
  "image_data": "base64_encoded_image",
  "language": "Bengali"
}

๐Ÿ”„ Development Workflow

๐Ÿงช Testing

# Backend tests
cd backend && npm test

# AI services tests
cd fastAPI && python test_services.py

# Frontend tests
cd frontend && npm run test

๐Ÿš€ Deployment

# Production build
npm run build

# Docker deployment
docker-compose up -d

# Environment setup
cp .env.production .env

๐Ÿ“Š Monitoring & Analytics

๐Ÿ“ˆ Key Metrics

  • Scheme discovery success rate
  • User engagement analytics
  • IVR call completion rates
  • AI response accuracy scores
  • Community sentiment trends

๐Ÿ” Logging

// Structured logging
logger.info('Scheme search', {
  userId,
  query,
  resultsCount,
  responseTime: Date.now() - startTime
});

๐Ÿ“Š Monitoring & Logging

ToolPurposeExample Metrics / Logs
PrometheusMetrics collectionAPI latency, request count, DB query time
GrafanaDashboards & alertsAPI health, inference latency, IVR funnel
LokiCentralized loggingErrors, OCR failures, Twilio webhook logs
TempoDistributed tracingEnd-to-end request traces across services
SentryError monitoringBackend crashes, React errors

๐ŸŒŸ Future Roadmap

๐Ÿ”ฎ Phase 2 Features

  • ๐Ÿ”— Direct government API integrations
  • ๐Ÿ“ฑ Native mobile applications
  • ๐ŸŽ™๏ธ Advanced voice interactions
  • ๐Ÿค– Chatbot for WhatsApp/Telegram
  • ๐Ÿ“Š Advanced analytics dashboard

๐ŸŒ Expansion Plans

  • Support for all 22 official Indian languages
  • Integration with state government portals
  • Blockchain-based application tracking
  • AI-powered policy recommendation engine

๐Ÿค Contributing

๐Ÿ› ๏ธ Development Setup

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

๐Ÿ“ Code Standards

  • ESLint for JavaScript/React
  • Black formatter for Python
  • Conventional commits
  • 80%+ test coverage

๐Ÿ“„ License

MIT ยฉ 2025 MySarkar Team
Built for Digital India Initiative


๐Ÿ™ Acknowledgments

  • Google Gemini for conversational AI
  • MongoDB Atlas for vector search capabilities
  • Twilio for voice communication infrastructure
  • Hugging Face for transformer models
  • Government of India for open data initiatives

๐Ÿš€ Making Government Services Accessible to Every Indian Citizen

Contributors

KoustavBera

6 commits

swetanjana

4 commits

VidhyaVijay26

2 commits

Languages

JavaScript

80.4%

Python

16.6%

CSS

2.2%