Walking safety app for York Region. Get three route options with safety scores based on real crime data, street lighting, and nearby safe spaces.
Built for YorkUHacks.
git clone https://github.com/KIRTIRAJ4327/yorkuhacks.git
cd yorkuhacks
flutter pub get
flutter run -d chromeAdd API keys for enhanced functionality:
flutter run -d chrome \
--dart-define=GEMINI_API_KEY=your_gemini_key \
--dart-define=GOOGLE_PLACES_API_KEY=your_places_key- Gemini API: AI route summaries and safety chat. Get free key at https://aistudio.google.com/apikey
- Google Places API: Real-time safe spaces with opening hours (24/7 or currently open). Get key at https://console.cloud.google.com/
Without API keys, the app uses fallback sample data for demonstration.
- Three route options: fastest, balanced, and safest
- Safety scores (0-100) based on crime data, lighting, and safe spaces
- Turn-by-turn navigation with safety alerts
- Chat with AI about area safety
- SOS emergency button
- Dark theme optimized for night use
Flutter, Riverpod, flutter_map (OpenStreetMap), OSRM routing, Gemini AI, York Region ArcGIS data, Hive for caching.
lib/
├── main.dart # App entry point
├── app.dart # Routing config (go_router)
│
├── core/
│ ├── theme/ # Colors, dark/light themes
│ ├── constants.dart # API URLs, scoring weights
│ └── utils/ # Geo calculations, formatting
│
├── data/
│ ├── models/ # Data classes (routes, crime, etc)
│ ├── repositories/ # API clients (OSRM, Nominatim, ArcGIS)
│ └── local/cache_service.dart # Hive offline cache
│
├── domain/
│ ├── safety_scorer.dart # Core algorithm: calculates 0-100 score
│ ├── route_service.dart # Orchestrates 3-route generation
│ ├── gemini_service.dart # AI summaries + chat
│ ├── navigation_engine.dart # Turn-by-turn logic
│ └── alert_engine.dart # Safety warnings
│
├── providers/ # Riverpod state (location, routes, nav, chat)
│
└── presentation/
├── screens/
│ ├── home_screen.dart # Map + search
│ ├── route_selection_screen.dart # 3 swipeable route cards
│ ├── navigation_screen.dart # Active turn-by-turn
│ ├── safety_chat_screen.dart # AI assistant chat
│ └── arrival_screen.dart # Journey stats
│
└── widgets/
├── map/safety_map.dart # Dark map with colored routes
├── route/route_card.dart # Swipeable card + safety gauge
├── navigation/sos_button.dart # Emergency button
└── ai/chat_bubble.dart # Chat messages
The brain of the app. Takes a route and calculates a 0-100 score using:
- 40% Crime density (counts crimes within 100m of route)
- 25% Street lighting coverage
- 15% Traffic collisions
- 10% Distance to safe spaces (police, hospitals)
- 10% Sidewalk infrastructure
Workflow:
- Gets 3+ routes from OSRM
- Fetches safety data (crime, lights, safe spaces) for the area
- Scores each route with
SafetyScorer - Classifies routes as fastest/balanced/safest
- Sends each route to Gemini for AI summary
- Returns 3 routes to UI
Riverpod state management:
location_provider.dart— GPS trackingroute_provider.dart— Route search + selectionnavigation_provider.dart— Active navigation stategemini_provider.dart— AI chat messagestheme_provider.dart— Dark/light mode
Splash → Home (map + search)
↓
User enters destination
↓
Route Selection (3 cards)
↓
User taps "Start Navigation"
↓
Navigation (turn-by-turn)
↓
Arrival (stats + AI feedback)
Can also go to: AI Chat (safety questions) from Home screen.
- Routes: OSRM public server (walking mode)
- Geocoding: Nominatim (OpenStreetMap)
- Crime Data: York Region ArcGIS + sample data (API endpoints need discovery)
- Street Lighting: York Region Open Data + sample data
- Safe Spaces: Google Places API (police, hospitals, fire stations, 24/7 pharmacies)
- Real-time opening hours — only shows places that are 24/7 or currently open
- Phone numbers for emergency calls
- Falls back to sample data if no API key provided
Routes get a 0-100 score:
- 80-100 = Very Safe (green)
- 60-79 = Moderate (yellow)
- 40-59 = Caution (orange)
- 0-39 = Higher Risk (red)
Route segments on the map are color-coded by their individual safety scores.
- Kirti (@KIRTIRAJ4327)
- DJ
- Yeshi
- Tarun
MIT
Made with ❤️ for York Region