Skip to content

piercebrookins/hoosride

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚌 HoosRide - CS 4710 Final Project

iOS Swift

Smart transit for UVA. Real-time bus tracking with ML-powered arrival predictions.

HoosRide is an iOS app that helps University of Virginia students and staff navigate the UVA transit system with live bus locations, intelligent trip planning, and machine learning-based arrival time predictions.


✨ Features

πŸ—ΊοΈ Live Transit Map

  • Real-time bus locations on all UVA routes
  • Color-coded routes (Orange, Gold, Green, Purple, Silver + Health shuttles)
  • Live vehicle positions with heading and load indicators
  • Route filtering and nearest-bus detection
  • Tap stops to see serving routes; tap vehicles for details

🧭 Smart Trip Planner

  • Location-aware routing with Apple Maps integration
  • 25+ curated UVA destination aliases (type "JPJ", "O-Hill", "Barracks", etc.)
  • Optimized route selection using live vehicle positions
  • Walking + transit combined itineraries
  • Route explanation badges β€” tells you why a route was chosen
  • Confidence indicators based on active bus count and ML predictions

πŸ€– ML-Powered Predictions

  • CoreML Gradient Boosted Tree model trained on UVA transit data
  • Adaptive delay corrections with calibrated confidence scoring
  • On-device observation collection for model improvement
  • Transparent source tracking (CoreML vs heuristic fallback)

πŸ“Ά Resilient Data Handling

  • Offline / degraded mode with connection state tracking
  • Stale data indicators with automatic retry
  • JSON-based master route data with hardcoded fallback
  • Graceful failure: static routes shown when API is unreachable

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          iOS App (Swift 6)                       β”‚
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   SwiftUI Views  β”‚  β”‚ MapKit Map   β”‚  β”‚ CoreML Predictor  β”‚  β”‚
β”‚  β”‚  ContentView     β”‚  β”‚ TransitMap   β”‚  β”‚ MLArrivalPredict. β”‚  β”‚
β”‚  β”‚  TripPlannerView β”‚  β”‚ MapViewModel β”‚  β”‚ ArrivalPredictor  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
β”‚                          β”‚                                       β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                           β”‚
β”‚              β”‚    Routing Engine     β”‚                           β”‚
β”‚              β”‚  Trip planning +      β”‚                           β”‚
β”‚              β”‚  route scoring +      β”‚                           β”‚
β”‚              β”‚  vehicle ETA calc     β”‚                           β”‚
β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β”‚
β”‚                          β”‚                                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Location β”‚  β”‚ TranslocService β”‚  β”‚   MasterDataLoader   β”‚   β”‚
β”‚  β”‚ Manager  β”‚  β”‚  (API client)   β”‚  β”‚ (JSON β†’ Swift models)β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                  TransLoc REST API
                  (real-time data)

πŸš€ Getting Started

Requirements

Tool Version
Xcode 16.0+
iOS 17.0+
Swift 6.0

Quick Start

# Open in Xcode
open HoosRide.xcodeproj

# Build & Run (⌘+R) β€” targets iPhone simulator
# No API keys needed β€” TransLoc API is public for UVA

Running Tests

# Run all unit tests (32 tests)
xcodebuild -project HoosRide.xcodeproj -scheme HoosRide \
  -destination 'platform=iOS Simulator,name=iPhone 17 Pro' test

# Or press ⌘+U in Xcode

Simulator Location

For best results, set the simulator location to UVA:

  1. In Simulator: Features β†’ Location β†’ Custom Location
  2. Latitude: 38.0356, Longitude: -78.5034

πŸ“± Project Structure

HoosRide/
β”œβ”€β”€ HoosRide/
β”‚   β”œβ”€β”€ HoosRideApp.swift              # App entry point
β”‚   β”‚
β”‚   β”œβ”€β”€ # Views
β”‚   β”œβ”€β”€ ContentView.swift              # Trip planner UI + view model
β”‚   β”œβ”€β”€ MapView.swift                  # Live transit map + MapViewModel
β”‚   β”œβ”€β”€ TripStepRow.swift              # Individual trip step rendering
β”‚   β”œβ”€β”€ RouteExplanationBadge.swift    # Why-this-route explanation
β”‚   β”œβ”€β”€ ConnectionStatusBanner.swift   # Offline/stale data indicator
β”‚   β”œβ”€β”€ SettingsView.swift             # App settings
β”‚   β”‚
β”‚   β”œβ”€β”€ # Routing & Planning
β”‚   β”œβ”€β”€ RoutingEngine.swift            # Route optimization + scoring
β”‚   β”œβ”€β”€ PlannedTrip.swift              # Trip model + RouteChoiceReason
β”‚   β”œβ”€β”€ TripStep.swift                 # Walk/ride/transfer/arrival steps
β”‚   β”‚
β”‚   β”œβ”€β”€ # Data & Services
β”‚   β”œβ”€β”€ TranslocService.swift          # TransLoc API client
β”‚   β”œβ”€β”€ MasterData.swift               # Route/stop canonical data
β”‚   β”œβ”€β”€ master_routes.json             # JSON route configuration
β”‚   β”œβ”€β”€ UVADestinations.swift          # 25+ curated campus aliases
β”‚   β”œβ”€β”€ LocationSearchService.swift    # Apple Maps search integration
β”‚   β”œβ”€β”€ LocationManager.swift          # GPS/location handling
β”‚   β”œβ”€β”€ GeocodingService.swift         # Address β†’ coordinate
β”‚   β”œβ”€β”€ GeoUtilities.swift             # Distance, formatting helpers
β”‚   β”‚
β”‚   β”œβ”€β”€ # ML & Prediction
β”‚   β”œβ”€β”€ MLArrivalPredictor.swift       # CoreML model wrapper
β”‚   β”œβ”€β”€ ArrivalPredictor.swift         # Prediction orchestration
β”‚   β”œβ”€β”€ ObservationCollector.swift     # On-device learning data
β”‚   β”‚
β”‚   β”œβ”€β”€ # Models
β”‚   β”œβ”€β”€ TransitModels.swift            # PlaceResult, BusRoute, RouteCandidate
β”‚   β”œβ”€β”€ TransitSnapshot.swift          # Immutable transit state snapshot
β”‚   β”œβ”€β”€ TransitStop.swift              # Stop model
β”‚   └── BusVehicle.swift               # Vehicle model
β”‚
└── HoosRideTests/
    └── HoosRideTests.swift            # 32 unit tests

πŸ€– On-Device ML

Current Model Performance

Metric Value
MAE 1.76 min
RΒ² 0.55
vs Heuristic 50% better

The trained CoreML model (BusArrivalPredictor.mlpackage) ships bundled in the Xcode project β€” Xcode picks it up automatically at build time. No external toolchain required to build the app.

What's ML vs Heuristic

Component Source
Wait time estimation ML (CoreML) when vehicles present; heuristic fallback
Delay adjustment ML with 50% blending weight
Confidence scoring Calibrated weighted factors
Ride time Segment-based heuristic
Walking time Distance / speed constant

πŸ“Š UVA Routes

Student Routes

Route Color Area
Orange 🟠 JPA ↔ Madison Ave ↔ Stadium
Gold 🟑 Hereford ↔ North Grounds ↔ Barracks Rd
Green 🟒 Hereford ↔ Rugby Rd ↔ Grady Ave
Purple 🟣 Fontaine Research Park ↔ Medical Center
Silver βšͺ JPJ ↔ Emmet St ↔ JPA ↔ North Grounds

Health Shuttles

Route Description
Fontaine Shuttle Medical Center ↔ Fontaine Research Park
Health Stadium Medical Center ↔ Scott Stadium

πŸ”§ Key Design Decisions

  1. JSON + Hardcoded Fallback for master route data β€” JSON loads first, hardcoded Swift data serves as safety net
  2. Observation pattern (@Observable) over ObservableObject β€” cleaner SwiftUI integration, no @Published boilerplate
  3. Immutable TransitSnapshot for thread-safe routing β€” snapshot is built once per refresh cycle
  4. Walking effort multiplier (1.6Γ—) β€” a 12-min bus ride beats an 8-min walk because riding is less effort
  5. ML blending at 50% β€” positional ETA as base, ML delay layered on top to avoid overcorrection
  6. Degraded mode over crashes β€” always show something (static routes) rather than empty screen

πŸ”Œ API

HoosRide uses the TransLoc v1 API (no key required for UVA):

Endpoint Purpose
/v1/vehicle_statuses Live bus positions
/v1/arrivals ETA predictions
/v1/routes Route metadata

πŸ§ͺ Test Coverage

32 tests across 4 test suites:

  • RoutingEngineTests (15): Walk vs bus, stop matching, route preference, edge cases, delayed vehicles
  • TransitModelTests (4): PlaceResult detection, route segments, vehicle equality, walking speeds
  • GeoUtilitiesTests (6): Distance, heading, formatting
  • MLPredictorTests (3): Prediction validity, rush hour detection, ETA adjustment

πŸ“ Known Limitations

  • Route data requires app update if UVA changes routes (JSON helps but still bundled)
  • ETA confidence drops significantly when no active vehicles are tracked
  • ML model trained primarily on synthetic data β€” real-world accuracy improves with observation collection
  • Single-seat trips only β€” no transfer routing between different bus lines
  • Walking time estimates use straight-line distance (no sidewalk routing)

πŸ“„ License

MIT License β€” see LICENSE for details.


Built for UVA students who wait at bus stops. πŸ§‘πŸ’™

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages