Your bus is 3 minutes away. We checked.
Real-time school bus tracking with live GPS, per-stop ETA, geofenced polylines,
and push notifications β built entirely in Kotlin with Jetpack Compose.
Every parent and student has asked the same question: "Where is the bus?"
Current solutions are either:
- π Phone calls β "Driver, where are you?" (annoying for everyone)
- π WhatsApp location sharing β unreliable, battery-draining, no ETA
- π° Commercial fleet trackers β expensive, designed for logistics companies, not schools
NextStop is purpose-built for schools. Students see their bus on a live map, get a per-stop ETA, and receive a push notification when the bus is approaching their stop. Admins manage the entire fleet β routes, buses, drivers, stops β from a single dashboard.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NextStop System β
β β
β βββββββββββββββββββββββ β
β β DRIVER APP β β
β β Foreground Service β β
β β βββ FusedLocation βββββ GPS ping every 4s βββββ β
β β β (HIGH_ACCURACY)β β β
β β βββ Speed filter β βΌ β
β β β (>0.5 m/s) β βββββββββββββββββββββ β
β β βββ Bearing data β β Firebase Realtime β β
β βββββββββββββββββββββββ β Database β β
β β /live/{busId} β β
β β βββ latitude β β
β βββββββββββββββββββββ β βββ longitude β β
β β STUDENT APP ββββββ Live βββββ βββ speed β β
β β β listener β βββ bearing β β
β β βββ Google Map β β βββ timestamp β β
β β β with route β β βββ active β β
β β β polyline β βββββββββββββββββββββ β
β β β β β
β β βββ Per-stop ETA β Haversine distance Γ· current speed β
β β β computation β = minutes to each stop β
β β β β β
β β βββ Proximity β If ETA < 5 min for assigned stop β
β β β notification β β Firebase Cloud Messaging push β
β β β β β
β β βββ Stop progressβ Animated progress bar with bus icon β
β β bar β tracking across the route β
β βββββββββββββββββββββ β
β β
β ββββββββββββββββββββββ ββββββββββββββββββββ β
β β ADMIN DASHBOARD β β Cloud Firestore β β
β β βββββββββββββββΊβ β β
β β βββ Manage Buses β β /buses β β
β β βββ Manage Routes β β /routes β β
β β βββ Assign Driversβ β /users β β
β β βββ CRUD Stops β β /assignments β β
β β βββ Fleet tracker β ββββββββββββββββββββ β
β ββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Real-time bus position on a Google Map with custom bus marker icon
- Location updates every 4 seconds via
FusedLocationProviderClientatPRIORITY_HIGH_ACCURACY - Location freshness indicator: "β Live" (green), "β 3 min ago" (yellow), "β Offline" (red) β students always know how fresh the data is
- Per-stop ETA computation: Haversine distance from bus coordinates to each stop, divided by current GPS speed
- Boarding stop ETA: Personalized "Arrives at your stop in 4 min" β not a generic fleet-wide estimate
- Edge case handling: "Calculating...", "Bus has already passed", "Bus is far away"
- Set your personal boarding stop using Google Places Autocomplete (restricted to India)
- Toggle proximity notifications β get a push when the bus is approaching your stop
- Stop assignments persist in Firestore β works across app restarts
- Google Directions API polylines: Road-snapped route paths (not naive straight lines between stops)
- Geofenced stop progression: "Passed" stops dim into gray, "Next" stop highlights in primary color
- Animated progress bar: Bus icon slides across a stop-by-stop progress track with smooth
animateFloatAsStatetransitions - Bottom sheet map: BottomSheetScaffold with draggable stop list + map overlay
- To College / To Home / All Scheduled β filter buses by trip direction
- Only shows buses that pass through your boarding stop (unless viewing "All Scheduled")
- Buses: Create, edit, assign numbers and types
- Routes: Define routes with ordered stops, departure times, assigned buses
- Stops: Add stops via Google Places Autocomplete with lat/lng auto-fill, reorder with drag handles
- Drivers: Assign drivers to buses, manage authentication and roster
- Mirror any active route on the admin dashboard β see exactly what students see
- Fleet-wide overview of which buses are active, inactive, or offline
| Layer | Technology | Why This Choice |
|---|---|---|
| UI | Jetpack Compose + Material 3 | Declarative UI with BottomSheetScaffold, AnimatedContent |
| Language | Kotlin 2.0 | Coroutines, StateFlow, type-safe throughout |
| Architecture | MVVM + StateFlow + Dagger Hilt DI |
Clean separation, testable, injectable |
| Auth | Firebase Auth | Role-based: Student / Driver / Admin |
| Metadata DB | Cloud Firestore | Routes, buses, stops, users, assignments |
| Realtime DB | Firebase Realtime Database | Live GPS coordinates β low latency, high write throughput |
| Maps | Google Maps SDK (Compose) | Vector overlays, Polylines, Markers, Camera animations |
| Places | Google Places API (New) | Autocomplete restricted to IN region for stop selection |
| Directions | Google Directions API | Road-snapped polyline computation between stops |
| Location | FusedLocationProviderClient | High-accuracy GPS with configurable intervals |
| Foreground Service | LocationForegroundService + Binder | Persistent tracking that survives app backgrounding |
| Notifications | Firebase Cloud Messaging | Per-stop proximity push alerts |
NextStop/
βββ app/src/main/java/com/yourteam/nextstop/
β βββ data/repository/
β β βββ AdminRepository.kt # Fleet CRUD operations
β β βββ AuthRepository.kt # Firebase Auth + role detection
β β βββ DriverRepository.kt # Live location writes to RTDB
β β βββ StudentRepository.kt # Stop assignments, bus tracking
β β
β βββ di/
β β βββ AppModule.kt # Dagger Hilt module β Firebase, Maps
β β
β βββ models/
β β βββ Bus.kt, Route.kt, User.kt # Domain models
β β βββ LiveLocation.kt # RTDB GPS data class
β β βββ TripState.kt # Sealed class: Running | Stopped
β β βββ CollegeLocation.kt # Campus coordinates
β β
β βββ service/
β β βββ LocationForegroundService.kt # GPS tracking service (4s interval)
β β βββ ProximityNotificationService.kt # FCM push notification handler
β β
β βββ ui/
β β βββ student/
β β β βββ StudentHomeScreen.kt # Fleet dashboard with direction toggle
β β β βββ StudentViewModel.kt # Live bus tracking, ETA computation
β β β βββ HomeStopSetupScreen.kt # Boarding stop selection
β β βββ driver/
β β β βββ DriverHomeScreen.kt # Trip start/stop with speed display
β β β βββ DriverViewModel.kt # Foreground service binding
β β βββ admin/
β β β βββ AdminHomeScreen.kt # Tab layout: Dashboard, Manage, Assign
β β β βββ AdminDashboardTab.kt # Live fleet overview
β β β βββ AdminManageTab.kt # Buses, Routes, Stops CRUD
β β β βββ AdminViewModel.kt # Fleet management state
β β βββ auth/
β β β βββ LoginScreen.kt # Email/password + role selection
β β β βββ AuthViewModel.kt # Auth state machine
β β βββ components/
β β βββ TrackingComponents.kt # SharedTrackerScreen, BusTrackingMap, StopProgressBar
β β βββ CustomPlacesSearchField.kt # Google Places autocomplete widget
β β βββ ShimmerSkeleton.kt # Loading skeleton components
β β βββ NextStopTopBar.kt # Reusable top app bar
β β
β βββ util/
β β βββ LocationUtils.kt # Haversine, ETA, vector bitmap helpers
β β βββ DirectionsFetcher.kt # Google Directions API polyline decoder
β β
β βββ navigation/
β βββ AppNavigation.kt # Role-based navigation graph
β βββ NavRoutes.kt # Route definitions
β
βββ google-services.json # Firebase config (gitignored)
βββ build.gradle.kts
- Android Studio Ladybug+ Β· Kotlin 2.0
- Firebase project (Auth + Firestore + Realtime Database)
- Google Cloud project with Maps SDK, Places API, Directions API enabled
- Clone the repo
- Place
google-services.jsoninapp/ - Add your Maps API key to
local.properties:MAPS_API_KEY=YOUR_GOOGLE_MAPS_API_KEY - Sync Gradle and run on your device
| Collection/Path | Purpose |
|---|---|
users/{uid} |
User profile with role (student/driver/admin) |
buses/{busId} |
Bus metadata (number, type, capacity) |
routes/{routeId} |
Route with ordered stops, departure time, assigned bus |
assignments/{id} |
Driver β Bus β Route assignments |
live/{busId} (RTDB) |
Real-time GPS coordinates (4s updates) |
Never ask "where is the bus?" again.
Real-time tracking, built for schools, powered by Kotlin.
Made with β€οΈ by Shashank Salapur