A real-time IoT-powered Smart City monitoring platform for Water Drainage Management and Garbage Detection & Reporting, built with React + Express + MongoDB.
๐ฎ๐ณ Digital India Initiative โ Department of Urban Planning
- Water Sensor (inside pipeline) โ detects if water is actively flowing through the pipe
- Ultrasonic Sensor (top of pipe, facing down) โ measures distance to water surface to calculate water level
- Combined Flow Diagnosis โ determines flow speed (fast/normal/slow/no flow) by combining both sensor readings
- Pipeline SVG Visualization โ live cross-section diagram showing water level, sensor positions, and flow direction
- Blockage Detection โ alerts when water sensor reads DRY (no flow = potential upstream blockage)
- Sector-based monitoring โ only Sector 4A has real hardware; other sectors are greyed out
- Ultrasonic Sensor on Bin Lid โ measures distance to garbage surface; short distance = bin filling up
- Overflow Alerts โ critical alert when bin fill exceeds 85%
- Citizen Image Reporting โ citizens can capture/upload photos of garbage and submit reports directly to the Municipal Corporation
- Report Tracking โ all citizen reports are stored with status (Pending โ Acknowledged โ Resolved)
- Bin SVG Visualization โ live cross-section of bin showing fill level and sensor position
- Summary stats for both Water Drainage and Garbage systems
- Geographic sensor network map
- Real-time hardware node status
- Community awareness blog section
- Node registry with status filtering
- Dispatch crew actions for critical/warning nodes
| Layer | Technology |
|---|---|
| Frontend | React 18 + Vite |
| Backend | Node.js + Express |
| Database | MongoDB + Mongoose |
| Real-time | Socket.IO |
| Hardware | ESP32 + HC-SR04 Ultrasonic + Water Level Sensor |
Smart_City project/
โโโ backend/
โ โโโ models/
โ โ โโโ SensorData.js # Sensor readings (distance, drainDistance, waterStatus)
โ โ โโโ GarbageReport.js # Citizen garbage reports with images
โ โ โโโ Incident.js # Alert incidents
โ โ โโโ User.js # User accounts
โ โโโ routes/
โ โ โโโ sensors.js # Sensor data intake, reports, incidents
โ โ โโโ auth.js # Authentication
โ โ โโโ users.js # User management
โ โโโ server.js # Express + Socket.IO server
โ โโโ package.json
โโโ frontend/
โ โโโ src/
โ โ โโโ components/
โ โ โ โโโ WaterDrainage.jsx # ๐ง Water drainage monitoring page
โ โ โ โโโ GarbageDetection.jsx # ๐๏ธ Garbage detection + citizen reporting
โ โ โ โโโ Dashboard.jsx # ๐ Overview dashboard
โ โ โ โโโ Sidebar.jsx # Navigation sidebar
โ โ โ โโโ MunicipalPortal.jsx # ๐ข Field operations
โ โ โ โโโ SensorMap.jsx # SVG sensor network map
โ โ โ โโโ Login.jsx # Authentication page
โ โ โ โโโ ...
โ โ โโโ App.jsx # Main app with routing
โ โ โโโ config.js # API URL config
โ โ โโโ index.css # Global styles
โ โโโ package.json
โโโ README.md
- Node.js v18+
- MongoDB (local or Atlas)
- ESP32 with sensors (for real hardware data)
git clone https://github.com/yashg2006/SmartCity.git
cd SmartCitycd backend
npm installCreate a .env file:
MONGO_URI=mongodb://localhost:27017/smartcity
PORT=5000
JWT_SECRET=your_secret_keyStart the server:
node server.jscd frontend
npm install
npm run devThe app will be available at http://localhost:5173
Your ESP32 should POST sensor data to the backend:
POST http://<SERVER_IP>:5000/api/sensors/data
Content-Type: application/json
{
"nodeId": "NODE-001",
"zone": "Sector 4A",
"distance": 25,
"drainDistance": 18,
"waterStatus": "NORMAL",
"lat": 12.9716,
"lng": 77.5946,
"batteryLevel": 95
}| Field | Type | Description |
|---|---|---|
distance |
Number (cm) | Ultrasonic on bin lid โ garbage surface. Low = bin full |
drainDistance |
Number (cm) | Ultrasonic in pipe โ water surface. Low = high water |
waterStatus |
String | NORMAL (flowing), DRY (no flow), OVERFLOW |
nodeId |
String | Unique sensor node ID |
zone |
String | Sector/zone name |
- Bin Full:
distance < 8cm - Water Dry (Blockage):
waterStatus = "DRY" - Drain High Water:
drainDistance < 5cm - Water Overflow:
waterStatus = "OVERFLOW"
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/sensors/data |
Receive sensor data from ESP32 |
GET |
/api/sensors/nodes |
Get latest reading per node |
GET |
/api/sensors/latest |
Get last 50 readings |
GET |
/api/sensors/incidents |
Get active incidents |
POST |
/api/sensors/report |
Submit citizen garbage report |
GET |
/api/sensors/reports |
Get all citizen reports |
POST |
/api/auth/register |
Register user |
POST |
/api/auth/login |
Login |
Water Sensor (WET) + Low drainDistance โ HIGH FLOW โก
Water Sensor (WET) + Mid drainDistance โ NORMAL FLOW โ
Water Sensor (WET) + High drainDistance โ LOW FLOW ๐ง
Water Sensor (DRY) โ NO FLOW ๐ซ (blockage alert)
fillPercent = ((BIN_DEPTH - distance) / BIN_DEPTH) ร 100
fillPercent > 85% โ CRITICAL ๐ด (overflow risk alert)
fillPercent > 65% โ WARNING ๐ก
fillPercent โค 65% โ HEALTHY ๐ข
| Role | Permissions |
|---|---|
admin |
Full access, dispatch crews, manage incidents |
municipal |
Field operations, dispatch crews |
citizen |
View dashboard, submit garbage reports |
This project is built for the Smart City Hackathon โ Digital India Initiative.