Inspiration

Late-night walks shouldn't feel like a risk calculation. But for millions of women, they are. We asked ourselves: what if your navigation app knew that the shortcut through the underpass is fine at 3 PM but dangerous at 11 PM — and told you why, not just flagged it red?

Every safety app we looked at treated risk as static. A bad area is a bad area, any time of day. That felt wrong. Crime, harassment, and poor lighting don't operate on a fixed schedule. SafeRoute was born from one question: what does a route actually feel like after dark?

What it does

SafeRoute is a real-time women's safety navigator built for urban India. Users can:

  • Report incidents (poor lighting, isolated areas, harassment history) directly on the map — contributing to a live, crowd-sourced safety layer
  • Get a colour-coded route (green → amber → red) scored 0–100 based on nearby incidents weighted by type and proximity
  • Adjust a time-of-day slider and watch the heatmap and risk score change — the same route scores differently at 2 PM vs 11 PM
  • Read a Gemini AI safety summary that doesn't just score but explains: "This route passes 2 poorly lit areas reported after 9 PM. Consider the main road instead."
  • Send an SOS with one tap — opens WhatsApp pre-filled with live GPS coordinates, no third-party API required

How we built it

We kept the architecture deliberately lean: a React + Vite frontend talking directly to three services — Firebase Firestore for real-time incident data, Google Maps JS API for routing and heatmap visualisation, and Gemini 1.5 Flash for AI safety summaries.

The core innovation is the time-aware risk scoring engine. Each reported incident carries a base weight by type (harassment history = 3, poor lighting = 2, isolated = 1) and a night multiplier that activates between 9 PM and 6 AM. Route waypoints are sampled every ~100 m and scored via Haversine distance against all nearby incidents. The aggregate score drives both the polyline colour segmentation and the Gemini prompt.

The entire backend is Firebase — no server, no Cloud Functions. Firestore's onSnapshot listener means a new incident reported by one user is visible to everyone within seconds.

Challenges we ran into

Polyline segmentation was harder than expected. Google Maps returns a single encoded polyline — splitting it into individually coloured segments required decoding, grouping waypoints into chunks, scoring each chunk, and rendering ~20 separate Polyline components with individual strokeColor props. Getting smooth colour transitions without visual gaps took real iteration.

Prompt engineering for Gemini needed careful tuning. Early responses were either too alarmist ("AVOID THIS ROUTE") or too vague to be useful. We landed on a system prompt that explicitly constrains tone: specific, helpful, not alarmist — and the difference was immediately noticeable in the output quality.

Time-aware heatmap weighting required us to separate the display weight (for HeatmapLayer intensity) from the scoring weight (for the risk formula) since both needed to respond to the slider without re-fetching Firestore data.

What we learned

  • Gemini Flash is genuinely fast and capable enough for real-world safety summaries on free-tier quotas — the latency was under 2 seconds in every test
  • Firebase Anonymous Auth eliminates the single biggest UX friction point in safety apps: account creation when someone just needs directions
  • The WhatsApp deep link (wa.me/?text=...) is the most underrated emergency feature in the developer toolkit — zero infrastructure, works globally, opens natively

What's next for SafeRoute

  • Community verification — let users upvote/downvote incidents to filter stale data
  • Police station and hospital overlay — nearest safe destinations on the route
  • Route comparison — show two routes side by side with AI explaining the trade-off
  • Offline mode — cache the last known heatmap so the app works in low-connectivity areas
  • Vernacular support — Gemini summaries in Hindi for broader adoption across India

Built With

  • deeplink
  • firebase-anonymous-auth
  • firebase-firestore
  • firebase-hosting
  • gemini-1.5-flash
  • google-maps-directions-api
  • google-maps-heatmaplayer
  • google-maps-javascript-api
  • javascript
  • react
  • tailwind-css
  • vite
  • web-geolocation-api
  • whatsapp
Share this project:

Updates