Skip to content

Dhanika-Bhat/SmartCity

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›๏ธ UrbanPulse โ€” Smart City Infrastructure Portal

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


๐ŸŒŸ Features

๐Ÿ’ง Water Drainage Monitoring

  • 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

๐Ÿ—‘๏ธ Garbage Detection & Citizen Reporting

  • 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

๐Ÿ“Š Overview Dashboard

  • Summary stats for both Water Drainage and Garbage systems
  • Geographic sensor network map
  • Real-time hardware node status
  • Community awareness blog section

๐Ÿข Field Operations (Municipal Portal)

  • Node registry with status filtering
  • Dispatch crew actions for critical/warning nodes

๐Ÿ—๏ธ Tech Stack

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

๐Ÿ“‚ Project Structure

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

๐Ÿš€ Getting Started

Prerequisites

  • Node.js v18+
  • MongoDB (local or Atlas)
  • ESP32 with sensors (for real hardware data)

1. Clone the repository

git clone https://github.com/yashg2006/SmartCity.git
cd SmartCity

2. Setup Backend

cd backend
npm install

Create a .env file:

MONGO_URI=mongodb://localhost:27017/smartcity
PORT=5000
JWT_SECRET=your_secret_key

Start the server:

node server.js

3. Setup Frontend

cd frontend
npm install
npm run dev

The app will be available at http://localhost:5173


๐Ÿ“ก ESP32 / Arduino Integration

Your ESP32 should POST sensor data to the backend:

POST http://<SERVER_IP>:5000/api/sensors/data
Content-Type: application/json

Payload Format

{
  "nodeId": "NODE-001",
  "zone": "Sector 4A",
  "distance": 25,
  "drainDistance": 18,
  "waterStatus": "NORMAL",
  "lat": 12.9716,
  "lng": 77.5946,
  "batteryLevel": 95
}

Field Descriptions

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

Alert Thresholds

  • Bin Full: distance < 8cm
  • Water Dry (Blockage): waterStatus = "DRY"
  • Drain High Water: drainDistance < 5cm
  • Water Overflow: waterStatus = "OVERFLOW"

๐Ÿ”‘ API Endpoints

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

๐Ÿง  Sensor Logic

Water Drainage System

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)

Garbage Bin System

fillPercent = ((BIN_DEPTH - distance) / BIN_DEPTH) ร— 100

fillPercent > 85%  โ†’ CRITICAL  ๐Ÿ”ด (overflow risk alert)
fillPercent > 65%  โ†’ WARNING   ๐ŸŸก
fillPercent โ‰ค 65%  โ†’ HEALTHY   ๐ŸŸข

๐Ÿ‘ฅ Roles

Role Permissions
admin Full access, dispatch crews, manage incidents
municipal Field operations, dispatch crews
citizen View dashboard, submit garbage reports

๐Ÿ“„ License

This project is built for the Smart City Hackathon โ€” Digital India Initiative.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 84.8%
  • CSS 9.8%
  • Python 4.0%
  • Other 1.4%