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.
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.
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
- Docker 20.10+
- Docker Compose 2.0+
- 4GB RAM minimum
- Government of India API key from data.gov.in
- Clone the repository:
git clone https://github.com/cyberkunju/NREGA.git
cd NREGA- Create environment configuration:
cp .env.example .env- Edit
.envwith 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- Start the application:
docker-compose up -d- Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001/api
- Database: localhost:5432
Backend Development:
cd backend
npm install
npm run devFrontend Development:
cd frontend
npm install
npm startETL Service:
cd etl
npm install
npm startUse the production Docker Compose configuration:
docker-compose -f docker-compose.prod.yml up -dProduction configuration includes:
- Multi-stage Docker builds
- Nginx serving optimized React build
- No volume mounts (code baked into images)
- Production environment variables
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
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.
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.
- 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
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.
Backend:
cd backend
npm testFrontend:
cd frontend
npm testBackup:
docker exec mgnrega-db pg_dump -U postgres mgnrega > backup.sqlRestore:
docker exec -i mgnrega-db psql -U postgres mgnrega < backup.sqlAccess PostgreSQL shell:
docker exec -it mgnrega-db psql -U postgres -d mgnregaCheck service health:
curl http://localhost:3001/api/healthView logs:
docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f etlBackend:
DB_NAME- PostgreSQL database nameDB_USER- Database userDB_PASSWORD- Database passwordCORS_ORIGIN- Allowed CORS origins
Frontend:
REACT_APP_API_URL- Backend API endpoint
ETL:
GOV_API_ENDPOINT- Government API URLGOV_API_KEY- API authentication keySTATE_FILTER- Optional state filtering
- 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
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+