Skip to content

codewithabhay10/SIH-Project-Sahay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‡ฎ๐Ÿ‡ณ PM-AJAY Digital Platform (SIHPS25152)

GitHub Smart India Hackathon License: ISC

A comprehensive digital platform for the Pradhan Mantri Anusuchit Jaati Abhyudaya Yojana (PM-AJAY) scheme, built for Smart India Hackathon 2025. This platform modernizes welfare fund disbursement, beneficiary management, and evidence tracking using blockchain technology, AI/ML models, and multi-channel communication.


๐Ÿ“‹ Table of Contents


๐Ÿ—๏ธ Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                           PM-AJAY Digital Platform                              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   Frontend  โ”‚   Backend   โ”‚  Blockchain  โ”‚   AI Models  โ”‚   Communication      โ”‚
โ”‚  (Next.js)  โ”‚ (Node/Fast) โ”‚  (Fabric)    โ”‚   (Python)   โ”‚  (WhatsApp/Chatbot)  โ”‚
โ”‚  Port:3000  โ”‚ Port:1604   โ”‚  Port:3002   โ”‚  Port:5000+  โ”‚     Port:3000        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚            โ”‚              โ”‚              โ”‚               โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                     โ”‚
                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚   MongoDB   โ”‚
                              โ”‚  Port:27017 โ”‚
                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Component Technologies
Frontend Next.js 14, React 18, TailwindCSS, TypeScript, Shepherd.js (guided tours)
Backend (Main API) Node.js 18+, Express.js, MongoDB, Mongoose, JWT Auth
Backend (Translation) FastAPI, Python 3.9+, Google Translate API (deep-translator)
Blockchain Hyperledger Fabric 2.x, Spring Boot (Java 17), Docker
AI/ML Models Python, XGBoost, Scikit-learn, LangChain, ChromaDB, RAG
Chatbot Node.js, Twilio WhatsApp API, MongoDB, Tesseract OCR
Video Conferencing Zego Cloud SDK

โœจ Features

๐Ÿ–ฅ๏ธ Frontend Dashboard

Feature Description
User Authentication Secure login/signup with role-based access (Ministry, PACC, State, SNA, IA, SAU)
Dashboard Analytics Real-time KPIs with donut charts, time-series graphs, and India heatmap
Proposal Management Create, track, and approve welfare proposals with multi-stage workflow
Project Tracking Monitor milestones with visual tracker and evidence uploads
Funds Management Track FTOs, PFMS confirmations, bank acknowledgments, and reconciliation
Beneficiary Management View/filter beneficiaries with ranking scores and demographic data
Evidence Repository Upload photos/documents with blockchain hash verification
Reports Generation Generate PDF/Excel reports for audits and compliance
SNA Dashboard State Nodal Agency view with account management
PACC View Project Appraisal & Central Committee approval interface
Multi-language Support 14+ Indian languages (Hindi, Bengali, Tamil, Telugu, etc.)
Video Conferencing Built-in Zego meeting rooms for virtual discussions
AI Chatbot Scheme FAQ assistant with context-aware responses
Guided Tour Interactive onboarding with Shepherd.js

โš™๏ธ Backend APIs

Main Backend (Node.js/Express) - Port 1604

  • User Management (Register, Login, Profile, OAuth)
  • Proposal CRUD with approval workflow
  • Project lifecycle with milestone tracking
  • Utilization Certificate (UC) upload/verification
  • Central ministry data aggregation
  • Document hash verification

Translation API (FastAPI) - Port 8000

  • Real-time translation for 14+ Indian regional languages
  • Auto-detect source language
  • Google Translate integration via deep-translator

โ›“๏ธ Blockchain (Hyperledger Fabric) - Port 3002

Channel Purpose Organizations
Approval Proposal & blueprint hashes Ministry, PACC, State
Funds FTO, PFMS, bank records Ministry, State, SNA
Implementation Beneficiary & evidence hashes State, IA, SNA
Audit Audit reports & UC hashes SAU, State, Ministry

20 blockchain API endpoints for hash storage and verification across 4 channels.

๐Ÿค– AI/ML Models

Model Purpose Data Files
Beneficiary Ranking XGBoost priority scoring synthetic_beneficiaries.csv (1.7MB), trained_model.json
Question Clustering Grievance pattern analysis pm_ajay_final_simulated_data.csv, processed_issues_uuid.csv
State Plan RAG Document Q&A with LangChain input.json, input2.json

๐Ÿ“ฑ WhatsApp Digital Khata Bot

  • User registration with demographic collection
  • Digital ledger for credits/debits
  • Transaction categories: Income, Expense, Loans, Repayments, Savings
  • OCR support for document scanning (Tesseract)
  • Twilio WhatsApp integration

๐Ÿ“ Project Structure

SIHPS25152_FINAL/
โ”‚
โ”œโ”€โ”€ frontend/                         # Next.js 14 Frontend (Port 3000)
โ”‚   โ”œโ”€โ”€ app/                          # App Router pages
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/                # Main dashboard with charts
โ”‚   โ”‚   โ”œโ”€โ”€ beneficiary/              # Beneficiary management
โ”‚   โ”‚   โ”œโ”€โ”€ funds/                    # FTO and fund tracking
โ”‚   โ”‚   โ”œโ”€โ”€ projects/                 # Project milestone tracking
โ”‚   โ”‚   โ”œโ”€โ”€ proposals/                # Proposal workflow
โ”‚   โ”‚   โ”œโ”€โ”€ reports/                  # Report generation
โ”‚   โ”‚   โ”œโ”€โ”€ sna/                      # State Nodal Agency view
โ”‚   โ”‚   โ”œโ”€โ”€ pacc/                     # PACC approval interface
โ”‚   โ”‚   โ”œโ”€โ”€ login/                    # Authentication
โ”‚   โ”‚   โ””โ”€โ”€ signup/                   # User registration
โ”‚   โ”œโ”€โ”€ components/                   # 36 reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ chatbot.tsx               # AI assistant (28KB)
โ”‚   โ”‚   โ”œโ”€โ”€ sidebar.tsx               # Navigation (23KB)
โ”‚   โ”‚   โ”œโ”€โ”€ india-map-heatmap.tsx     # State visualization
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ lib/                          # Utilities and helpers
โ”‚   โ””โ”€โ”€ public/                       # Static assets
โ”‚
โ”œโ”€โ”€ backend/                          # Main Backend (Port 1604)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/              # 7 request handlers
โ”‚   โ”‚   โ”œโ”€โ”€ models/                   # 10 MongoDB schemas
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ beneficiary.model.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ proposal.model.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ project.model.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ngo.model.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ routes/                   # 6 API route files
โ”‚   โ”‚   โ””โ”€โ”€ middlewares/              # Auth & validation
โ”‚   โ”œโ”€โ”€ main.py                       # FastAPI Translation Server (Port 8000)
โ”‚   โ””โ”€โ”€ requirements.txt              # Python dependencies
โ”‚
โ”œโ”€โ”€ app-backend/                      # Secondary MERN Backend
โ”‚   โ””โ”€โ”€ src/                          # Controllers, models, routes
โ”‚
โ”œโ”€โ”€ blockchain/                       # Hyperledger Fabric (Port 3002)
โ”‚   โ”œโ”€โ”€ backend/                      # Node.js blockchain gateway
โ”‚   โ”œโ”€โ”€ backend-spring/               # Spring Boot API (Java 17)
โ”‚   โ”œโ”€โ”€ blockchain/                   # Chaincode & network config
โ”‚   โ”‚   โ”œโ”€โ”€ organizations/            # Org certificates
โ”‚   โ”‚   โ””โ”€โ”€ docker/                   # Docker compose files
โ”‚   โ”œโ”€โ”€ API_REFERENCE.md              # Complete API docs (20 endpoints)
โ”‚   โ””โ”€โ”€ commands.sh                   # Setup scripts
โ”‚
โ”œโ”€โ”€ AI_Model/                         # Machine Learning Models
โ”‚   โ”œโ”€โ”€ Individual Beneficiary Ranking Model/
โ”‚   โ”‚   โ”œโ”€โ”€ 1_synthesize_data.py      # Generate training data
โ”‚   โ”‚   โ”œโ”€โ”€ 2_train_model.py          # Train XGBoost model
โ”‚   โ”‚   โ”œโ”€โ”€ 3_test_model.py           # Model testing
โ”‚   โ”‚   โ”œโ”€โ”€ 6_app.py                  # Flask API (Port 5000)
โ”‚   โ”‚   โ”œโ”€โ”€ synthetic_beneficiaries.csv   # 1.7MB training data
โ”‚   โ”‚   โ””โ”€โ”€ trained_model.json        # Trained XGBoost model
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ Question Clustering/
โ”‚   โ”‚   โ”œโ”€โ”€ app.py                    # Clustering API
โ”‚   โ”‚   โ”œโ”€โ”€ clusters.py               # K-means implementation
โ”‚   โ”‚   โ””โ”€โ”€ pm_ajay_final_simulated_data.csv
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ State Plan Analysis RAG/
โ”‚       โ”œโ”€โ”€ main.py                   # RAG entry point
โ”‚       โ”œโ”€โ”€ rag_system.py             # LangChain RAG implementation
โ”‚       โ”œโ”€โ”€ analysis agent.py         # Document analysis
โ”‚       โ””โ”€โ”€ tools.py                  # Utility functions
โ”‚
โ”œโ”€โ”€ WHATSAPP/                         # WhatsApp Khata Bot (Port 3000)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/              # Message handlers
โ”‚   โ”‚   โ”œโ”€โ”€ models/                   # User & Khata schemas
โ”‚   โ”‚   โ””โ”€โ”€ services/                 # Business logic
โ”‚   โ”œโ”€โ”€ config/                       # Twilio configuration
โ”‚   โ”œโ”€โ”€ eng.traineddata               # English OCR (5.2MB)
โ”‚   โ””โ”€โ”€ hin.traineddata               # Hindi OCR (1.6MB)
โ”‚
โ”œโ”€โ”€ pmajay-chatbot/                   # Additional Chatbot Service
โ”‚   โ””โ”€โ”€ chatbot_backend/
โ”‚       โ””โ”€โ”€ chroma_db/                # Vector database for RAG
โ”‚
โ”œโ”€โ”€ .gitignore                        # Excludes venv, node_modules, large files
โ””โ”€โ”€ README.md                         # This file

๐Ÿ“Š Data Files

AI Model Training Data

File Location Size Description
synthetic_beneficiaries.csv AI_Model/Individual Beneficiary Ranking Model/ 1.7 MB 10,000+ synthetic beneficiary records for training
location dataset.csv AI_Model/Individual Beneficiary Ranking Model/ 4 KB State/district location mappings
trained_model.json AI_Model/Individual Beneficiary Ranking Model/ 620 KB Trained XGBoost model weights
preprocessor.joblib AI_Model/Individual Beneficiary Ranking Model/ 4 KB Sklearn preprocessing pipeline
pm_ajay_final_simulated_data.csv AI_Model/Question Clustering/ 100 KB Simulated grievance/issue data
processed_issues_uuid.csv AI_Model/Question Clustering/ 45 KB Processed issues with UUIDs
input.json AI_Model/State Plan Analysis RAG/ 3.6 KB Sample state plan input
input2.json AI_Model/State Plan Analysis RAG/ 5 KB Additional plan data

OCR Training Data (WhatsApp Bot)

File Size Description
eng.traineddata 5.2 MB Tesseract English OCR model
hin.traineddata 1.6 MB Tesseract Hindi OCR model

๐Ÿš€ Getting Started

Prerequisites

Tool Version Purpose
Node.js v18+ Backend & Frontend
Python 3.9+ AI Models & Translation API
MongoDB 6.0+ Database
Docker 24.0+ Blockchain network
Java 17+ Spring Boot blockchain API
pnpm or npm Latest Package management

Quick Install Check

node --version    # Should be v18+
python --version  # Should be 3.9+
mongod --version  # Should be 6.0+
docker --version  # Should be 24.0+
java --version    # Should be 17+

๐Ÿ“ Step-by-Step Run Instructions

Method 1: Run Core Services Only (Recommended for Quick Start)

Open 4 terminal windows and run each command in sequence:

Terminal 1: Start MongoDB

# Windows
mongod

# macOS/Linux
sudo mongod --dbpath /data/db

Terminal 2: Start Main Backend (Port 1604)

cd backend
npm install
npm run dev

โœ… Expected output: Server is running on http://localhost:1604

Terminal 3: Start Translation API (Port 8000)

cd backend
pip install -r requirements.txt
python main.py

โœ… Expected output: Uvicorn running on http://0.0.0.0:8000

Terminal 4: Start Frontend (Port 3000)

cd frontend
npm install    # or pnpm install
npm run dev    # or pnpm dev

โœ… Expected output: Ready on http://localhost:3000

Access the Application

Open your browser and go to: http://localhost:3000


Method 2: Run All Services (Full Platform)

Step 1: Start MongoDB

mongod

Step 2: Start Main Backend

cd backend
npm install
npm run dev
# Runs on http://localhost:1604

Step 3: Start Translation API

cd backend
pip install -r requirements.txt
python main.py
# Runs on http://localhost:8000

Step 4: Start Frontend

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

Step 5: Start Blockchain Backend (Choose One)

Option A: Spring Boot (Recommended)

cd blockchain/backend-spring
./mvnw spring-boot:run    # Linux/macOS
mvnw.cmd spring-boot:run  # Windows
# Runs on http://localhost:3002

Option B: Node.js

cd blockchain/backend
npm install
npm start
# Runs on http://localhost:3002

Step 6: Start WhatsApp Bot (Optional)

cd WHATSAPP
npm install
npm run dev
# Runs on http://localhost:3000 (use different port if frontend is running)

โš ๏ธ Note: For WhatsApp bot to work, you need ngrok and Twilio credentials configured.

Step 7: Run AI Models (Optional)

Beneficiary Ranking API (Port 5000):

cd "AI_Model/Individual Beneficiary Ranking Model"
pip install flask pandas xgboost scikit-learn joblib
python 6_app.py

Question Clustering:

cd "AI_Model/Question Clustering"
pip install flask pandas scikit-learn
python app.py

State Plan RAG:

cd "AI_Model/State Plan Analysis RAG"
pip install langchain chromadb openai
python main.py

Method 3: Using Docker (Coming Soon)

# docker-compose.yml will be added for one-command startup
docker-compose up -d

๐Ÿ” Environment Variables

Create .env files in each directory:

frontend/.env

NEXT_PUBLIC_API_URL=http://localhost:1604
NEXT_PUBLIC_TRANSLATION_API=http://localhost:8000
NEXT_PUBLIC_BLOCKCHAIN_API=http://localhost:3002

backend/.env

PORT=1604
MONGODB_URI=mongodb://localhost:27017/pmajay
CORS_ORIGIN=http://localhost:3000
JWT_SECRET=your_super_secret_jwt_key_here

WHATSAPP/.env

TWILIO_ACCOUNT_SID=your_twilio_sid
TWILIO_AUTH_TOKEN=your_twilio_token
TWILIO_WHATSAPP_NUMBER=whatsapp:+14155238886
MONGODB_URI=mongodb://localhost:27017/whatsapp_khata
PORT=3001

blockchain/backend-spring/application.properties

server.port=3002

๐Ÿ“š API Documentation

Quick API Reference

Service Port Base URL Health Check
Frontend 3000 http://localhost:3000 Browser
Main Backend 1604 http://localhost:1604/api /api/health
Translation API 8000 http://localhost:8000 /health
Blockchain API 3002 http://localhost:3002 /health

Main Backend Endpoints

POST   /api/users/register     - Register new user
POST   /api/users/login        - User authentication
GET    /api/proposals          - Get all proposals
POST   /api/proposals          - Create new proposal
GET    /api/projects           - Get all projects
POST   /api/projects           - Create new project
GET    /api/central            - Get central dashboard data
POST   /api/uc/upload          - Upload utilization certificate
GET    /api/health             - Health check

Translation API Endpoints

POST   /translate              - Translate text between languages
GET    /languages              - Get supported languages list
GET    /health                 - Health check

Blockchain API Endpoints

See blockchain/API_REFERENCE.md for complete documentation of 20 endpoints.


๐Ÿงช Quick Verification

After starting all services, run these commands to verify:

# Check main backend
curl http://localhost:1604/api/health
# Expected: {"status":"ok","message":"Backend is running","port":"1604"}

# Check translation API
curl http://localhost:8000/health
# Expected: {"status":"healthy","provider":"Google Translate"}

# Check blockchain API
curl http://localhost:3002/health
# Expected: {"status":"UP"}

# Test translation
curl -X POST http://localhost:8000/translate \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello, how are you?","source_lang":"en","target_lang":"hi"}'

๐Ÿ› Troubleshooting

Common Issues

Issue Solution
EADDRINUSE: address already in use Kill process on that port: npx kill-port 3000
MongoDB connection failed Ensure MongoDB is running: mongod
Module not found Run npm install or pip install -r requirements.txt
CORS error Check CORS_ORIGIN in backend .env matches frontend URL
Port 3000 conflict (WhatsApp vs Frontend) Change WhatsApp port to 3001 in its .env

Windows-Specific

# Kill process on port
netstat -ano | findstr :3000
taskkill /PID <PID> /F

# Run Python scripts
python main.py  # Not python3

macOS/Linux-Specific

# Kill process on port
lsof -ti:3000 | xargs kill -9

# Run Python scripts
python3 main.py

๐Ÿ‘ฅ Access Roles

Role Permissions
Ministry Full access, fund release approval, audit oversight
PACC Proposal approval, blueprint review
State State-level project implementation, UC submission
SNA Fund tracking, bank account management
IA (Implementing Agency) Evidence upload, milestone updates
SAU (State Audit Unit) Audit reports, corrective actions
Beneficiary View benefits, raise issues via WhatsApp

๐Ÿ“„ License

ISC License


๐Ÿ™ Acknowledgments

Built for Smart India Hackathon 2025 to digitize and streamline the PM-AJAY scheme for efficient welfare fund distribution to Scheduled Caste beneficiaries.

Problem Statement ID: SIH PS 25152


๐Ÿ”— Links


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

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors