Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mrigank005/WHCL-Hackathon

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‡ฎ๐Ÿ‡ณ BharatChain - User Manual & Setup Guide

BharatChain Logo

India's Blockchain-Powered Digital Governance Platform
Complete User Manual & Developer Guide

Frontend Backend AI Service One-Click Launch

๐Ÿš€ Quick Start โ€ข ๐Ÿ“ฑ User Guide โ€ข ๐Ÿ”ง Developer Setup โ€ข ๐Ÿ› ๏ธ Troubleshooting


๏ฟฝ What is BharatChain?

BharatChain is India's first comprehensive blockchain-powered digital governance platform that revolutionizes how citizens interact with government services. Built with cutting-edge technology, it provides:

  • ๐Ÿ” Secure Document Management - Upload, verify, and store official documents on blockchain
  • ๐Ÿ“ Smart Grievance System - AI-powered complaint processing with real-time tracking
  • ๐Ÿ‘ค Digital Identity - Blockchain-based citizen registration and authentication
  • ๐Ÿค– AI-Powered Analysis - Intelligent document verification and grievance categorization
  • ๐ŸŒ Modern Web Interface - Beautiful, responsive Indian-themed user interface

๐ŸŽฏ Why BharatChain?

Transform government services with transparency, security, and efficiency through blockchain technology.


๐Ÿš€ Quick Start - One Click Launch

๐Ÿ“‹ Prerequisites

Before starting, ensure you have:

โšก Instant Launch (Easiest Method)

Option 1: Simple Double-Click Launch

# Navigate to your BharatChain folder and double-click:
start.bat

Option 2: Enhanced Launcher

# Double-click for smart launcher with fallback:
bharatchain.bat

Option 3: PowerShell Advanced

# Right-click folder โ†’ "Open PowerShell here" โ†’ Run:
.\bharatchain.ps1

๐ŸŽฌ What Happens When You Launch

========================================
๐Ÿ‡ฎ๐Ÿ‡ณ BharatChain Launcher ๐Ÿ‡ฎ๐Ÿ‡ณ
Starting all services...
========================================

โœ… Stopping existing services...
๐Ÿค– Starting AI Service (Port 5001)...
โš™๏ธ Starting Backend (Port 3001)...
๐ŸŽจ Starting Frontend (Port 3000)...

========================================
๐Ÿš€ All services are starting up!

Services run in separate windows.
Please wait 15-20 seconds for startup...

๐ŸŒ Your BharatChain will open at:
   http://localhost:3000

๐Ÿ“ก Backend API available at:
   http://localhost:3001

๐Ÿง  AI Service available at:
   http://localhost:5001
========================================

๐Ÿ”ฅ Opening browser automatically...

โœ… Verify Everything Works

After launch, you should see:

  • 3 terminal windows opened (AI Service, Backend, Frontend)
  • Browser opens automatically to http://localhost:3000
  • Beautiful Indian-themed interface loads
  • "Connect MetaMask" button appears on the homepage

๐Ÿ›‘ To Stop All Services

# Method 1: Close terminal windows manually
# Method 2: Use stop command
bharatchain.bat stop

# Method 3: Kill all Node.js processes
taskkill /f /im node.exe
taskkill /f /im python.exe

๏ฟฝ User Guide

๐Ÿ” Step 1: Connect Your Wallet

  1. Install MetaMask browser extension if not already installed
  2. Create/Import wallet and set up your account
  3. Visit http://localhost:3000
  4. Click "Connect MetaMask" on the homepage
  5. Approve connection in MetaMask popup
  6. Sign message to authenticate (no gas fees!)

๐Ÿ‘ค Step 2: Citizen Registration

  1. After wallet connection, you'll see the registration form
  2. Fill required details:
    • Full Name
    • Aadhar Number (12 digits)
    • Phone Number
    • Email Address
    • Date of Birth
  3. Submit registration - your identity gets stored on blockchain
  4. Success! You're now a registered BharatChain citizen

๐Ÿ“„ Step 3: Document Management

Upload Documents:

  1. Navigate to "Documents" in the dashboard
  2. Click "Upload Document"
  3. Select file (PDF, JPG, PNG - max 10MB)
  4. Choose document type (Aadhar, PAN, etc.)
  5. Wait for AI processing - automatic text extraction & verification
  6. Document stored on blockchain with IPFS hash

View Documents:

  • Dashboard overview shows all your documents
  • Click any document to view details
  • Verification status shown (Pending/Verified/Rejected)
  • Download original or processed version

๐Ÿ“ Step 4: Submit Grievances

File a Complaint:

  1. Go to "Grievances" section
  2. Click "Submit New Grievance"
  3. Fill the form:
    • Subject: Brief description
    • Description: Detailed explanation
    • Category: Select appropriate category
    • Urgency: Select priority level
  4. Submit - AI automatically analyzes and categorizes
  5. Track status - real-time updates on progress

AI Analysis Features:

  • Sentiment Analysis: Detects urgency and emotion
  • Smart Categorization: Auto-assigns to correct department
  • Priority Scoring: Urgent issues get higher priority
  • Response Time: Estimated resolution timeline

๐Ÿ“Š Step 5: Dashboard Overview

Your dashboard shows:

  • Document Summary: Total uploaded, verified, pending
  • Grievance Status: Active, resolved, in-progress
  • Recent Activity: Latest actions and updates
  • Quick Actions: Fast access to common tasks
  • Notifications: Important updates and alerts

๏ฟฝ Developer Setup

๐Ÿ› ๏ธ Manual Development Setup

If you want to run services individually for development:

Install Dependencies:

# Clone repository
git clone https://github.com/your-username/WHCL-Hackathon.git
cd WHCL-Hackathon

# Install backend dependencies
cd server && npm install

# Install frontend dependencies  
cd ../client && npm install

# Install AI service dependencies
cd ../ai-service && pip install -r requirements.txt

Start Services Manually:

# Terminal 1: AI Service
cd ai-service
python simple_app.py

# Terminal 2: Backend
cd server
npm start

# Terminal 3: Frontend
cd client
npm start

๐Ÿ”— System Architecture

Component Technology Port Purpose
Frontend React 18 + Material-UI 3000 User interface & dashboard
Backend Node.js + Express 3001 RESTful APIs & business logic
AI Service Python + Flask 5001 Document analysis & ML processing
Database SQLite - Data persistence & caching
Blockchain Local/Mumbai 8545 Smart contracts & immutable records

๐Ÿ—ƒ๏ธ Project Structure

WHCL-Hackathon/
โ”œโ”€โ”€ ๐ŸŽจ client/                 # React frontend
โ”‚   โ”œโ”€โ”€ src/components/        # UI components
โ”‚   โ”œโ”€โ”€ src/context/          # Web3 & app context
โ”‚   โ””โ”€โ”€ public/               # Static assets
โ”œโ”€โ”€ โš™๏ธ server/                 # Node.js backend  
โ”‚   โ”œโ”€โ”€ routes/               # API endpoints
โ”‚   โ”œโ”€โ”€ database/             # DB models & config
โ”‚   โ””โ”€โ”€ server.js             # Main server file
โ”œโ”€โ”€ ๐Ÿค– ai-service/             # Python AI service
โ”‚   โ”œโ”€โ”€ simple_app.py         # Flask app
โ”‚   โ””โ”€โ”€ requirements.txt      # Python dependencies
โ”œโ”€โ”€ ๐Ÿ”— contracts/             # Smart contracts
โ”‚   โ”œโ”€โ”€ CitizenRegistry.sol   # Citizen management
โ”‚   โ”œโ”€โ”€ DocumentRegistry.sol  # Document storage
โ”‚   โ””โ”€โ”€ GrievanceSystem.sol   # Grievance handling
โ”œโ”€โ”€ ๐Ÿš€ Launchers/             # One-click launch files
โ”‚   โ”œโ”€โ”€ start.bat             # Simple launcher
โ”‚   โ”œโ”€โ”€ bharatchain.bat       # Enhanced launcher
โ”‚   โ””โ”€โ”€ bharatchain.ps1       # PowerShell launcher
โ””โ”€โ”€ ๐Ÿ“š docs/                  # Documentation

๐Ÿ“ก API Reference

๐Ÿ” Authentication Endpoints

Method Endpoint Description Example
POST /api/auth/message Get wallet signing message curl -X POST http://localhost:3001/api/auth/message
POST /api/auth/connect Authenticate with signature curl -X POST http://localhost:3001/api/auth/connect -d '{"address":"0x...", "signature":"0x..."}'
POST /api/auth/verify Verify JWT token curl -X POST http://localhost:3001/api/auth/verify -H "Authorization: Bearer TOKEN"

๐Ÿ‘ค Citizen Management

Method Endpoint Description Parameters
GET /api/citizens/profile Get citizen profile Requires JWT token
POST /api/citizens/register Register new citizen fullName, aadharNumber, phoneNumber, email, dateOfBirth
PUT /api/citizens/update Update citizen information Profile fields to update

๐Ÿ“„ Document Management

Method Endpoint Description Parameters
GET /api/documents List citizen documents Optional: type, status filters
POST /api/documents/upload Upload & analyze document file (multipart), type, description
GET /api/documents/:id Get document details Document ID
PUT /api/documents/:id/verify Verify document (officials) status, comments

๐Ÿ“ Grievance System

Method Endpoint Description Parameters
GET /api/grievances List grievances Optional: status, category filters
POST /api/grievances Submit new grievance subject, description, category, urgency
PUT /api/grievances/:id Update grievance status status, comments
POST /api/grievances/:id/comments Add comment comment, isOfficial

๐Ÿง  AI Service Endpoints

Method Endpoint Description Parameters
GET /health AI service health check None
POST /analyze/grievance Analyze grievance text {"text": "grievance description"}
POST /analyze/document Process document OCR file (multipart form)
POST /analyze/sentiment Sentiment analysis {"text": "text to analyze"}

๐Ÿ“Š System Health

Method Endpoint Description Response
GET /api/health Overall system health {"status": "running", "timestamp": "..."}
GET /api/health/database Database connectivity {"database": "connected"}
GET /api/health/blockchain Blockchain connectivity {"blockchain": "connected"}

๐Ÿ› ๏ธ Troubleshooting

๐Ÿšจ Common Issues & Solutions

1. Services Won't Start

Problem: "Port already in use" or services fail to start

Solutions:

# Kill existing processes
taskkill /f /im node.exe
taskkill /f /im python.exe

# Then restart
.\start.bat

Problem: "Module not found" errors

Solutions:

# Reinstall dependencies
cd server && npm install
cd ../client && npm install
cd ../ai-service && pip install -r requirements.txt

2. MetaMask Connection Issues

Problem: MetaMask doesn't connect or shows errors

Solutions:

  • Check MetaMask is unlocked and account is selected
  • Refresh the page (Ctrl+F5) and try again
  • Switch to correct network (use local network for development)
  • Clear browser cache and restart browser

3. AI Service Not Working

Problem: AI analysis fails or returns errors

Solutions:

# Check if Python dependencies are installed
cd ai-service
pip install -r requirements.txt

# Check if service is running
curl http://localhost:5001/health

# Restart AI service
python simple_app.py

4. Frontend Not Loading

Problem: React app shows blank page or errors

Solutions:

# Clear React cache and restart
cd client
npm start -- --reset-cache

# Or delete node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
npm start

5. Database Issues

Problem: "Database locked" or connection errors

Solutions:

# Stop all services first
taskkill /f /im node.exe

# Delete database lock file
del server\database\*.db-wal
del server\database\*.db-shm

# Restart backend
cd server && npm start

๐Ÿ” Debugging Tips

Check Service Status

# Quick status check
bharatchain.bat status

# Manual health checks
curl http://localhost:3000    # Frontend
curl http://localhost:3001/api/health    # Backend  
curl http://localhost:5001/health        # AI Service

View Service Logs

  • Frontend: Check browser console (F12 โ†’ Console)
  • Backend: Look at terminal running npm start in server folder
  • AI Service: Check terminal running python simple_app.py

Common Error Messages

Error Meaning Solution
EADDRINUSE Port already in use Kill existing processes with taskkill
MODULE_NOT_FOUND Missing dependencies Run npm install or pip install -r requirements.txt
MetaMask not detected MetaMask not installed Install MetaMask browser extension
Connection refused Service not running Start the specific service
CORS error Cross-origin request blocked Check backend CORS configuration

๐Ÿ“ž Getting Help

If you're still having issues:

  1. Check all services are running: Use bharatchain.bat status
  2. Review terminal outputs: Look for error messages in service windows
  3. Try clean restart: Stop all services, wait 5 seconds, restart
  4. Check prerequisites: Ensure Node.js, Python, and MetaMask are installed
  5. Create GitHub issue: If problem persists, report it with error details

๐ŸŽฏ Performance Tips

  • First startup takes 20-30 seconds - be patient!
  • Keep terminal windows open - closing them stops services
  • Use Chrome/Edge browsers - better MetaMask compatibility
  • Clear browser cache periodically - prevents stale data issues
  • Restart services daily - keeps everything fresh during development

๐Ÿš€ Advanced Usage

๐Ÿ”ง Environment Configuration

Create .env file in server folder:

# Database
DATABASE_URL=sqlite:./database/bharatchain.db
NODE_ENV=development

# Security
JWT_SECRET=your-super-secret-jwt-key-here
SESSION_SECRET=your-session-secret-here

# Services
FRONTEND_URL=http://localhost:3000
AI_SERVICE_URL=http://localhost:5001

# Blockchain (for production)
MUMBAI_RPC_URL=https://rpc-mumbai.maticvigil.com
PRIVATE_KEY=your-wallet-private-key-for-deployment

๐ŸŒ Production Deployment

Frontend (Vercel/Netlify)

cd client
npm run build
# Deploy dist/ folder to your hosting service

Backend (Railway/Render/Heroku)

cd server
# Configure environment variables on hosting platform
# Deploy server folder

AI Service (PythonAnywhere/Railway)

cd ai-service
# Install requirements: pip install -r requirements.txt
# Start with: python simple_app.py

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

๐Ÿ”จ Development Setup

  1. Fork the repository on GitHub
  2. Clone your fork: git clone https://github.com/your-username/WHCL-Hackathon.git
  3. Create feature branch: git checkout -b feature/amazing-feature
  4. Make changes and test thoroughly
  5. Commit changes: git commit -m 'Add amazing feature'
  6. Push to branch: git push origin feature/amazing-feature
  7. Open Pull Request

๐Ÿ“ Contribution Guidelines

  • Write tests for new features
  • Follow existing code style
  • Update documentation for API changes
  • Test on Windows (our primary platform)
  • Include screenshots for UI changes

๐Ÿงช Testing Your Changes

# Run all tests
npm test                    # Backend tests
cd client && npm test       # Frontend tests  
cd ai-service && python -m pytest  # AI service tests

# Manual testing
.\start.bat                 # Test launcher
bharatchain.bat status      # Test status check

๐Ÿ“„ License & Acknowledgments

๐Ÿ“œ License

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

๐Ÿ™ Acknowledgments

  • Government of India - Digital India Initiative inspiration
  • Ethereum Foundation - Blockchain infrastructure
  • OpenZeppelin - Smart contract security standards
  • Material-UI Team - Beautiful React component library
  • MetaMask Team - Web3 wallet integration
  • Flask & React Communities - Excellent documentation and support

๐ŸŒŸ Built With Love For

  • Digital India ๐Ÿ‡ฎ๐Ÿ‡ณ
  • Transparent Governance ๐Ÿ›๏ธ
  • Citizen Empowerment ๐Ÿ‘ฅ
  • Blockchain Innovation โ›“๏ธ

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

One-Click Launch Documentation Support

Ready to revolutionize digital governance? Just double-click start.bat and let's go! ๐Ÿš€

Transform India's digital future, one blockchain transaction at a time. โœจ


๐Ÿ“ž Support & Contact

Happy coding! ๐ŸŽ‰ Let's build the future of digital governance together! ๐Ÿ‡ฎ๐Ÿ‡ณ

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 75.8%
  • JavaScript 22.1%
  • Solidity 0.6%
  • CSS 0.6%
  • HTML 0.3%
  • Shell 0.2%
  • Other 0.4%