Skip to content

Latest commit

Β 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— Smart Parking App

A real-time parking discovery and booking application built with Next.js 14, Firebase Firestore, and React Leaflet. ESP32 IoT sensors push live slot availability to the UI instantly.

Tech Stack Firebase Leaflet TypeScript


πŸ“Έ Project Preview

Interactive Map

Map

Parking Reservation

Booking

VIEW SLOT DETAILS

BOOK LATER

BOOK NOW

BOOKING DETAILS

BOOKING CONFIRMATION

IoT Hardware Prototype

Hardware

System Architecture

Architecture

Demonstration Video

Demonstration


✨ Features

  • πŸ—ΊοΈ Interactive Map – OpenStreetMap with color-coded parking markers
  • ⚑ Real-time Updates – ESP32 sensors β†’ Firebase β†’ UI with onSnapshot
  • πŸ…ΏοΈ Visual Slot Grid – See exact slot layout with live occupancy
  • πŸ“… Park Now & Pre-book – Immediate or scheduled parking
  • πŸ“‹ Booking History – With expandable detail cards
  • πŸ‘€ Profile Management – Editable user & vehicle info
  • πŸ“± Mobile-first – Google Maps / Uber-style bottom sheets

πŸš€ Quick Start

1. Prerequisites

2. Clone & Install

git clone https://github.com/your-username/smart-parking-app.git
cd smart-parking-app

pnpm install

3. Firebase Setup

a) Create Firebase Project

  1. Go to https://console.firebase.google.com
  2. Create project β†’ Enable Firestore Database
  3. Go to Project Settings β†’ General β†’ Your Apps β†’ Add Web App
  4. Copy the config values

b) Set Firestore Rules (Dev mode)

In Firebase Console β†’ Firestore β†’ Rules, paste:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

4. Environment Variables

cp .env.local.example .env.local

Edit .env.local with your Firebase config:

NEXT_PUBLIC_FIREBASE_API_KEY="AIzaSy..."
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN="your-project.firebaseapp.com"
NEXT_PUBLIC_FIREBASE_PROJECT_ID="your-project"
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET="your-project.firebasestorage.app"
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID="000000000000"
NEXT_PUBLIC_FIREBASE_APP_ID="1:000:web:xxx"

5. Initialize Sample Data

# Install firebase-admin for the script
pnpm add -D firebase-admin

# Download your service account key from Firebase Console
# Project Settings β†’ Service Accounts β†’ Generate new private key
# Save as scripts/serviceAccountKey.json

node scripts/initFirebaseData.js

This creates:

  • 3 parking sites in Mumbai
  • 18-30 slots per site with random initial occupancy

6. Run

pnpm dev
# β†’ http://localhost:3000

πŸ“ Project Structure

smart-parking-app/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ layout.tsx          # Root layout + Leaflet CSS
β”‚   β”œβ”€β”€ page.tsx            # Map home page
β”‚   β”œβ”€β”€ globals.css         # Global styles
β”‚   β”œβ”€β”€ history/
β”‚   β”‚   └── page.tsx        # Booking history
β”‚   └── profile/
β”‚       └── page.tsx        # User profile
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ParkingMap.tsx      # Leaflet map + markers
β”‚   β”œβ”€β”€ SearchBar.tsx       # Floating search + locate me
β”‚   β”œβ”€β”€ ParkingBottomSheet.tsx  # Slide-up parking card
β”‚   β”œβ”€β”€ SlotGrid.tsx        # Interactive slot layout
β”‚   β”œβ”€β”€ BookingModal.tsx    # 3-step booking flow
β”‚   └── Navbar.tsx          # Bottom navigation
β”œβ”€β”€ hooks/
β”‚   └── useFirestore.ts     # All Firebase queries & real-time hooks
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ firebase.ts         # Firebase initialization
β”‚   └── utils.ts            # Helper functions
β”œβ”€β”€ types/
β”‚   └── index.ts            # TypeScript types
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ initFirebaseData.js # Seed Firebase with sample data
β”‚   └── esp32_sensor.ino    # Arduino firmware for ESP32
β”œβ”€β”€ .env.local.example      # Environment template
β”œβ”€β”€ firestore.rules         # Firebase security rules
└── package.json

πŸ”Œ ESP32 Integration

  1. Open scripts/esp32_sensor.ino in Arduino IDE
  2. Install libraries: ArduinoJson via Library Manager
  3. Fill in your WiFi credentials and Firebase API key
  4. Wire HC-SR04 sensor: TRIG β†’ GPIO5, ECHO β†’ GPIO18
  5. Flash to ESP32 β†’ it auto-pushes slot status every 3 seconds

Data flow:

HC-SR04 Sensor
     ↓
  ESP32 (WiFi)
     ↓ HTTPS PATCH
Firebase Firestore
     ↓ onSnapshot
  Next.js Web App
     ↓
  UI updates live

πŸ› οΈ Available Scripts

Command Description
pnpm dev Start development server
pnpm build Build for production
pnpm start Start production server
pnpm lint Run ESLint
node scripts/initFirebaseData.js Seed Firebase

🚒 Deployment

Vercel (Recommended)

pnpm add -g vercel
vercel
# Follow prompts, add env vars in Vercel dashboard

Self-hosted

pnpm build
pnpm start
# Runs on port 3000

Docker

FROM node:18-alpine
WORKDIR /app
COPY . .
RUN npm install -g pnpm && pnpm install && pnpm build
EXPOSE 3000
CMD ["pnpm", "start"]

πŸ—ƒοΈ Firestore Collections

Collection Description
parkingSites Parking locations with coordinates
parkingSlots Per-slot occupancy (updated by ESP32)
bookings User booking records

πŸ”§ Troubleshooting

Map not loading?

  • Ensure leaflet/dist/leaflet.css is imported in layout.tsx
  • Check browser console for CSP errors

Firebase permission denied?

  • Set Firestore rules to allow read/write (dev mode)
  • Verify .env.local has correct values with NEXT_PUBLIC_ prefix

Markers not showing?

  • Run node scripts/initFirebaseData.js to seed parking sites
  • Check Firestore console to confirm data exists

ESP32 not sending data?

  • Verify WiFi credentials in .ino file
  • Check Serial Monitor at 115200 baud for error messages
  • Ensure Firebase API key is correct

πŸ“„ License

MIT

About

Smart parking platform that combines IoT sensors, real-time occupancy tracking, interactive maps, and online booking to simplify parking discovery and management.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages