SafarSaheli - Project Story

🌸 Inspiration

Walking alone at night, taking an unfamiliar route, wondering if this street is safe - this is not a hypothetical for millions of women in India. It is Tuesday. It is the commute home.

India records over 4.5 lakh crimes against women every year. That is 1,200 cases every single day. 50 cases every hour. Most of them happen in transit - on roads, in autos, near metro stations, in the gap between "I just left" and "I'm almost home."

And yet - not a single navigation app in the world asks the one question that matters most to a woman stepping out alone:

"Is this route safe?"

Google Maps will show you the fastest route. It will not tell you if that route passes through a high-crime area. It will not alert your family if something goes wrong. And it definitely will not be there at 10 PM when you just need to know - am I going to be okay?

That gap is why we built SafarSaheli.


🛠️ What We Built

SafarSaheli is an AI-powered women's safety PWA - runs directly in the browser, no app install needed, works on any Android phone.

Six features. One mission - keep women safe.

  • 🏠 Home Dashboard - Central safety hub with one-tap access to all features. SOS is always red, always visible, always one tap away. That design decision was intentional.

  • 🛡️ Safety Routes - Enter start and destination. Our ML model fetches multiple route options and scores each one for safety using real Delhi crime data. Green is safe. Yellow is caution. Red we suggest you go a different way. You're not just picking a route. You're making an informed decision.

  • 📍 Safety & Hygiene - Instantly find the nearest hospitals, police stations, pharmacies, washrooms and metro stations within 2km. Each result shows exact distance and one-tap Google Maps navigation. Two taps from feeling unsafe to having help on the way.

  • 🆘 SOS Alert - One tap. Three-second countdown to prevent accidental triggers. Then your live GPS location is sent to your emergency contact via WhatsApp, pre-filled message, Google Maps link, ready to send. No third-party service. No monthly fee. Works on every phone, every network, every time.

  • 🗺️ Trip Planner - AI-generated women-friendly travel itineraries powered by Gemini. Input your destination, duration and preferences. Get a day-by-day plan that prioritizes safe areas, well-lit routes, verified stays and crowd-appropriate timings.

  • 💬 Saheli - Your 24/7 AI safety companion. Powered by Google Gemini with a custom safety-focused system prompt. She knows your city. She knows the time of day. She is tuned specifically for women's safety in India, not a general chatbot repurposed, but a companion built with empathy.


🎯 UN Sustainable Development Goals

SafarSaheli directly addresses three UN SDGs:

SDG 5 — Gender Equality

"Achieve gender equality and empower all women and girls"

Safe mobility is a prerequisite for gender equality. When women cannot move freely — to work, to college, to hospitals — every other opportunity closes. SafarSaheli removes the fear barrier that keeps millions of Indian women from solo travel and essential trips.

SDG 3 — Good Health & Well-Being

"Ensure healthy lives and promote well-being for all"

The Safety & Hygiene feature gives women instant access to the nearest verified hospitals, pharmacies and clean washrooms within 2km — critical in emergencies and for everyday health needs in unfamiliar areas.

SDG 11 — Sustainable Cities & Communities

"Make cities inclusive, safe, resilient and sustainable"

Cities are only truly inclusive when all residents can navigate them safely. SafarSaheli's crime-data-powered route scoring contributes to making urban spaces safer and more accessible for women — one route at a time.


🧠 How We Built It

Frontend

React + Vite + TailwindCSS + MapLibre GL JS - deployed as a Progressive Web App. Mobile-first design with 44px touch targets, bottom navigation bar, and safe area support for notched screens. No app store. No install friction.

Backend

FastAPI (Python) hosted on Render. On startup, the server loads the crime dataset and trains the KMeans model in memory. The /safest-route endpoint receives start and end coordinates, fetches routes from Geoapify, runs them through the ML scoring engine, and returns ranked results with safety scores - all in real time.

The ML Model - Where The Real Work Happened

This is the core of SafarSaheli — and the part we are most proud of.

Step 1 — The Data

We sourced real Delhi Police crime data covering 167 districts across 8 crime categories: Murder, Rape, Gang Rape, Robbery, Theft, Assault, Sexual Harassment, and Crime Density (crimes per square km).

Raw data is not enough. The model needed to understand that not all crimes carry equal weight for a woman's physical safety.

Step 2 - Weighted Risk Scoring

Before clustering, every district gets a weighted risk score:

Crime Type Weight Reason
Murder 10 Highest physical threat
Gang Rape 10 Highest physical threat
Rape 8 Severe violent crime
Assault 6 Direct physical threat
Sexual Harassment 5 High relevance to women's safety
Robbery 4 Physical threat involved
Theft 1 Property crime, not physical
Crime Density 3 Overall area risk indicator

We are not optimizing for property safety. We are optimizing for physical safety. That philosophy is baked into the math itself.

Step 3 - KMeans Clustering

We trained a KMeans clustering model on these weighted district scores. Using the elbow method to find optimal K, the algorithm naturally grouped Delhi's 167 districts into 6 distinct danger tiers

  • from relatively safe to high risk.

Why KMeans and not a neural network?

Because interpretability matters. We can explain to any user exactly which danger tier their route passes through and why. A black box model that cannot explain its decisions has no place in a safety tool that women are trusting with their lives.

Step 4 - Route Safety Scoring

When a user enters start and destination:

  1. Geoapify Routing API fetches up to 3 genuinely different routes (fastest, shortest, balanced) - deduplicated to ensure they actually take different paths, not variations of the same road.

  2. For each route, we sample up to 50 evenly-spaced GPS coordinates. Evenly spaced not random so no stretch of the route is missed.

  3. For every sampled point, we check proximity to every crime district within a 5km radius using the Haversine formula — the geometrically correct way to measure distance on a curved Earth, not a flat-map approximation.

  4. Proximity penalty uses inverse distance weighting:

$$ \text{Weight} = \frac{1}{1 + d} $$

Where \( d \) is distance in km. A crime cluster 0.5km away hits significantly harder than one 4km away.

  1. The final safety score is computed across three dimensions — because a simple average would let a few safe stretches mask one genuinely dangerous section:

$$ \text{Combined Risk} = 0.4 \times \bar{r} + 0.3 \times r_{max} + 0.3 \times f $$

Where:

  • \( \bar{r} \) = average severity at risky points (how bad are the bad areas?)
  • \( r_{max} \) = worst single hotspot on the route (worst-case penalty)
  • \( f \) = fraction of route passing through risky zones

$$ \text{Safety Score} = (1 - \text{Combined Risk}) \times 100 $$

Zero to 100. Higher is safer.

The highest-scoring route is recommended. But the user also sees all alternatives ranked — so they can make their own informed trade-off between safety and speed. We give the information. She makes the call.

Maps & Search

MapLibre GL JS for map rendering. Geoapify API for autocomplete search, route fetching, and nearest place discovery within 2km radius. Autocomplete uses AbortController with 300ms debounce to prevent race conditions on fast typing.

AI Features

Google Gemini API powers both Saheli chatbot and Trip Planner. Saheli's system prompt is custom-built for women's safety context in India — injected with user's city and current time of day for context-aware responses.

SOS Delivery

WhatsApp wa.me deep link with pre-filled location message. Zero third-party dependency. Works on any phone, any network, any time. Files (photo, audio) save locally to the user's device — nothing uploaded to any server. The user is in full control of her data.


⚡ Challenges We Faced

1. The crime data problem Delhi's crime data was inconsistent — varying formats across districts, missing coordinates, overlapping region boundaries, ambiguous category names. Cleaning 167 crime zones into a format the KMeans model could train on took longer than building the model itself. Real data is always messier than demo data.

2. Weighting philosophy The hardest non-technical decision was how to weight the crime types. We debated this for hours. A theft-heavy route and a rape-heavy route should not score the same — but how much different? Getting the weights wrong would mean recommending routes that felt safe statistically but weren't actually safe for women. We landed on severity-proportional weights anchored to physical threat level — not academic literature, but our own reasoned judgment about what women actually fear.

3. Search autocomplete race conditions When users typed fast, multiple API calls resolved out of order — older results overwrote newer ones, the dropdown flickered and disappeared mid-typing. Fixed with AbortController to cancel in-flight requests before each new one, and 300ms debounce to prevent call floods. Classic async JavaScript problem with a clean solution.

4. Vercel vs FastAPI Vercel is serverless. FastAPI is not. Our ML model needs to load on startup and persist in memory between requests — impossible on serverless functions which spin up and down. Moved backend to Render, wired VITE_BACKEND_URL environment variable in Vercel, added CORS for the production domain. Classic "works on localhost" moment that cost us three hours.

5. SOS that actually works for free Twilio looked perfect on paper — until we saw the pricing. A women's safety tool that costs money to send an emergency alert is not a women's safety tool. We rebuilt SOS using WhatsApp's wa.me deep link with pre-filled location message. Zero cost. Zero dependency. Works on every phone. Sometimes the constraint produces the better solution.

6. Data sourcing for production The current crime dataset is a publicly available research dataset. For production, we need official, continuously updated data. Our strategy: RTI filings with Delhi Police, collaboration with NGOs who already collect ground-level crime data (Praja Foundation, iCall), and NCRB annual data feeds. Three independent channels so no single source is a bottleneck.


📚 What We Learned

  • Real crime data is messy. ML pipelines are only as good as the cleaning that happens before them. Garbage in, garbage out — no matter how elegant the model.

  • The weighting decisions in an ML model are ethical decisions, not just technical ones. Who decides that murder weighs 10x more than theft? We did. That responsibility is real.

  • For safety-critical features, simplicity beats sophistication. A wa.me link that always works beats a Twilio integration that sometimes doesn't. Reliability is a feature.

  • PWAs are underrated for social impact apps in India — no App Store approval wait, no install friction, works on ₹8,000 Android phones on 4G. The women who need this most are not on iPhones.

  • Building for women's safety means building for one-handed use, low-light conditions, and high-stress moments. Every extra tap costs trust. Every second of load time costs safety.

  • Constraints are not obstacles. No Twilio budget forced a better SOS. No serverless ML forced a proper backend architecture. The best solutions often come from the tightest constraints.


🌐 Try It Live

Live App: https://safar-saheli.vercel.app

GitHub: https://github.com/Gauravkumar512/SafarSaheli

Built With

Share this project:

Updates