Skip to content

Web-based visualization system for India's MGNREGA employment program. Features interactive district maps, real-time performance metrics, 15-language support, and automated data pipeline from data.gov.in.

Notifications You must be signed in to change notification settings

cyberkunju/NREGA

Repository files navigation

MGNREGA Report

https://mgnrega.cyberkunju.dev

Web application for visualizing performance data of India's Mahatma Gandhi National Rural Employment Guarantee Act (MGNREGA) program across 740+ districts.

Overview

This system provides an interactive map-based interface to explore MGNREGA employment statistics, payment efficiency, and work completion rates at the district level. Data is automatically fetched from the Government of India's Open Data API and updated every 12 hours.

Technology Stack

Frontend

  • React 18.2 with React Router v6
  • MapLibre GL for interactive maps
  • Turf.js for geospatial calculations
  • i18next for multi-language support (15 languages)
  • Framer Motion for animations

Backend

  • Node.js with Express 4.18
  • PostgreSQL 14 for data storage
  • node-postgres for database connectivity
  • Express rate limiting (100 req/15min per IP)

ETL Pipeline

  • node-cron for scheduled data fetching
  • Automated data transformation and validation
  • Runs every 12 hours

Infrastructure

  • Docker and Docker Compose for containerization
  • Nginx for production frontend serving
  • Multi-stage Docker builds for optimization

Prerequisites

  • Docker 20.10+
  • Docker Compose 2.0+
  • 4GB RAM minimum
  • Government of India API key from data.gov.in

Quick Start

  1. Clone the repository:
git clone https://github.com/cyberkunju/NREGA.git
cd NREGA
  1. Create environment configuration:
cp .env.example .env
  1. Edit .env with your configuration:
DB_NAME=mgnrega
DB_USER=postgres
DB_PASSWORD=your_secure_password
CORS_ORIGIN=*
REACT_APP_API_URL=http://localhost:3001/api
GOV_API_ENDPOINT=https://api.data.gov.in/resource/ee03643a-ee4c-48c2-ac30-9f2ff26ab722
GOV_API_KEY=your_api_key_here
  1. Start the application:
docker-compose up -d
  1. Access the application:

Development

Backend Development:

cd backend
npm install
npm run dev

Frontend Development:

cd frontend
npm install
npm start

ETL Service:

cd etl
npm install
npm start

Production Deployment

Use the production Docker Compose configuration:

docker-compose -f docker-compose.prod.yml up -d

Production configuration includes:

  • Multi-stage Docker builds
  • Nginx serving optimized React build
  • No volume mounts (code baked into images)
  • Production environment variables

Project Structure

NREGA/
├── backend/              # Express REST API
│   ├── db/              # Database connection and schema
│   ├── routes/          # API route handlers
│   └── server.js        # Main application entry
├── frontend/            # React application
│   ├── public/          # Static assets and GeoJSON
│   └── src/
│       ├── components/  # React components
│       ├── pages/       # Route-level pages
│       ├── services/    # API client
│       └── locales/     # Translation files
├── etl/                 # Data pipeline
│   ├── data-fetcher.js
│   ├── data-transformer.js
│   └── data-loader.js
├── docs/                # Documentation
├── docker-compose.yml   # Development configuration
└── docker-compose.prod.yml  # Production configuration

API Endpoints

Health Check

GET /api/health

Districts List

GET /api/districts
GET /api/districts?state=Maharashtra

Performance Data

GET /api/performance/heatmap-data
GET /api/performance/heatmap-data?period=2024-10
GET /api/performance/all
GET /api/performance/:district_name
GET /api/performance/:district_name/periods

Full API documentation available in docs/API.md.

Database Schema

districts table:

  • Stores unique district identifiers
  • Indexed on district name

monthly_performance table:

  • Stores monthly performance metrics
  • Unique constraint on (district_name, month, fin_year)
  • Indexed on district_name, period, and last_updated

Full schema documentation available in docs/DATABASE.md.

Features

  • Interactive choropleth map visualization
  • District-level performance metrics
  • Historical data comparison
  • Multi-language support (Hindi, Tamil, Telugu, Marathi, Bengali, Gujarati, Kannada, Malayalam, Odia, Punjabi, Assamese, Urdu, English, and more)
  • Progressive Web App with offline support
  • Responsive design for mobile and desktop
  • Automated data updates

Data Source

All data is sourced from the Government of India's Open Data Platform (data.gov.in). The ETL pipeline fetches, validates, and stores data automatically.

Testing

Backend:

cd backend
npm test

Frontend:

cd frontend
npm test

Database Operations

Backup:

docker exec mgnrega-db pg_dump -U postgres mgnrega > backup.sql

Restore:

docker exec -i mgnrega-db psql -U postgres mgnrega < backup.sql

Access PostgreSQL shell:

docker exec -it mgnrega-db psql -U postgres -d mgnrega

Monitoring

Check service health:

curl http://localhost:3001/api/health

View logs:

docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f etl

Environment Variables

Backend:

  • DB_NAME - PostgreSQL database name
  • DB_USER - Database user
  • DB_PASSWORD - Database password
  • CORS_ORIGIN - Allowed CORS origins

Frontend:

  • REACT_APP_API_URL - Backend API endpoint

ETL:

  • GOV_API_ENDPOINT - Government API URL
  • GOV_API_KEY - API authentication key
  • STATE_FILTER - Optional state filtering

Performance

  • Backend response time: <100ms (cached)
  • Frontend initial load: <2s (production build)
  • Map rendering: <1s for 740 districts
  • Database queries: Optimized with indexes
  • Rate limiting: 100 requests per 15 minutes per IP

Browser Support

  • Chrome 90+
  • Firefox 88+
  • Safari 14+
  • Edge 90+

About

Web-based visualization system for India's MGNREGA employment program. Features interactive district maps, real-time performance metrics, 15-language support, and automated data pipeline from data.gov.in.

Topics

Resources

Stars

Watchers

Forks