Skip to content

prathamb9/India_Innovates_Merge_Conflicts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

70 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SignalSync Logo

SignalSync

AI-Powered Intelligent Traffic Management & Emergency Response System

Next.js 16 YOLOv8 Firebase Google Maps TailwindCSS Python

Team Merge_Conflicts ยท India Innovates Hackathon 2026

Restoring the Golden Hour โ€” one green signal at a time.

Live Demo ยท Architecture ยท Edge AI ยท Setup Guide


๐Ÿ“‹ Table of Contents


๐ŸŒ Overview

SignalSync is a full-stack AI-powered traffic management platform that combines real-time computer vision (YOLOv8), dynamic signal control, and emergency green corridor management to tackle India's most critical urban mobility challenges.

Built by Team Merge_Conflicts for the India Innovates Hackathon 2026, SignalSync demonstrates how edge AI and connected infrastructure can save lives during the critical Golden Hour โ€” the 60-minute window where timely medical intervention can mean the difference between life and death.

๐Ÿ’ก Key Insight: Ambulances in Indian cities spend 10โ€“15% of their journey time stuck at red lights. SignalSync eliminates that delay entirely.


๐Ÿšจ The Problem

Problem Impact
๐Ÿฅ Red-light delays for ambulances 10โ€“15% of Golden Hour lost idling at signals
๐Ÿšฆ Fixed-timer traffic signals Waste fuel on empty lanes, ignore real-time density
๐Ÿ›ก๏ธ VVIP convoy security Stopped convoys become static security targets
๐Ÿ“Š No real-time visibility Traffic control rooms lack live intersection intelligence
๐Ÿ”‡ No automated preemption Signal override requires manual radio coordination

๐Ÿ’ก Our Solution

SignalSync operates on three integrated pillars:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                          SIGNALSYNC                              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   ๐ŸŽฏ AI VISION   โ”‚  ๐ŸŸข GREEN WAVE   โ”‚    ๐Ÿ“Š LIVE DASHBOARD      โ”‚
โ”‚                  โ”‚                  โ”‚                            โ”‚
โ”‚  YOLOv8 detects  โ”‚  Dispatcher      โ”‚  City-wide traffic        โ”‚
โ”‚  vehicles at     โ”‚  creates a       โ”‚  control center with      โ”‚
โ”‚  every inter-    โ”‚  zero-stop       โ”‚  real-time node status,   โ”‚
โ”‚  section in      โ”‚  signal priority โ”‚  active corridors, and    โ”‚
โ”‚  real-time       โ”‚  path for        โ”‚  AI-powered density       โ”‚
โ”‚                  โ”‚  ambulances      โ”‚  analytics                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  4-cam pipeline  โ”‚  GPS tracking    โ”‚  Signal cycle control     โ”‚
โ”‚  N/S/E/W feeds   โ”‚  Auto-terminate  โ”‚  Manual + AI override     โ”‚
โ”‚  Edge processing โ”‚  Firebase sync   โ”‚  Emergency detection      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ—๏ธ System Architecture

graph TB
    subgraph Edge["๐ŸŽฏ Edge AI Layer"]
        V1[CAM: NORTH] --> YOLO[YOLOv8 Model]
        V2[CAM: SOUTH] --> YOLO
        V3[CAM: EAST] --> YOLO
        V4[CAM: WEST] --> YOLO
        YOLO --> SC[Signal Controller]
        YOLO --> MJPEG[MJPEG Streamer :8001]
    end

    subgraph Cloud["โ˜๏ธ Cloud Layer"]
        FB[(Firebase Firestore)]
        AUTH[Firebase Auth]
    end

    subgraph Frontend["๐Ÿ–ฅ๏ธ Frontend Layer"]
        HP[Landing Page]
        DB[Live Dashboard]
        PT[Green Corridor Portal]
        IM[Intersection Modal]
    end

    SC --> FB
    MJPEG --> IM
    FB --> DB
    FB --> PT
    AUTH --> PT
Loading

Data Flow:

  1. Edge cameras feed video into YOLOv8 for real-time vehicle detection
  2. Signal Controller analyzes N/S vs E/W density โ†’ dynamically assigns GREEN to the denser axis
  3. MJPEG Streamer serves annotated video feeds with bounding boxes to the dashboard
  4. Firebase Firestore syncs signal states, corridor data, and intersection stats in real-time
  5. Dashboard displays live feeds, signal status, and emergency override controls

โœจ Key Features

๐Ÿ  Landing Page (/)

  • Visuo-inspired dark violet-black aesthetic with animated purple spotlight
  • Animated intersection hero with traffic light cycling N/S โ†” E/W phases
  • Problem statement, three-pillar architecture breakdown, user flow diagrams
  • Multi-language support (English, Hindi, Kannada, Telugu, Tamil, Marathi, Bengali, Gujarati)

๐Ÿ“Š Live Dashboard (/dashboard)

  • City picker โ€” 8 major Indian cities with instant data refresh
  • AI Camera Network โ€” 6 real named intersections per city with live YOLO density
  • 4-Direction Intersection Modal โ€” click any camera to open the N/S/E/W quad-view with:
    • Real-time YOLO bounding boxes on each direction's video feed
    • Independent signal poles per direction (GREEN/YELLOW/RED)
    • Live density percentage and vehicle count per direction
    • Traffic status banners (FLOWING / STOPPED / CLEARING)
  • Signal Control Panel โ€” traffic light status, countdown timer, N/S vs E/W density bar
  • Manual Override Controls โ€” Force Green, Force Red, Reset Auto per intersection
  • Emergency Detection โ€” Force Emergency button simulates ambulance detection cascade
  • IoT Auto-Preemption โ€” GPS-based signal preemption when ambulance is within 500m
  • Live Green Corridors โ€” polls Firestore + localStorage every 1.5s for active corridors
  • System Log โ€” timestamped event log showing all signal changes and detections

๐Ÿ—บ๏ธ Green Corridor Portal (/portal)

  • ๐Ÿ“ Use My Location โ€” one-tap GPS auto-fill using Browser Geolocation API
  • Route Finder โ€” Google Directions API with live traffic-aware routing (departure-time + BEST_GUESS)
  • Initiate Green Wave โ€” saves corridor to Firestore, auto-selects 5 intersections along the route
  • CorridorStatusBox โ€” animated GREEN โœ“ / PREP โฑ / QUEUED status per node
  • Traffic signal overlays โ€” colored rings at each node on the Google Map
  • Live GPS Tracking โ€” watchPosition() tracks vehicle with pulsing blue dot, map auto-recenters
  • Auto-terminate โ€” corridor removed from Firestore + localStorage 2.5s after arrival

๐Ÿ” Authentication (/auth/login, /auth/register)

  • Firebase Authentication (Email/Password)
  • Role-based access control โ€” admin role unlocks full signal override panel

โš™๏ธ Admin Panel (/admin)

  • Admin-only route guarded by Firestore role check
  • Full signal override capabilities

๐Ÿค– Edge AI Module

The edge-sim/ directory contains the Python-based Edge AI processing pipeline โ€” the brain of SignalSync's real-time traffic intelligence.

Components

File Purpose
streamer.py 4-direction pipelined YOLO streamer with MJPEG output and signal control
runner.py Standalone YOLO runner that pushes emergency events to Firebase
firebase_client.py Firebase Admin SDK client for pushing intersection stats and events
yolov8n.pt Pre-trained YOLOv8n model weights

How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  4 Video     โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  YOLOv8 Inference โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  Frame Buffer   โ”‚
โ”‚  Sources     โ”‚     โ”‚  (every 4th frame)โ”‚     โ”‚  (3.5s batches) โ”‚
โ”‚  N/S/E/W     โ”‚     โ”‚                  โ”‚     โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                       โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”‚
                    โ”‚  Signal          โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚  Controller      โ”‚     density stats
                    โ”‚  (1s tick)       โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  MJPEG Stream    โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  Dashboard       โ”‚
                    โ”‚  :8001           โ”‚     โ”‚  (Browser)       โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  Firebase Push   โ”‚
                    โ”‚  (2s interval)   โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Per-Direction Video Pipeline

Each direction (NORTH, SOUTH, EAST, WEST) has its own dedicated video file and processing pipeline:

Direction Video Source Axis
NORTH demo.mp4 N/S
SOUTH WhatsApp Video 1.mp4 N/S
EAST WhatsApp Video 2.mp4 E/W
WEST WhatsApp Video 3.mp4 E/W

Each pipeline runs in its own thread with double-buffered frame processing for smooth, gap-free MJPEG streaming at 20fps.

API Endpoints (Port 8001)

Endpoint Method Description
/video_feed/{direction} GET MJPEG stream for NORTH/SOUTH/EAST/WEST
/signal_state GET Current signal phase, mode, and axis densities
/signal_override POST Admin-only manual signal phase lock
/stats GET Per-direction YOLO detection stats
/stats/{direction} GET Stats for a single direction
/health GET Service health check with pipeline readiness

๐Ÿ› ๏ธ Tech Stack

Layer Technology Purpose
Frontend Next.js 16 (App Router) React-based SSR/CSR application
Styling Tailwind CSS 3 + Custom CSS tokens Dark-mode design system with Visuo aesthetic
Maps Google Maps JavaScript API Maps, Directions, Places Autocomplete
GPS Browser Geolocation API Real-time vehicle tracking
Auth Firebase Authentication Email/Password login with role-based access
Database Cloud Firestore Real-time corridor sync and intersection stats
AI/ML YOLOv8n (Ultralytics) Real-time vehicle detection and classification
Video OpenCV + MJPEG 4-direction video processing and streaming
Backend FastAPI + Uvicorn Edge AI REST API and MJPEG streamer
IoT Firebase Realtime Signals GPS-based ambulance geofence preemption
i18n Custom LanguageProvider 8-language support (EN, HI, KN, TE, TA, MR, BN, GU)

๐Ÿ“ Project Structure

India_Innovates_Merge_Conflicts/
โ”‚
โ”œโ”€โ”€ README.md                          โ† You are here
โ”œโ”€โ”€ start-backend.ps1                  โ† One-click backend launcher (all 4 services)
โ”œโ”€โ”€ start-frontend.ps1                 โ† Frontend dev server launcher
โ”œโ”€โ”€ yolov8n.pt                         โ† YOLO model weights
โ”‚
โ”œโ”€โ”€ edge-sim/                          โ† ๐Ÿค– Edge AI Processing Module
โ”‚   โ”œโ”€โ”€ streamer.py                    # 4-direction YOLO streamer + signal controller
โ”‚   โ”œโ”€โ”€ runner.py                      # Standalone YOLO runner โ†’ Firebase events
โ”‚   โ”œโ”€โ”€ firebase_client.py             # Firebase Admin SDK push client
โ”‚   โ”œโ”€โ”€ requirements.txt               # Python dependencies
โ”‚   โ”œโ”€โ”€ serviceAccountKey.json         # ๐Ÿ”‘ Firebase service account (gitignored)
โ”‚   โ”œโ”€โ”€ yolov8n.pt                     # YOLOv8n model weights
โ”‚   โ”œโ”€โ”€ demo.mp4                       # NORTH camera demo video
โ”‚   โ”œโ”€โ”€ WhatsApp Video 1.mp4           # SOUTH camera demo video
โ”‚   โ”œโ”€โ”€ WhatsApp Video 2.mp4           # EAST camera demo video
โ”‚   โ””โ”€โ”€ WhatsApp Video 3.mp4           # WEST camera demo video
โ”‚
โ””โ”€โ”€ signal-sync/                       โ† ๐Ÿ–ฅ๏ธ Next.js Frontend Application
    โ”œโ”€โ”€ app/
    โ”‚   โ”œโ”€โ”€ layout.jsx                 # Root layout โ€” AuthProvider, fonts, global styles
    โ”‚   โ”œโ”€โ”€ globals.css                # Design tokens, Visuo theme, animations
    โ”‚   โ”œโ”€โ”€ page.jsx                   # Landing page โ€” animated hero, problem, pillars
    โ”‚   โ”œโ”€โ”€ dashboard/
    โ”‚   โ”‚   โ””โ”€โ”€ page.jsx               # Live city dashboard โ€” AI cameras, corridors
    โ”‚   โ”œโ”€โ”€ portal/
    โ”‚   โ”‚   โ””โ”€โ”€ page.jsx               # Green corridor creation & GPS navigation
    โ”‚   โ”œโ”€โ”€ routes/
    โ”‚   โ”‚   โ””โ”€โ”€ page.jsx               # Standalone route finder
    โ”‚   โ”œโ”€โ”€ admin/
    โ”‚   โ”‚   โ””โ”€โ”€ page.jsx               # Admin panel (role-gated)
    โ”‚   โ”œโ”€โ”€ profile/
    โ”‚   โ”‚   โ””โ”€โ”€ page.jsx               # User profile page
    โ”‚   โ””โ”€โ”€ auth/
    โ”‚       โ”œโ”€โ”€ login/page.jsx         # Sign-in page
    โ”‚       โ””โ”€โ”€ register/page.jsx      # Registration page
    โ”‚
    โ”œโ”€โ”€ components/
    โ”‚   โ”œโ”€โ”€ YoloFailsafePanel.jsx      # 6-camera AI grid with signal control
    โ”‚   โ”œโ”€โ”€ IntersectionModal.jsx       # 4-direction N/S/E/W expanded view
    โ”‚   โ”œโ”€โ”€ DelhiMap.jsx               # Google Maps with GPS, overlays, directions
    โ”‚   โ”œโ”€โ”€ CorridorStatusBox.jsx       # Animated GREEN/PREP/QUEUED status
    โ”‚   โ”œโ”€โ”€ DemoCorridorStatus.jsx      # Demo corridor animation
    โ”‚   โ”œโ”€โ”€ Navbar.jsx                 # Navigation bar
    โ”‚   โ”œโ”€โ”€ Chatbot.jsx                # In-app chatbot
    โ”‚   โ”œโ”€โ”€ AuthProvider.jsx           # Firebase auth context + Firestore profile
    โ”‚   โ”œโ”€โ”€ LanguageProvider.jsx        # Multi-language context provider
    โ”‚   โ””โ”€โ”€ LanguagePicker.jsx         # Language selection dropdown
    โ”‚
    โ”œโ”€โ”€ lib/
    โ”‚   โ”œโ”€โ”€ firebase.js                # Firebase app + Auth + Firestore init
    โ”‚   โ”œโ”€โ”€ firestore.js               # Firestore helpers โ€” corridors, signals
    โ”‚   โ”œโ”€โ”€ cityNodes.js               # Real intersection data for 8 cities
    โ”‚   โ””โ”€โ”€ i18n.js                    # Translation strings (8 languages)
    โ”‚
    โ”œโ”€โ”€ public/
    โ”‚   โ”œโ”€โ”€ logo.png                   # SignalSync logo
    โ”‚   โ”œโ”€โ”€ cam-north.mp4              # Fallback video โ€” NORTH direction
    โ”‚   โ”œโ”€โ”€ cam-south.mp4              # Fallback video โ€” SOUTH direction
    โ”‚   โ”œโ”€โ”€ cam-east.mp4               # Fallback video โ€” EAST direction
    โ”‚   โ””โ”€โ”€ cam-west.mp4               # Fallback video โ€” WEST direction
    โ”‚
    โ”œโ”€โ”€ .env.local                     # ๐Ÿ”‘ Environment variables (gitignored)
    โ”œโ”€โ”€ next.config.js
    โ”œโ”€โ”€ tailwind.config.js
    โ”œโ”€โ”€ postcss.config.js
    โ””โ”€โ”€ package.json

๐Ÿš€ Getting Started

Prerequisites

Requirement Version Installation
Node.js โ‰ฅ 18 LTS nodejs.org
Python โ‰ฅ 3.10 python.org
pip Latest Comes with Python
Google Cloud โ€” Maps JS API, Directions API, Places API enabled
Firebase โ€” Auth (Email/Password) + Cloud Firestore

Step 1 โ€” Clone the Repository

git clone https://github.com/Aniruddha1406/India_Innovates_Merge_Conflicts.git
cd India_Innovates_Merge_Conflicts

Step 2 โ€” Install Frontend Dependencies

cd signal-sync
npm install

โš ๏ธ If npm install fails with peer dependency errors, use npm install --force

Step 3 โ€” Install Edge AI Dependencies

cd edge-sim
pip install -r requirements.txt

Required Python packages:

  • ultralytics (YOLOv8)
  • opencv-python
  • fastapi
  • uvicorn
  • firebase-admin

Step 4 โ€” Configure Environment Variables

Create signal-sync/.env.local:

# โ”€โ”€ Google Maps โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your_google_maps_api_key

# โ”€โ”€ Firebase (Client SDK) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id

Place your Firebase Admin SDK service account key at:

edge-sim/serviceAccountKey.json

๐Ÿ” Both .env.local and serviceAccountKey.json are gitignored. Never commit credentials.

Step 5 โ€” Launch Everything

Option A: One-click launch (Windows PowerShell)

# Terminal 1 โ€” All backend services
.\start-backend.ps1

# Terminal 2 โ€” Frontend dev server
.\start-frontend.ps1

Option B: Manual launch

# Terminal 1 โ€” FastAPI Backend (port 5000)
cd backend
python -m uvicorn main:app --port 5000 --reload

# Terminal 2 โ€” YOLO Streamer (port 8001)
cd edge-sim
python streamer.py --video-north demo.mp4 --video-south "WhatsApp Video 1.mp4" --video-east "WhatsApp Video 2.mp4" --video-west "WhatsApp Video 3.mp4" --port 8001

# Terminal 3 โ€” YOLO Runner (Firebase events)
cd edge-sim
python runner.py --video demo.mp4 --headless

# Terminal 4 โ€” Next.js Frontend (port 3000)
cd signal-sync
npm run dev

Step 6 โ€” Open in Browser

Service URL Description
Frontend http://localhost:3000 SignalSync web application
YOLO Streamer http://localhost:8001/health Edge AI health check
YOLO Feeds http://localhost:8001/video_feed/NORTH Live MJPEG stream

๐Ÿ”‘ Environment Variables

Variable Required Description
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY โœ… Google Maps JavaScript API key
NEXT_PUBLIC_FIREBASE_API_KEY โœ… Firebase project API key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN โœ… Firebase Auth domain
NEXT_PUBLIC_FIREBASE_PROJECT_ID โœ… Firebase project ID
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET โœ… Firebase Storage bucket
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID โœ… Firebase Cloud Messaging sender ID
NEXT_PUBLIC_FIREBASE_APP_ID โœ… Firebase app ID

All NEXT_PUBLIC_ prefixed variables are exposed to the browser. Admin/secret keys go in serviceAccountKey.json only.


๐Ÿ“„ Pages & Routes

Route Page Auth Description
/ Landing Page No Animated hero, problem statement, solution pillars, user flows
/dashboard Live Dashboard No City-wide AI camera network, signal control, corridors
/portal Green Corridor Yes* Create corridors, GPS tracking, real-time signal override
/routes Route Finder No Standalone route search with city-bounded autocomplete
/admin Admin Panel Admin Signal override, system management
/profile User Profile Yes User account settings
/auth/login Sign In No Email/password authentication
/auth/register Sign Up No New account creation

*Basic features accessible without auth; full corridor creation requires sign-in.


๐Ÿš‘ Green Corridor System

End-to-End Flow

 โ‘  Operator opens /portal
    โ””โ”€โ–ถ Selects city โ†’ Enters origin & destination
         โ””โ”€โ–ถ [Optional] Tap ๐Ÿ“ for GPS auto-fill

 โ‘ก Clicks "Get Best Route"  
    โ””โ”€โ–ถ Google Directions API fetches traffic-aware route
         โ””โ”€โ–ถ Live departure-time model with BEST_GUESS traffic

 โ‘ข Clicks "Initiate Green Wave"
    โ””โ”€โ–ถ pickCorridorNodes() selects 5 real intersections along the route
    โ””โ”€โ–ถ Corridor saved to Firestore + localStorage  
    โ””โ”€โ–ถ Signal circle overlays appear on map (๐ŸŸข ๐ŸŸก ๐Ÿ”ด)

 โ‘ฃ Demo ambulance drives the route on the map
    โ””โ”€โ–ถ Each node triggers onNodeAdvance() callback
    โ””โ”€โ–ถ CorridorStatusBox updates: GREEN โ†’ PREP โ†’ QUEUED cascade
    โ””โ”€โ–ถ Dashboard polls localStorage every 1.5s and mirrors status

 โ‘ค [Physical travel] Tap "Start Live GPS Tracking"
    โ””โ”€โ–ถ watchPosition() tracks vehicle with pulsing blue dot
    โ””โ”€โ–ถ Map auto-recenters at zoom level 15

 โ‘ฅ Vehicle arrives at destination
    โ””โ”€โ–ถ Auto-terminate fires after 2.5s grace period
    โ””โ”€โ–ถ Corridor removed from Firestore + localStorage
    โ””โ”€โ–ถ All signals return to normal cycle

Signal States

State Visual Description
GREEN โœ“ ๐ŸŸข Green circle Ambulance at intersection โ€” full green priority
PREP โฑ ๐ŸŸก Amber circle Next intersection โ€” signal preparing to clear
QUEUED ๐Ÿ”ด Red circle Downstream โ€” cross-traffic held at red
โœ“ CLEAR โšช Dim green Ambulance passed โ€” signal returned to normal

๐Ÿšฆ Signal Control Logic

The signal controller in streamer.py runs every 1 second and uses a hybrid approach:

Dynamic Mode (Density Difference > 10%)

IF avg(N/S density) > avg(E/W density) + 10%:
    โ†’ N/S axis gets GREEN, E/W gets RED
    
IF avg(E/W density) > avg(N/S density) + 10%:
    โ†’ E/W axis gets GREEN, N/S gets RED

Fixed Cycle Mode (Balanced Traffic)

GREEN  (20s) โ†’ YELLOW (3s buffer) โ†’ RED (15s) โ†’ swap axes โ†’ repeat

Emergency Override

Ambulance detected by YOLO โ†’ ALL signals YELLOW (3s) โ†’ 
    Detection node: GREEN (corridor clear)
    All other nodes: RED (cross-traffic stopped)
    โ†’ Auto-clear after vehicle passes

Priority Hierarchy

IoT Geofence Preemption > Emergency YOLO Detection > Manual Override > Auto Cycle

๐Ÿ™๏ธ City Coverage

SignalSync covers 8 major Indian cities with 17โ€“20 real named intersections per city:

City State Sample Intersections
๐Ÿ›๏ธ Delhi Delhi NCR Connaught Place, AIIMS, Karol Bagh, IGI Terminal 3, Lajpat Nagar
๐ŸŒŠ Mumbai Maharashtra Dadar TT Circle, BKC, Andheri Junction, Mahim Causeway, Borivali
๐ŸŒณ Bengaluru Karnataka Silk Board Junction, Hebbal Flyover, Marathahalli, Whitefield
๐Ÿ•Œ Hyderabad Telangana Hitech City, Jubilee Hills, Ameerpet, Gachibowli, Charminar
๐Ÿ–๏ธ Chennai Tamil Nadu Anna Salai, T. Nagar Pondy Bazaar, Koyambedu Hub, Guindy
โ›ฐ๏ธ Pune Maharashtra Shivajinagar, Swargate, Hadapsar, Hinjewadi Phase 1
๐ŸŒ‰ Kolkata West Bengal Esplanade Crossing, Park Street, Gariahat More, Howrah Station
๐Ÿ—๏ธ Ahmedabad Gujarat ISCON Circle, Navrangpura, SG Highway, Shivranjani Cross Rd

All intersection data with real GPS coordinates is stored in signal-sync/lib/cityNodes.js.


๐Ÿ”ฅ Firebase Setup

Required Services

  1. Authentication โ†’ Enable Email/Password sign-in method
  2. Cloud Firestore โ†’ Create database in production mode

Firestore Collections

Collection Purpose
users User profiles with role field
corridors Active green corridor data
edge_events YOLO emergency detection events
intersection_stats Per-camera density and vehicle data
signals Real-time signal state per intersection

Recommended Security Rules

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Users โ€” only the owner can read/write their profile
    match /users/{uid} {
      allow read, write: if request.auth.uid == uid;
    }
    // Corridors โ€” authenticated users can create; owner/admin can modify
    match /corridors/{corridorId} {
      allow read: if true;
      allow create: if request.auth != null;
      allow update, delete: if request.auth != null &&
        (resource.data.uid == request.auth.uid ||
         get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin');
    }
    // Edge events & stats โ€” read-only for clients; server writes via Admin SDK
    match /edge_events/{doc} {
      allow read: if true;
    }
    match /intersection_stats/{doc} {
      allow read: if true;
    }
    match /signals/{doc} {
      allow read: if true;
    }
  }
}

๐Ÿ“ž Emergency Numbers (India)

Service Number
๐Ÿš‘ Ambulance 102
๐Ÿš’ Fire Brigade 101
๐Ÿ‘ฎ Police 100
๐Ÿฅ All Emergencies (GVK EMRI) 108

๐Ÿค Team

Team Merge_Conflicts

India Innovates Hackathon 2026

Area Contribution
๐Ÿ–ฅ๏ธ Full-Stack Development Next.js 16 app, Firebase integration, Google Maps API
๐Ÿค– AI/ML Engineering YOLOv8 pipeline, 4-direction video processing, signal control
๐ŸŽจ UI/UX Design Dark-mode Visuo design system, animations, responsive layout
๐Ÿ“Š Data Research Real intersection GPS coordinates for 8 Indian cities
๐Ÿ—๏ธ System Architecture Green corridor algorithm, real-time signal sync, IoT preemption

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


SignalSync

SignalSync ยท Restoring the Golden Hour

Built with โค๏ธ by Team Merge_Conflicts

India Innovates Hackathon ยท 2026

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors