Production-Grade Full-Stack Transit Platform & IoT Telematics Ecosystem
Built with Next.js 14 (App Router), TypeScript, Tailwind CSS, Supabase PostgreSQL, Upstash Redis, Razorpay, Leaflet GIS, and ESP32 IoT Microcontrollers.
Inspired by the seat allocation UX of RedBus & AbhiBus, the live radar experience of Delhi Metro, and the operational fleet intelligence of Optibus & Samsara.
π Official Production URL: https://campusfleet.vercel.app
- π Main Live Web App: https://campusfleet.vercel.app
- β‘ High-Availability Mirrors: https://ridx.vercel.app β’ https://campusfleet-live.vercel.app
- π Dedicated IoT Firmware Repo: https://github.com/CampusFleet/esp32-rfid-terminal
-
Real-Time Attendance Reconciliation: Reads morning shift boarding check-ins from
attendance_recordsto immediately identify and prune absentee riders from the outgoing evening manifests. -
Intra-Corridor Bus Disassembly at Merge Stops: If two buses on the same corridor are operating at low load factors, the engine combines riders onto a single carrier vehicle at an authorized interchange stop and stands down the redundant bus at the depot (
STANDBY_DISASSEMBLED), saving 5β8 Liters of diesel per run. -
Clarke-Wright Multi-Corridor Route Stitching: Merges low-occupancy adjacent routes (
$\le 50%$ ) by splicing active stops and bypassing empty ones, strictly bounded by maximum detour SLAs ($\le 15$ minutes). -
Dynamic Progressive Bus Dispatch: Staggers depot departures as buses reach target threshold occupancies (e.g.
$80%$ ), preventing campus parking gridlocks. -
Strict Transit Hierarchy Rule: Fully separates internal operational dispatches (
trip_id,trip_code) from commuter interfaces. Students only see human-friendly labels: Bus Number, Route Name, and Departure Time.
- Dynamic Institutional Groups: Chat channels are partitioned dynamically by campus (e.g.
campus-gehu-bhimtal). Group creation and deletion are locked from end-users to ensure roster integrity. - Live Interactive Polls: Group members can create and vote on single/multi-choice polls with live percentage progress bars and real-time voter tallying.
- Sub-2ms Redis Cache-Aside: Chat messages and polls are cached in Upstash Redis (
chat:msgs:${conversationId}) with 60-second sliding TTLs and instant cache invalidation on new messages, votes, reactions, and edits. - SVG Icon Standard: Crisp Lucide React SVGs (
ThumbsUp,Heart,BusFront) replacing OS-dependent emoji stickers for light and dark modes.
- Isolated Hardware Repository: Deployed to CampusFleet/esp32-rfid-terminal with PlatformIO and Arduino IDE compatibility.
- Self-Identity via Hardware MAC: Bus terminals read their physical factory MAC address on startup β no hardcoded bus IDs are baked into firmware.
- Sub-2ms Redis Heartbeat: Terminals transmit lightweight heartbeats every 20 seconds, updating live status directly in memory with 0 SQL database load.
- Visual LED Feedback: Pulses the onboard status LED 3 times upon successful card validation.
- Physical 2Γ2 Chassis Seat Map: Realistic bus chassis layouts (
2x2,2x3,3x2, continuous rear bench). - Atomic Distributed Seat Locking: Redis
SETNX+ PostgreSQLseat_attendance_transaction()PL/pgSQL function prevents double-booking under high concurrency. - Semester Subscription Integration: Seat selection acts as a digital boarding pass linked to conductor manifests.
- Dijkstra's Shortest Path β Optimal path between stops ($O((V+E)\log V)$).
- Bellman-Ford Nearest Stops β Discovers best nearby stops with connectivity bonuses.
- A* Search β Point-to-point pathfinding using Haversine heuristic distance.
-
Floyd-Warshall All-Pairs β Precomputes all-pairs shortest distances for dashboard analytics (
$O(V^3)$ ,$O(1)$ query). - Kruskal's MST β Calculates minimum road infrastructure connecting campus hubs.
- Direct Express Engine β Dynamically skips stops where zero active students alight.
- Rotating Cryptographic QR Nonces: Digital passes regenerate HMAC tokens every 30 seconds to defeat static screenshots.
-
Geofence GPS Validation: Attendance scans require conductor and student GPS coordinates to be physically within
$<150\text{m}$ of the stop. - Passport Photo KYC Matching: Conductor scanner displays verified student photos to prevent card/pass impersonation.
| Technology | Purpose |
|---|---|
| Next.js 14 (App Router) | Full-stack framework with React Server Components (RSC) and SSR |
| React 18 | UI component rendering |
| TypeScript | Strict compile-time type safety across all domain entities |
| Tailwind CSS | Utility-first styling with responsive, accessible light/dark themes |
| Framer Motion | Micro-animations and tactile 3D transitions |
| Leaflet & React-Leaflet | Interactive GIS mapping with custom animated bus markers |
| Lucide React | Modern SVG icons (zero OS-dependent emoji stickers) |
| jsQR & qrcode.react | 60 FPS camera-based QR scanning and dynamic ticket rendering |
| Technology | Purpose |
|---|---|
| Supabase PostgreSQL | Cloud-hosted relational database with Row Level Security (RLS) |
| Supabase Realtime | WebSocket bus location broadcasting and instant dispatch updates |
| Upstash Redis | Sub-2ms cache-aside layer, distributed seat locks, and live IoT heartbeats |
| Next.js API Routes | 31 API route groups (85+ REST endpoints) |
| Razorpay | Online payment gateway for semester transit passes and fee verification |
| jose (JWT) | HS256 cryptographically signed tokens with HttpOnly secure cookies |
| MongoDB | Real-time chat messages and interactive poll option persistence |
| Technology | Purpose |
|---|---|
| ESP32 Dev Module | Wi-Fi / 4G Hotspot connected microcontrollers mounted on buses |
| MFRC522 (RC522) | 13.56 MHz RFID contactless smart card reader via SPI bus |
| PlatformIO / Arduino | Firmware toolchains for compilation, flashing, and OTA updates |
| Technology | Purpose |
|---|---|
| Vitest | 16 test suites (180 unit and integration tests passing) |
| Vercel | Serverless edge deployment with automatic CI/CD pipelines |
The production Supabase PostgreSQL database includes 44 base tables, 9 views, and 10 atomic PL/pgSQL functions:
- Fleet Management:
buses,routes,route_stops,stops,campuses,transit_zones,shifts. - Operations & Attendance:
trips,bus_reservations,seat_attendance,attendance_records,attendance_reconciliation_runs. - Fleet Orchestration:
bus_merge_points,bus_merge_suggestions,dispatch_configs. - People & Academic Hierarchy:
users,students,staff,classes,academic_branches,academic_courses. - Financial & Billing:
subscription_plans,subscriptions,payment_submissions. - Audit & Telematics:
audit_logs,notifications,vehicle_issues,system_configs.
CampusFleet/
βββ platform/ # Main Next.js Full-Stack Web Platform (this repo)
β βββ src/
β β βββ app/ # Next.js 14 App Router routes
β β β βββ portal/ # Student & Parent Cockpit (Radar, Pass, Payments)
β β β βββ driver/ # Driver In-Cabin Console (GPS Telematics, Incidents)
β β β βββ conductor/ # Conductor Console (Camera Scanner, Passenger Manifest)
β β β βββ transport-manager/ # Transport Manager (Combine Buses, Trips, Demand)
β β β βββ transport-admin/ # Transport Admin (Routes, Corridors, RFID, ESP32, Billing)
β β β βββ teacher/ # Teacher Panel (Student Arrivals, Commute, Gate Passes)
β β β βββ chat/ # Campus Group Chat & Live Polls
β β β βββ api/ # 31 REST API route groups
β β βββ components/ # Reusable modular UI components
β β β βββ common/BusLoadingScreen.tsx # Creative Cartoonish Blue Loading Screen Bus
β β β βββ chat/ChatPortalView.tsx # Chat thread with interactive poll widgets
β β β βββ transport-manager/ # Combine Buses & Fleet Orchestration Views
β β β βββ ...
β β βββ lib/ # Domain services, algorithms, and DB clients
β β βββ route-optimizer.ts # 6 Graph Algorithms + Clarke-Wright Heuristics
β β βββ reservation-engine.ts # Seat booking & concurrency controls
β β βββ chat-mongodb.ts # MongoDB + Upstash Redis cache-aside
β β βββ types.ts # Unified TypeScript entity interfaces
β βββ docs/screenshots/ # High-resolution application screenshots
β
βββ esp32-rfid-terminal/ # Dedicated IoT Firmware Repository
βββ src/main.cpp # C++ firmware with auto-MAC & 20s Redis heartbeat
βββ platformio.ini # PlatformIO configuration
βββ README.md # Hardware wiring diagram (ESP32 β RC522)
git clone https://github.com/CampusFleet/platform.git
cd platformnpm installcp .env.example .env.localProvide your Supabase URL, service role key, Razorpay credentials, and Upstash Redis tokens.
npm testExecutes all 16 test suites covering route optimization, seat locking, payments, telematics, and rollover.
npm run devOpen http://localhost:3000 to access the CampusFleet Gateway.
- Gateway (
/): Select your role (Student, Driver, Conductor, Transport Admin, Transport Manager, Teacher). - Student Dashboard (
/portal): View live assigned bus, Metro-style station progression, and ETA countdown. - RedBus 2Γ2 Seat Map: Select an available seat with visual seat layout and atomic distributed concurrency locking.
- Digital Pass (
/portal/qr): View the rotating anti-fraud QR ticket with physical seat number. - Fee Payment (
/portal/payments): Checkout semester pass through Razorpay sandbox or upload receipt. - Campus Chat & Polls (
/chat): Join the verified campus group, create a poll, and cast a vote. - Driver Console (
/driver): Start trip, broadcast live 15s GPS coordinates, and view route halts. - Conductor Scanner (
/conductor): Verify student QR codes with real-time geofence validation and locked KYC photos. - Combine Buses (
/transport-manager/combine-buses): Reconcile morning attendance actuals, view auto-detected bus disassemblies, stitch sparse routes, and execute 1-click Auto-Pilot. - Transport Admin (
/transport-admin): Manage corridors on interactive Leaflet maps, pair ESP32 telematics MAC addresses, and issue student RFID cards.
| Member | Focus Area |
|---|---|
| Aditya Pandey | Lead Architect, Full-Stack Next.js 14, & Routing Algorithms |
| Harsh Kumar | Database Architecture, Supabase PostgreSQL, & PL/pgSQL Atomic RPCs |
| Kartik Bisht | Frontend UX/UI, Mobile PWA, & Responsive Styling |
| Gaurang Joshi | Embedded IoT Hardware, ESP32 Telematics, & Quality Assurance |
- Project Guide: Prof. Rahul
- Institution: Graphic Era Hill University (GEHU), Bhimtal Campus
- Live System: https://campusfleet.vercel.app










