Hackathon Project: Empowering safer journeys through AI-driven route analysis and real-time community alerts.
Try SafeRoute now - No installation required!
| ๐ User App | ๐จโ๐ผ Admin Dashboard |
|---|---|
| Main navigation interface | Monitor SOS alerts & community reports |
๐ Direct Links:
- User Interface: https://saferoute-frontend.onrender.com/
- Admin Dashboard: https://saferoute-frontend.onrender.com/admin
SafeRoute is an intelligent navigation system that prioritizes user safety by analyzing crime data, emergency services availability, and community reports to recommend the safest routes. Built during a hackathon with a focus on women's safety and community-driven protection.
- Multi-AI Provider Support: Groq AI (llama-3.3-70b-versatile) for comprehensive analysis
- Smart Route Scoring: AI evaluates routes based on crime incidents, lighting, and emergency services
- Real-time Risk Assessment: Dynamic safety scores using multiple data sources
- Emergency Service Integration: Google Places API integration for real hospital/police/petrol/hotel locations
- Evenly Distributed POI Markers: Hospitals, police stations, petrol pumps, and hotels are spatially distributed along each route using position-band sampling โ not clustered at start/end
- AI Safety Explainer: One-click Groq AI analysis of any route explaining why it is safe or risky in plain language (3โ4 sentences)
- AI Route Narrator: Text-to-speech narration of your selected route with turn-by-turn safety briefing; uses Groq for a personalized briefing, falls back to browser Speech Synthesis
- Predictive Safety Score: Bar chart showing safety forecasts for 7AM / 2PM / 8PM / 11PM with a "NOW" badge on the current time slot โ powered by time-of-day + day-of-week scoring with optional Groq AI insight
- Crime Heatmap Overlay: Toggle a live danger heatmap built from community reports and SOS alerts directly on the map
- Color-Coded Intensity: Yellow โ Orange โ Red โ Deep Red gradient representing danger density
- Auto-Refresh: Heatmap updates automatically when new community reports are submitted
- SOS Alert Broadcasting: Instant emergency alerts to admin dashboard via Socket.IO
- Countdown SOS with Cancel: 5-second confirmation window prevents accidental triggers
- AI Emergency Assistant: Groq AI provides nearby emergency services and personalized safety tips on SOS trigger
- Live Location Sharing: Real-time GPS tracking with current address shown on map
- Current Location Marker: Animated blue drop-pin shows your detected location on the map with address in an info popup
- Locate Me Button: Instantly fills the source field with your current location for route planning
- Crowd-sourced Reports: Users can report accidents, suspicious activity, harassment, theft, traffic, and road damage
- Real-time Incident Mapping: Live visualization of community-reported safety concerns
- Heatmap Integration: Community reports directly feed the danger heatmap
- Interactive Safety Dashboard: Visual route comparison with safety scores, distance, duration, and AI features per route
- Safety-Color-Coded Routes: Green / Amber / Red polylines on map based on safety score
- Night Mode Support: Full dark mode for comfortable night navigation
- Mobile-Responsive Design: Hamburger navigation and sidebar overlay for all screen sizes
- Personalized Experience: Name capture on first visit used in SOS alerts and AI narration
SafeRoute/
โโโ backend/ # Flask API Server
โ โโโ app.py # Main application with AI integration
โ โโโ saferoute.db # SQLite database
โโโ frontend/ # Static Web Application
โ โโโ index.html # Landing page (default)
โ โโโ app.html # Main user interface
โ โโโ admin.html # Admin dashboard
โ โโโ main.js # Core JavaScript functionality
โ โโโ style.css # Modern UI styling
โ โโโ config.js # Environment configuration
โโโ requirements.txt # Python dependencies
โโโ render.yaml # Deployment configuration
โโโ Procfile # Heroku deployment
- Python 3.8+
- Google Maps API Key
- AI API Keys (optional, for enhanced AI features):
- Groq AI API Key
- Google Gemini API Key
git clone https://github.com/yourusername/saferoute.git
cd saferoute# Copy environment template
cp .env.example .env
# Edit .env with your API keys
GROQ_API_KEY=your_groq_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here
GOOGLE_MAPS_API_KEY=your_google_maps_api_key_herepip install -r requirements.txt# Start backend server
python backend/app.py
# Open frontend (in another terminal)
# Serve frontend files on localhost:8000 or open index.html (landing) or app.html (main app) directly- Main App:
http://localhost:5000or openfrontend/app.html - Admin Dashboard:
frontend/admin.html
POST /get-routes
Content-Type: application/json
{
"source": "Starting Location",
"destination": "Destination Location",
"frontend_routes": [{ "polyline": "<encoded_polyline>" }]
}POST /explain-route
Content-Type: application/json
{
"route": { "safety_score": 82, "distance": "12.3 km", ... }
}POST /narrate-route
Content-Type: application/json
{
"route": { ... },
"route_num": 1,
"user_name": "Priya"
}POST /predict-safety
Content-Type: application/json
{
"route": { "safety_score": 82, ... }
}Returns scores for 7AM / 2PM / 8PM / 11PM slots with optional Groq AI one-line insight.
POST /send-alert
Content-Type: application/json
{
"lat": 17.3850,
"lng": 78.4867,
"user_name": "Priya"
}POST /post-feedback
Content-Type: application/json
{
"lat": 17.3850,
"lng": 78.4867,
"type": "harassment",
"description": "Incident description"
}- Model:
llama-3.3-70b-versatile - Use Cases:
- Route safety explanation (3โ4 sentence human-readable analysis)
- Voice narration script generation (time-of-day aware)
- Predictive safety one-line insight per route
- Emergency SOS AI assistant (nearest hospitals, police, actionable advice)
- Speed: ~500ms average response
- Fallback: All AI features have client-side fallbacks โ app is fully functional without Groq
- Primary: Groq AI (
llama-3.3-70b-versatile) - Secondary: Google Places API (real location data for POI markers)
- Tertiary: Client-side calculation (safety scores, narration text, forecast bars)
- Final: Generic emergency suggestions with helpline numbers
SafeRoute calculates safety scores using multiple factors:
-
Crime Incident Analysis (40%)
- Historical crime data simulation
- Incident severity weighting
- Proximity to route calculation
-
Emergency Services Availability (30%)
- Hospital proximity and count
- Police station accessibility
- Response time estimation
-
Infrastructure Quality (20%)
- Street lighting assessment
- Road condition evaluation
- Public transport availability
-
Community Reports (10%)
- Real-time incident reports
- User-generated safety alerts
- Crowd-sourced hazard mapping
Time-of-day and day-of-week adjustments applied to base score:
| Time Slot | Modifier |
|---|---|
| 7 AM | +8 (morning commute, safer) |
| 2 PM | +5 (daytime, peak safety) |
| 8 PM | โ10 (evening, higher risk) |
| 11 PM | โ20 (night, highest risk) |
Weekend penalty: โ3 points. Groq AI adds a one-sentence contextual insight per forecast.
# render.yaml configuration included
# Automatic deployment from GitHub# Set environment variables
export PORT=5000
export GROQ_API_KEY=your_key
export GOOGLE_MAPS_API_KEY=your_key
# Run production server
python backend/app.py- Flask: Web framework with CORS support
- Flask-SocketIO: Real-time WebSocket communication
- SQLite: Lightweight database for alerts and feedback
- Groq AI SDK:
llama-3.3-70b-versatilefor route explanation, narration, and prediction - Google Directions API: Multi-route planning with polyline encoding
- Google Places API (New): Real hospital, police, petrol pump, and hotel locations along routes
- Vanilla JavaScript: No framework dependencies
- Google Maps JavaScript API: Interactive mapping with HeatmapLayer, DirectionsRenderer, custom SVG markers
- Web Speech Synthesis API: Browser-native TTS for route narration
- Socket.IO Client: Real-time SOS and community report updates
- Modern CSS: Responsive design with dark mode, animated route cards, forecast bars
- Render.com: Primary hosting platform
- Heroku: Alternative deployment option
- Static Hosting: Frontend can be served separately
- API Key Protection: Secure environment variable management
- CORS Configuration: Proper cross-origin request handling
- Input Validation: Sanitized user inputs and SQL injection prevention
- Rate Limiting: Built-in protection against abuse
- Emergency Verification: Confirmation tokens for sensitive operations
CREATE TABLE sos_alerts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
lat REAL NOT NULL,
lng REAL NOT NULL,
timestamp DATETIME NOT NULL,
status TEXT DEFAULT 'PENDING'
);CREATE TABLE route_feedback (
id INTEGER PRIMARY KEY AUTOINCREMENT,
lat REAL,
lng REAL,
type TEXT,
description TEXT,
timestamp DATETIME NOT NULL,
route_polyline TEXT
);- Animated Logo: Dynamic slogan rotation
- Safety Color Coding: Intuitive visual safety indicators
- Responsive Design: Mobile-first approach
- Dark Mode: Eye-friendly night navigation
- Real-time Updates: Live incident and alert notifications
This is a hackathon project, but contributions are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
Built for: Hackathon
Theme: Women's Safety & Community Protection
Duration:
Team: Thrivers
- โ AI-powered safety analysis with Groq (llama-3.3-70b-versatile)
- โ AI Safety Explainer โ plain-language route risk analysis
- โ AI Route Narrator โ voice narration with Groq + Speech Synthesis fallback
- โ Predictive Safety Score โ time-of-day forecast with bar chart UI
- โ Danger Heatmap Overlay โ community-fed live crime heatmap
- โ Real-time SOS emergency response system
- โ Evenly distributed POI markers (hospitals, police, petrol, hotels) along routes
- โ Safety-color-coded route polylines (Green / Amber / Red)
- โ Live user location marker with animated drop-pin
- โ Community-driven safety network with real-time Socket.IO updates
- โ Mobile-responsive design with hamburger navigation
- โ Production-ready deployment on Render.com
- Fake incoming call feature for discreet SOS escape
- Shake-to-SOS via device motion sensor
- Trusted contacts auto-alert via WhatsApp/SMS deep links
- Journey Guard Mode โ auto-SOS if user doesn't check in by ETA
- Live SOS tracking shareable link for trusted contacts
- Machine learning model for predictive safety analysis using real crime datasets
- Integration with local law enforcement APIs
- Wearable device compatibility (smartwatch alerts)
- Multi-language support for global accessibility
- Advanced analytics dashboard for city planners
- Integration with ride-sharing platforms
India: 100 (Police), 102 (Ambulance), 1091 (Women Helpline)
- Groq AI for providing fast, unlimited AI inference
- Google Gemini for advanced AI reasoning capabilities
- Google Maps Platform for comprehensive location services
- Open Source Community for inspiration and tools
- Hackathon Organizers for the opportunity to build for social impact
๐ก๏ธ SafeRoute - Because every journey should be a safe journey.