Skip to content

bikund2017/Park-Ride

Repository files navigation

Park & Ride+ Delhi NCR πŸš—πŸš‡πŸ”Œ

A comprehensive IoT-enabled real-time parking and transit information system for Delhi NCR, featuring Arduino sensor integration, interactive maps, community reporting, and intelligent parking search.

Live Demo

Node.js

React

Arduino

Vercel

🌟 Overview

Park & Ride+ is a full-stack IoT web application that combines real Arduino hardware sensors with cloud-based deployment to help Delhi NCR commuters find parking, track public transit, and share community reports. The platform bridges physical parking sensors with a modern web interface for real-time availability tracking.

🌐 Live Application: https://park-ride-new1.vercel.app/

🎯 What Makes This Project Unique?

Real Hardware Integration:

  • βœ… Arduino Mega 2560 with IR sensors detecting actual car entry/exit

  • βœ… USB Serial Communication forwarding sensor data to cloud

  • βœ… Node.js Serial Bridge running on local machine

  • βœ… Vercel Serverless Functions receiving Arduino data via HTTP POST

  • βœ… Firebase Firestore storing real-time parking availability

  • βœ… React Frontend displaying live Arduino data (updates every 10 seconds)

Key Features:

  • πŸ”Œ Real Arduino Sensors - Physical IR sensors tracking parking occupancy

  • πŸ—ΊοΈ Interactive Google Maps with real-time transit tracking

  • πŸ…ΏοΈ Hybrid Data Model - 1 real Arduino parking + 2 simulated locations

  • πŸ“ Community reporting system with image uploads

  • ⭐ User favorites and personalized parking recommendations

  • πŸ” Intelligent parking search with location-based filtering

  • πŸ” Secure Firebase authentication

  • πŸš‡ 10 Metro lines visualization

  • ⚑ Serverless Architecture - Works with Arduino locally and Vercel remotely

✨ Core Features

οΏ½ Arduino IoT Integration (NEW!)

Hardware Setup:

  • Microcontroller: Arduino Mega 2560

  • Sensors: 2x IR Obstacle Sensors (Entry & Exit detection)

  • Display: LCD 16x2 with I2C interface

  • Actuator: SG90 Servo Motor (automated gate control)

  • Communication: USB Serial (9600 baud)

System Architecture:


β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚ Arduino Mega β”‚ ← IR Sensors (Pins 2 & 3)

β”‚ (Hardware) β”‚ ← LCD Display (I2C)

β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ← Servo Motor (Pin 9)

β”‚ USB Serial (9600 baud)

↓

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚ Serial Bridge β”‚ ← Node.js (serialport)

β”‚ (Local PC) β”‚ ← Runs continuously

β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”‚ HTTP POST every 5s

↓

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚ Vercel Function β”‚ ← /api/arduino/parking

β”‚ (Cloud API) β”‚ ← Serverless

β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”‚ Store in Firestore

↓

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚ Firebase β”‚ ← Collection: arduino-parking

β”‚ (Database) β”‚ ← Real-time updates

β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”‚ GET /api/transit-data (10s polling)

↓

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

β”‚ React Frontend β”‚ ← Displays live data

β”‚ (Vercel) β”‚ ← Green card + parking list

β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Arduino Features:

  • βœ… Real-time car counting (entry/exit tracking)

  • βœ… Available slots calculation (Total - Occupied)

  • βœ… JSON output via Serial ({"parkingLotId":"SAB_Mall_Parking","totalSlots":3,"availableSlots":2})

  • βœ… LCD display showing availability

  • βœ… Automated gate control with servo

  • βœ… Entry/exit beep indicators

Current Arduino Parking Locations:

  1. SAB Mall Parking - 3 slots (Real Arduino data)
  • Location: Sector 27, Noida

  • GPS: [28.567582, 77.322673]

  • Hourly Rate: β‚Ή30/hr

  • Status: 🟒 Live (Real-time updates)

  1. Noida City Centre Parking (Optional second Arduino)
  • Location: Sector 32, Noida

  • GPS: [28.5744, 77.3564]

  • Status: Can be configured in bridge script

Serial Bridge Configuration:

// arduino-serial-bridge.js

const port = '/dev/ttyUSB0';

const baudRate = 9600;

const serverUrl = 'https://park-ride-new1.vercel.app';

const postInterval = 5000; // 5 seconds

οΏ½πŸ—ΊοΈ Interactive Mapping

  • Google Maps Integration - Primary mapping with @react-google-maps/api

  • Route Visualization - Polylines showing complete transit routes

  • Color-coded Markers - Green (available), Orange (limited), Red (full) for parking

  • Marker Clustering - Smart grouping of reports for better map clarity

  • Location Search - Google Places API integration for address lookup

πŸ…ΏοΈ Parking Management

Hybrid Data Model:

  • 1 Real Arduino Location (SAB Mall Parking - Live sensors)

  • 2 Simulated Locations (Connaught Place, India Gate - Demo data)

Arduino Parking Features:

  • βœ… Real-time occupancy from IR sensors

  • βœ… Automatic availability updates (every 5 seconds from hardware)

  • βœ… Visual indicators: Green (available), Orange (limited), Red (full)

  • βœ… Live percentage calculation

  • βœ… "πŸ”Œ Arduino Connected" badge on cards

  • βœ… Appears first in parking list (sorted by Arduino connection)

  • βœ… Green gradient card in sidebar for selected Arduino parking

Simulated Parking Features:

  • Realistic data using Faker.js

  • Random availability changes (Β±5% every update)

  • Used for demonstration and testing

  • Same UI/UX as real Arduino data

Parking Card Information:

  • Real-time availability tracking (e.g., "2/3 available")

  • Capacity vs occupied visualization

  • Hourly rate information

  • Distance calculation from user location

  • Quick add to favorites

  • GPS coordinates for mapping

πŸš‡ Transit Tracking

Metro Lines (10) - Simulated Data:

Metro Tracking Features:

  • Route path visualization with DMRC color coding

  • Speed and status indicators

  • Next station information

  • Simulated real-time movement

Note: Transit data is currently simulated using Faker.js for demonstration purposes.

πŸ“ Community Reporting

Report Categories:

  • πŸš— Parking Issues

  • πŸš‡ Metro Updates

  • πŸ“ General Reports

Features:

  • Location-based reporting (click on map or use current location)

  • Image upload support (Cloudinary + local storage fallback)

  • Rich text descriptions with validation

  • Community upvoting system

  • Category-specific emoji markers

  • Real-time report filtering

  • Search functionality

  • Report resolution tracking

⭐ Favorites System

  • Save frequently used parking locations

  • User-specific favorites tied to Firebase Auth

  • Persistent storage in Firestore

  • Quick access from dedicated Favorites page

  • One-click add/remove functionality

  • Visual indication on map for favorited lots

πŸ” Parking Search

  • Location-based Search - Find parking near any address

  • Distance Filtering - 1km, 3km, 5km, 10km radius options

  • Google Places Integration - Autocomplete address search

  • Visual Results - Map markers for matching parking lots

  • Detailed Cards - Distance, availability, and rates

  • User Location - GPS-based current location detection

  • Route Planning - Integration with route planner

πŸ” Authentication & Security

  • Firebase Authentication - Email/password login

  • Protected Routes - Login required for app access

  • Auth Context - Global authentication state management

  • Session Persistence - Stay logged in across sessions

  • User Profile - Display name and email management

  • Secure API - Token-based API authentication

  • Input Validation - Validator.js for sanitization

πŸ—οΈ Technology Stack

Hardware (IoT)

| Component | Model | Purpose |

|-----------|-------|---------|

| Microcontroller | Arduino Mega 2560 | Main controller for parking system |

| Entry Sensor | IR Obstacle Sensor | Detects car entry |

| Exit Sensor | IR Obstacle Sensor | Detects car exit |

| Display | LCD 16x2 (I2C) | Shows availability to drivers |

| Gate Control | SG90 Servo Motor | Automated barrier |

| Communication | USB Serial (9600) | Data transmission to PC |

Frontend

| Technology | Version | Purpose |

|------------|---------|---------|

| React | 18.2.0 | UI library |

| React Router | 6.30.1 | Client-side routing |

| Vite | 4.5.14 | Build tool & dev server |

| Google Maps API | 2.20.7 | Primary mapping solution |

| React Leaflet | 4.2.1 | Leaflet React components |

| React Leaflet Cluster | 3.1.1 | Marker clustering |

| Firebase | 10.14.1 | Client-side auth SDK |

Backend

| Technology | Version | Purpose |

|------------|---------|---------|

| Express.js | 5.1.0 | Web framework (local dev) |

| Node.js | 16+ | Runtime environment |

| SerialPort | 12.0.0 | Arduino USB communication |

| Axios | 1.7.9 | HTTP client for bridge |

| Firebase Admin | 13.5.0 | Server-side SDK |

| Faker.js | 10.1.0 | Simulated data generation |

| Multer | 2.0.2 | File upload handling |

| Cloudinary | 2.8.0 | Cloud image storage |

| Validator | 13.15.20 | Input sanitization |

| Winston | 3.18.3 | Logging framework |

| Helmet | 8.1.0 | Security middleware |

| Compression | 1.8.1 | Response compression |

| CORS | 2.8.5 | Cross-origin support |

Database & Storage

  • Firebase Firestore - NoSQL database for reports, favorites, and Arduino parking data

  • Cloudinary - Cloud-based image CDN (optional)

  • Local Storage - Fallback for image uploads

Deployment & Infrastructure

  • Vercel Serverless Functions - Production API endpoints

  • Vercel Static Hosting - React frontend deployment

  • Express Server - Local development fallback

  • Node.js Serial Bridge - Runs on local machine with Arduino

  • Continuous Deployment - Auto-deploy from Git (GitHub β†’ Vercel)

πŸ“¦ Installation & Setup

Prerequisites

  • Node.js 16.0.0 or higher (Download)

  • npm (comes with Node.js)

  • Firebase Project (Create one)

  • Google Maps API Key (Get key)

  • Arduino Mega 2560 (optional - for real sensor data)

  • Arduino IDE (if using hardware) (Download)

Part 1: Software Setup

Step 1: Clone Repository

git clone https://github.com/bikund2017/Park-Ride.git

cd Park-Ride

Step 2: Install Dependencies

# Install backend dependencies

npm install

# Install frontend dependencies

cd client

npm install

cd ..

Step 3: Firebase Setup

  1. Create Firebase Project:
  • Go to Firebase Console

  • Click "Add Project"

  • Enable Authentication (Email/Password)

  • Enable Firestore Database

  1. Download Service Account Key:
  • Go to Project Settings β†’ Service Accounts

  • Generate New Private Key

  • Save as serviceAccountKey.json in project root

  1. Get Web App Credentials:
  • Go to Project Settings β†’ General

  • Add Web App

  • Copy configuration values

Step 4: Google Maps Setup

  1. Go to Google Cloud Console

  2. Create or select a project

  3. Enable APIs:

  • Maps JavaScript API

  • Places API

  • Geocoding API

  1. Create credentials (API Key)

  2. Restrict key (optional but recommended)

Step 5: Environment Variables

Backend Configuration (Create /.env):

# Server Configuration

NODE_ENV=development

PORT=3002


# Optional: Delhi Transit API

DELHI_TRANSIT_API_KEY=your_api_key_if_available

  

# Optional: Cloudinary Image Upload

CLOUDINARY_CLOUD_NAME=your_cloud_name

CLOUDINARY_API_KEY=your_api_key

CLOUDINARY_API_SECRET=your_api_secret

  

# Optional: CORS Origins (comma-separated)

ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173

Frontend Configuration (Create /client/.env):

# Firebase Configuration

VITE_FIREBASE_API_KEY=your_firebase_api_key

VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com

VITE_FIREBASE_PROJECT_ID=your-project-id

VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com

VITE_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id

VITE_FIREBASE_APP_ID=your_app_id

  
# Google Maps API Key

VITE_GOOGLE_MAP_API=your_google_maps_api_key

Step 6: Run Development Servers

Option 1: Run

# Terminal 1 - Backend (Port 3002)

npm run dev

# Terminal 2 - Frontend (Port 3000)

cd client

npm run dev

Part 2: Arduino Hardware Setup (Optional)

Step 1: Hardware Requirements

Components Needed:

  • 1x Arduino Mega 2560

  • 2x IR Obstacle Sensors

  • 1x LCD 16x2 with I2C module

  • 1x SG90 Servo Motor

  • 1x Breadboard

  • Jumper wires

  • 1x USB A to B cable

  • Power supply (if needed)

Step 2: Circuit Connections

IR Sensors:

  • Entry Sensor:

  • VCC β†’ Arduino 5V

  • GND β†’ Arduino GND

  • OUT β†’ Arduino Pin 2

  • Exit Sensor:

  • VCC β†’ Arduino 5V

  • GND β†’ Arduino GND

  • OUT β†’ Arduino Pin 3

LCD Display (I2C):

  • VCC β†’ Arduino 5V

  • GND β†’ Arduino GND

  • SDA β†’ Arduino SDA (Pin 20)

  • SCL β†’ Arduino SCL (Pin 21)

Servo Motor:

  • Red Wire β†’ Arduino 5V

  • Brown Wire β†’ Arduino GND

  • Orange Wire β†’ Arduino Pin 9

Step 3: Upload Arduino Code

  1. Open Arduino IDE

  2. Install Required Libraries:

  • Go to Sketch β†’ Include Library β†’ Manage Libraries

  • Install: LiquidCrystal_I2C

  • Install: Servo

  1. Load the Code:
  • Open arduino/parking_sensor_system.ino

  • Or copy code from arduino/ folder

  1. Configure Settings:
#define TOTAL_PARKING_SLOTS 3 // Change based on your parking lot

#define PARKING_LOT_ID "SAB_Mall_Parking" // Unique identifier
  1. Upload to Arduino:
  • Select Board: Arduino Mega 2560

  • Select Port: (e.g., COM3 or /dev/ttyUSB0)

  • Click Upload

  1. Verify Operation:
  • LCD should display: "Available: X/3"

  • Serial Monitor (9600 baud) should show JSON output

  • Test sensors by moving hand in front of IR sensors

Step 4: Configure Serial Bridge

  1. Find Arduino Port:
# Linux

ls /dev/tty*

# Look for /dev/ttyUSB0
  1. Edit Bridge Configuration:
# Open arduino-serial-bridge.js

nano arduino-serial-bridge.js
  1. Update Port Settings:
const portPath = '/dev/ttyUSB0'; // Change to your port

const baudRate = 9600;

const serverUrl = 'https://park-ride-new1.vercel.app'; // Or localhost:3002 for local
  1. Install Bridge Dependencies:
npm install serialport axios
  1. Run Serial Bridge:
node arduino-serial-bridge.js
  1. Verify Connection:
  • You should see: βœ… Arduino connected on /dev/ttyUSB0

  • Every 5 seconds: βœ… Data sent to server successfully!

  • Check Vercel/local server logs for incoming data

Step 5: Test Arduino Integration

  1. Check Firebase:
  • Go to Firebase Console β†’ Firestore

  • Look for collection: arduino-parking

  • Should see document: SAB_Mall_Parking with latest data

  1. Check Frontend:
  • Open http://localhost:5173 (or Vercel URL)

  • Search for "parking"

  • SAB Mall Parking should appear first with πŸ”Œ badge

  • Availability should match Arduino LCD display

  1. Test Real-Time Updates:
  • Wave hand in front of Entry IR sensor

  • LCD should update: "Available: 2/3"

  • After 5 seconds, website should refresh

  • Green card should show: "2 / 3 available"

Step 6: Keep Bridge Running (Production)

Option 1: Screen (Linux/Mac)

screen -S arduino-bridge

node arduino-serial-bridge.js

# Press Ctrl+A, then D to detach

# Reattach: screen -r arduino-bridge

πŸ“ Project Structure


Park-Ride/

β”œβ”€β”€ api/ # Vercel Serverless Functions

β”‚ β”œβ”€β”€ arduino/

β”‚ β”‚ └── parking.js # POST/GET Arduino sensor data

β”‚ β”œβ”€β”€ favorites.js # GET/POST favorites

β”‚ β”œβ”€β”€ health.js # Health check endpoint

β”‚ β”œβ”€β”€ report.js # POST new report

β”‚ β”œβ”€β”€ reports.js # GET all reports

β”‚ β”œβ”€β”€ transit-data.js # GET parking + transit data (hybrid)

β”‚ β”œβ”€β”€ favorites/

β”‚ β”‚ └── delete.js # DELETE favorite

β”‚ └── reports/

β”‚ └── [id]/

β”‚ └── upvote.js # POST upvote report

β”œβ”€β”€ arduino/ # Arduino Hardware Code

β”‚ β”œβ”€β”€ parking_sensor_system.ino # Main Arduino sketch

β”‚ β”œβ”€β”€ arduino-serial-bridge.js # Node.js USBβ†’HTTP bridge

β”‚ └── README.md # Arduino setup guide

β”œβ”€β”€ client/ # React Frontend

β”‚ β”œβ”€β”€ public/ # Static assets

β”‚ β”œβ”€β”€ src/

β”‚ β”‚ β”œβ”€β”€ components/ # React components

β”‚ β”‚ β”‚ β”œβ”€β”€ Header.jsx # App header

β”‚ β”‚ β”‚ β”œβ”€β”€ Navbar.jsx # Navigation bar

β”‚ β”‚ β”‚ β”œβ”€β”€ Sidebar.jsx # Sidebar with real-time Arduino updates

β”‚ β”‚ β”‚ β”œβ”€β”€ MapViewGoogle.jsx # Google Maps component

β”‚ β”‚ β”‚ β”œβ”€β”€ ParkingSearch.jsx # Search functionality

β”‚ β”‚ β”‚ β”œβ”€β”€ RoutePlanner.jsx # Route planning

β”‚ β”‚ β”‚ β”œβ”€β”€ ReportForm.jsx # Report submission

β”‚ β”‚ β”‚ β”œβ”€β”€ ProtectedRoute.jsx# Auth guard

β”‚ β”‚ β”‚ └── LoadingSpinner.jsx# Loading UI

β”‚ β”‚ β”œβ”€β”€ contexts/

β”‚ β”‚ β”‚ └── AuthContext.jsx # Auth state management

β”‚ β”‚ β”œβ”€β”€ pages/ # Route pages

β”‚ β”‚ β”‚ β”œβ”€β”€ Home.jsx # Landing page

β”‚ β”‚ β”‚ β”œβ”€β”€ Login.jsx # Login page

β”‚ β”‚ β”‚ β”œβ”€β”€ Signup.jsx # Registration page

β”‚ β”‚ β”‚ β”œβ”€β”€ Reports.jsx # Reports page

β”‚ β”‚ β”‚ β”œβ”€β”€ Favorites.jsx # Favorites page

β”‚ β”‚ β”‚ β”œβ”€β”€ About.jsx # About page

β”‚ β”‚ β”‚ └── NotFound.jsx # 404 page

β”‚ β”‚ β”œβ”€β”€ App.jsx # Main app component

β”‚ β”‚ β”œβ”€β”€ main.jsx # App entry point

β”‚ β”‚ β”œβ”€β”€ firebaseConfig.js # Firebase client config

β”‚ β”‚ β”œβ”€β”€ index.css # Global styles

β”‚ β”‚ └── map-fix.css # Map-specific styles

β”‚ β”œβ”€β”€ package.json # Frontend dependencies

β”‚ └── vite.config.js # Vite configuration

β”œβ”€β”€ services/

β”‚ └── transitAPI.js # Transit API integration

β”œβ”€β”€ utils/

β”‚ └── logger.js # Winston logger

β”œβ”€β”€ uploads/ # Local image storage

β”œβ”€β”€ config.js # Server configuration

β”œβ”€β”€ firebase.js # Firebase Admin SDK

β”œβ”€β”€ server.js # Express server (local dev)

β”œβ”€β”€ package.json # Backend dependencies

β”œβ”€β”€ vercel.json # Vercel deployment config

β”œβ”€β”€ nodemon.json # Nodemon configuration

β”œβ”€β”€ cleanup-firebase.js # Firebase cleanup utility

β”œβ”€β”€ serviceAccountKey.json # Firebase credentials (gitignored)

β”œβ”€β”€ VERCEL_ARDUINO_SETUP.md # Arduino deployment guide

└── README.md # This file

πŸ”Œ API Reference

Base URL

  • Local: http://localhost:3002/api

  • Production: https://park-ride-new1.vercel.app/api

Arduino Endpoints (NEW!)

POST /api/arduino/parking

  • Description: Receive Arduino sensor data (called by serial bridge)

  • Body:

{

"parkingLotId": "SAB_Mall_Parking",

"totalSlots": 3,

"availableSlots": 2

}
  • Response:
{

"success": true,

"message": "Arduino parking data saved successfully",

"data": {

"parkingLotId": "SAB_Mall_Parking",

"name": "SAB Mall Parking",

"location": [28.567582, 77.322673],

"totalSlots": 3,

"availableSlots": 2,

"lastUpdated": "2025-11-06T10:30:00.000Z"

}

}

GET /api/arduino/parking

  • Description: Get latest Arduino parking data

  • Response:

{

"data": [

{

"parkingLotId": "SAB_Mall_Parking",

"name": "SAB Mall Parking",

"totalSlots": 3,

"availableSlots": 2,

"location": [28.567582, 77.322673],

"hourlyRate": 30,

"lastUpdated": "2025-11-06T10:30:00.000Z"

}

]

}

Transit & Parking Data

GET /api/transit-data

  • Description: Get all parking lots (Arduino + simulated) and transit vehicles

  • Response:

{

"parkingLots": [

{

"id": "SAB_Mall_Parking",

"name": "SAB Mall Parking",

"location": [28.567582, 77.322673],

"capacity": 3,

"availableSpots": 2,

"hourlyRate": 30,

"arduinoConnected": true,

"lastUpdated": "2025-11-06T10:30:00.000Z"

},

{

"id": 0,

"name": "Connaught Place Park & Ride",

"location": [28.6315, 77.2167],

"capacity": 250,

"availableSpots": 180,

"arduinoConnected": false

}

],

"transitVehicles": [...],

"timestamp": "2025-11-06T10:30:00.000Z",

"dataMode": "hybrid"

}

GET /api/health

  • Description: Server health check

  • Response:

{

"status": "operational",

"timestamp": "2025-11-01T12:00:00.000Z",

"server": { "uptime": 12345, ... },

"apis": { ... },

"data": { "transitVehicles": 19, "parkingLots": 12 }

}

Reports

POST /api/report

  • Description: Submit a new community report

  • Body:

{

"location": [28.6139, 77.2090],

"description": "Parking lot full, overflow parking needed",

"category": "parking",

"imageUrl": "https://..."

}
  • Response:
{

"message": "Report submitted successfully",

"reportId": "abc123"

}

GET /api/reports?category=parking&limit=100

  • Description: Get all reports with optional filtering

  • Query Params:

  • category (optional): Filter by category

  • search (optional): Search in descriptions

  • limit (optional): Max results (default: 100)

  • Response:

{

"reports": [...],

"total": 42

}

POST /api/reports/{id}/upvote

  • Description: Upvote a specific report

  • Response:

{

"message": "Report upvoted successfully",

"upvotes": 15

}

Favorites

POST /api/favorites

  • Description: Add parking lot to favorites

  • Body:

{

"userId": "firebase_user_id",

"parkingLotId": 5

}

GET /api/favorites?userId={userId}

  • Description: Get user's favorite parking lots

  • Response:

{

"favorites": [...]

}

DELETE /api/favorites/delete?userId={userId}&parkingLotId={lotId}

  • Description: Remove from favorites

🎯 How It Works

IoT Data Flow (Arduino β†’ Web)


1. Physical Event

└─ Car enters/exits parking lot

└─ IR Sensor detects movement (Pin 2 or 3)

└─ Arduino updates counter

└─ LCD displays: "Available: 2/3"

  

2. Serial Communication

└─ Arduino sends JSON via USB every loop

└─ {"parkingLotId":"SAB_Mall_Parking","totalSlots":3,"availableSlots":2}

└─ Serial Bridge (Node.js) receives data

  

3. HTTP POST to Cloud

└─ Bridge sends POST to Vercel

└─ https://park-ride-new1.vercel.app/api/arduino/parking

└─ Serverless function processes request

  

4. Database Storage

└─ Vercel function writes to Firebase

└─ Collection: arduino-parking

└─ Document: SAB_Mall_Parking

  

5. Frontend Polling

└─ React app fetches every 10 seconds

└─ GET /api/transit-data

└─ Merges Arduino + simulated data

  

6. UI Update

└─ Sidebar green card shows: "2 / 3 available"

└─ Parking list card updates with πŸ”Œ badge

└─ Map marker changes color (Green/Orange/Red)

Authentication Flow

  1. Client Initialization
  • User accesses app at localhost:5173 (dev) or park-ride-new1.vercel.app (prod)

  • React app loads with Firebase Auth check

  • Google Maps API initializes with API key

  1. Authentication Flow
  • User logs in via Firebase Auth (email/password)

  • Auth token stored in browser localStorage

  • Protected routes check auth state via AuthContext

  • User ID used for favorites and personalized features

  1. Data Polling
  • Client polls /api/transit-data every 10 seconds

  • Server fetches Arduino data from Firebase

  • Server generates simulated parking data (Faker.js)

  • Hybrid data (1 real + 2 simulated) returned to client

  1. Map Rendering
  • Google Maps renders Delhi NCR centered at [28.6139, 77.2090]

  • Arduino parking lots displayed with πŸ”Œ badge

  • Simulated parking shown with standard markers

  • Real-time availability colors: Green (>50%), Orange (20-50%), Red (<20%)

  1. Community Reports
  • User clicks map or uses current location

  • Fills out report form (description, category, optional image)

  • Image uploaded to Cloudinary or local storage

  • Report saved to Firestore with geolocation

  • All users see report on map immediately

  1. Favorites System
  • User clicks star icon on parking lot (Arduino or simulated)

  • Favorite saved to Firestore: favorites/{userId}-{lotId}

  • Favorites page fetches user-specific favorites

  • Real-time Arduino availability shown for favorited lots

  1. Parking Search
  • User enters address in search box

  • Google Places Autocomplete suggests addresses

  • User selects location or uses current GPS

  • Map filters parking lots within selected radius

  • Distance calculated using Haversine formula

Data Sources

Current Implementation:

  • Arduino Data: Real IR sensor data (SAB Mall Parking - 3 slots)

  • Simulated Data: 2 locations using Faker.js (Connaught Place, India Gate)

  • Update Frequency:

  • Arduino: Every 5 seconds (bridge POST interval)

  • Frontend: Every 10 seconds (polling interval)

  • Simulated: Random changes Β±5% on each update

Real-Time Update Chain:


Arduino (5s) β†’ Serial Bridge (5s) β†’ Vercel (instant) β†’ Firebase (instant) β†’ Frontend (10s)

Total latency: 5-15 seconds from physical event to UI update

Manual Deployment

Build Frontend:

cd client

npm run build

# Output: client/dist/

Deploy client/dist/ to any static hosting:

  • Netlify

  • GitHub Pages

  • Firebase Hosting

  • AWS S3 + CloudFront

Deploy Serverless Functions:

  • Copy api/ folder to serverless platform

  • Configure environment variables

  • Ensure Firebase Admin SDK credentials are set

πŸ“Š Data Model

Firestore Collections

arduino-parking (NEW!)

{

// Document ID: parkingLotId (e.g., "SAB_Mall_Parking")

parkingLotId: "SAB_Mall_Parking",

name: "SAB Mall Parking",

address: "313 B E, I Block, Pocket E, Sector 27, Noida",

location: [28.567582, 77.322673],

totalSlots: 3,

availableSlots: 2,

hourlyRate: 30,

lastUpdated: Timestamp

}

reports

{

id: "auto-generated",

location: [28.6139, 77.2090],

description: "Parking lot full",

category: "parking",

imageUrl: "https://...",

timestamp: Timestamp,

upvotes: 0,

resolved: false,

clientInfo: {

userAgent: "...",

ip: "..."

}

}

favorites

{

id: "userId-parkingLotId",

userId: "firebase_user_id",

parkingLotId: 5,

parkingLot: { /* full parking object */ },

createdAt: Date

}

πŸ”’ Security

  • βœ… Helmet.js for HTTP headers

  • βœ… CORS configuration (restricted origins)

  • βœ… Input validation with Validator.js

  • βœ… Firebase Authentication

  • βœ… Rate limiting (10kb body limit)

  • βœ… Sanitized user inputs

  • βœ… Secure file uploads (5MB limit, image only)

  • βœ… Environment variable protection (.env files gitignored)

  • βœ… API key restrictions (Google Maps - domain-locked)

  • βœ… Arduino data validation (JSON schema check)

  • βœ… Firebase Admin SDK server-side only (private key secured)

πŸ› Known Issues & Limitations

  • Arduino Dependency: Serial bridge must run on local machine with USB connection

  • Single Arduino: Currently supports 1-2 Arduino devices (scalable with code changes)

  • Latency: 5-15 seconds delay from physical event to UI update

  • USB Requirement: Arduino must stay connected via USB (no WiFi module)

  • Local Bridge: Bridge computer must stay online for cloud updates

  • Transit Data: Metro tracking is simulated (real APIs pending integration)

  • Image Uploads: Require Cloudinary account (local fallback available)

  • Google Maps Billing: Requires enabled billing account (free tier available)

πŸ—ΊοΈ Roadmap

Phase 1: Hardware Expansion βœ… (Current)

  • Arduino Mega 2560 integration

  • IR sensor entry/exit detection

  • LCD display for drivers

  • Servo motor gate control

  • Serial USB communication

  • Node.js serial bridge

  • Vercel serverless endpoint

  • Firebase real-time storage

  • React frontend display

Phase 2: IoT Enhancement 🚧 (In Progress)

  • Add WiFi module (ESP32/ESP8266) for wireless Arduino

  • Support multiple Arduino devices (scalable architecture)

  • Battery backup for power outages

  • SMS/Email alerts for parking full

  • QR code ticket system integration

  • License plate recognition (camera + OCR)

Phase 3: Software Features πŸ“‹ (Planned)

  • Integrate real Delhi Transit APIs (DMRC, DTC, Indian Railways)

  • Push notifications for parking availability

  • Reservation system (book parking spot in advance)

  • Payment gateway integration (UPI, cards)

  • Route optimization algorithm

  • Historical analytics dashboard

  • Admin panel for hardware management

  • Mobile app (React Native)

Phase 4: Advanced IoT πŸš€ (Future)

  • AI/ML parking prediction (occupancy forecasting)

  • Computer vision parking spot detection

  • Smart city API integrations

  • EV charging station integration

  • Weather-based parking suggestions

πŸ“Έ Screenshots & Demo

Arduino Hardware

Arduino Setup

  • Physical parking sensor system

  • IR sensors detecting car entry/exit

  • LCD display showing real-time availability

  • Servo motor controlling gate barrier

Web Application

Dashboard

  • Interactive Google Maps with parking markers

  • Real-time Arduino data display

  • Green gradient card for selected Arduino parking

  • πŸ”Œ Badge indicating live hardware connection

Real-Time Updates

Green Card

  • Selected parking location card

  • Live availability: "2 / 3 available"

  • Data source indicator: "Real-time parking availability is being updated from Arduino sensors"


Built with ❀️ and πŸ”Œ for Delhi NCR commuters

Real Hardware + Real Code = Real Impact

Combining IoT hardware with cloud computing to solve real-world parking challenges

Made with React + Express + Arduino + Firebase + Google Maps


πŸ”Œ IoT Technology Stack

Arduino

React

Node.js

Firebase

Vercel

Google Maps

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors