A cutting-edge AI-powered navigation system that prioritizes user safety through machine learning route analysis, crime data integration, and real-time emergency response features.
- AI Safety Routing Engine: Custom A* algorithm with dynamic cost calculation
- Dual Route Modes: Safest route (weighted for safety) vs Fastest route (shortest distance)
- Real-time Safety Metrics: Live safety scores, lighting levels, crowd density analysis
- AI Safety Prediction: Machine learning model for location-based safety scoring
- Mapbox GL Integration: Stunning 3D map with dark cyberpunk theme
- 3D Building Extrusion: Immersive skyscraper visualization on zoom
- Crime Heatmap Layer: Glowing neon red/orange danger zones
- Neon Route Display: Dynamic green (safest) and cyan (fastest) route lines with glow effects
- Crime Hotspot Analysis: High/Medium/Low severity zones with radius-based penalties
- Safety Node Network: Lighting level and crowd density tracking
- User Report System: Dynamic penalty calculation based on recent suspicious activity
- SOS Emergency System: One-click emergency alert with full-screen red overlay
- AI Explainability: Detailed risk factor breakdown and confidence scores
- Quick Demo Mode: Instant AI value demonstration for judges
- 30-Second Demo Flow: Perfect judge presentation script
- Demo Scenarios: High Risk Area, Safe Corridor, and Quick Demo modes
- Presentation Guide: Complete talking points and Q&A preparation
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Next.js) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Sidebar β β Map β β SOS Panel β β
β β (React/TS) β β (Mapbox GL) β β (Emergency) β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β REST API
β
ββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β Backend (FastAPI) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Routing β β AI/ML Model β β SOS β β
β β Service β β (Scikit-learn)β β Service β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β Database (SQLite) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Safety Nodes β βCrime Hotspotsβ β User Reports β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.8+
- Node.js 18+
- Mapbox Access Token (get one at mapbox.com)
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Initialize database with mock data
python -m app.utils.generate_mock_data
# Start the server
uvicorn app.main:app --reloadThe backend will be available at http://localhost:8000
API documentation: http://localhost:8000/docs
cd frontend
# Install dependencies
npm install
# Configure environment variables
# Edit .env.local and add your Mapbox token:
# NEXT_PUBLIC_MAPBOX_TOKEN=your_mapbox_token_here
# Start the development server
npm run devThe frontend will be available at http://localhost:3000
saferoute-ai/
βββ backend/
β βββ app/
β β βββ api/
β β β βββ v1/
β β β βββ routing.py # Route calculation endpoint
β β β βββ sos.py # SOS emergency endpoint
β β β βββ ai.py # AI safety score endpoint
β β βββ db/
β β β βββ models.py # SQLAlchemy models
β β β βββ session.py # Database session management
β β βββ services/
β β β βββ routing.py # AI safety routing algorithm
β β βββ schemas/
β β β βββ routing.py # Pydantic schemas
β β β βββ sos.py # SOS request schemas
β β βββ utils/
β β β βββ generate_mock_data.py # Mock data generator
β β βββ core/
β β β βββ config.py # Configuration management
β β βββ main.py # FastAPI application
β βββ ml/
β β βββ safety_model.py # ML model implementation
β β βββ feature_engineering.py # Feature extraction
β β βββ train_model.py # Model training
β βββ requirements.txt
β βββ init_db.py # Database initialization
βββ frontend/
β βββ src/
β β βββ app/
β β β βββ page.tsx # Main application page
β β β βββ layout.tsx # Root layout
β β β βββ globals.css # Global styles
β β βββ components/
β β βββ Sidebar.tsx # Glassmorphic sidebar with SOS
β β βββ Map.tsx # 3D Mapbox component
β βββ package.json
β βββ tailwind.config.ts
β βββ .env.local # Environment variables
βββ HACKATHON_PRESENTATION.md # Demo guide for judges
βββ DEPLOYMENT.md # Deployment documentation
βββ API_DOCUMENTATION.md # API reference
βββ README.md
POST /api/v1/calculate
Content-Type: application/json
{
"source": {
"latitude": 28.6315,
"longitude": 77.2167
},
"destination": {
"latitude": 28.6350,
"longitude": 77.2200
},
"safety_weight": 0.7
}GET /api/v1/ai/safety-score?latitude=28.6315&longitude=77.2167&radius=1000POST /api/v1/sos/trigger
Content-Type: application/json
{
"latitude": 28.6315,
"longitude": 77.2167,
"timestamp": "2026-06-04T01:00:00Z"
}GET /health- Lighting Level Analysis: Street light density and coverage
- Crime Hotspot Detection: Proximity to reported crime locations
- Crowd Density Assessment: Real-time crowd estimation
- Historical Incident Data: Past safety incidents in area
- Time-based Factors: Safety varies by time of day
- Algorithm: Random Forest Regressor
- Features: 15+ engineered safety features
- Output: Safety score between 0.0 (unsafe) and 1.0 (safe)
- Confidence: Model reliability metrics (87% average)
- Fallback: Rule-based system when AI unavailable
Cost = Distance + Safety Penalty
Safety Penalties:
- Crime Hotspots: HIGH (2500), MEDIUM (500), LOW (100)
- Low Lighting: 50
- Sparse Crowd: 30
- Recent User Reports: Dynamic (decays over time)
- AI Safety Score: Integrated into cost calculation
- Cyberpunk Aesthetic: Dark theme with neon accents
- Glassmorphism: Frosted glass UI elements
- Smooth Animations: Cinematic transitions with Framer Motion
- 3D Immersion: Building extrusion and spatial visualization
- Accessibility: High contrast and clear visual hierarchy
- CORS configuration for frontend-backend communication
- Environment variable management for sensitive data
- Input validation with Pydantic schemas
- SQL injection prevention with SQLAlchemy ORM
- Auto-generated SECRET_KEY for JWT tokens
- Health check endpoint for monitoring
The system generates realistic mock data for Connaught Place, Delhi:
- 80 Safety Nodes with safety scores, lighting levels, and crowd density
- 15 Crime Hotspots with severity levels and radius
- 50 User Reports with various types and timestamps
- 50 Detour Nodes for alternative routing
- Click "Quick Demo Mode" button in the sidebar
- Watch AI calculate optimal safe route
- View safety score comparison (safest vs fastest)
- See AI explainability panel with risk factors
- High Risk Area: Shows AI avoiding crime hotspots
- Safe Corridor: Demonstrates optimal safe routing
- Quick Demo: Instant AI value demonstration
See HACKATHON_PRESENTATION.md for complete demo script and talking points.
# Build and start all services
docker-compose up --build
# Services will be available at:
# - Frontend: http://localhost:3000
# - Backend: http://localhost:8000
# - API Docs: http://localhost:8000/docs# Backend
cd backend
docker build -t saferoute-backend .
docker run -p 8000:8000 saferoute-backend
# Frontend
cd frontend
docker build -t saferoute-frontend .
docker run -p 3000:3000 saferoute-frontendSee DEPLOYMENT.md for detailed deployment instructions.
- API Documentation: See
API_DOCUMENTATION.mdfor complete API reference - Deployment Guide: See
DEPLOYMENT.mdfor production deployment - Hackathon Guide: See
HACKATHON_PRESENTATION.mdfor demo instructions - Interactive API Docs: Available at
http://localhost:8000/docswhen backend is running
- Real-time GPS tracking
- User authentication and profiles
- Historical route analysis
- Integration with real emergency services APIs
- Mobile application (React Native)
- Multi-city support
- Real-time crowd-sourced safety reports
- Advanced ML model training with real data
Mapbox Token Error
- Ensure
NEXT_PUBLIC_MAPBOX_TOKENis set infrontend/.env.local - Get a free token at mapbox.com
Backend Connection Error
- Verify backend is running on
http://localhost:8000 - Check CORS configuration in
backend/app/main.py - Ensure database is initialized with mock data
Port Conflicts
- Frontend auto-selects available ports (3000-3006)
- Backend runs on port 8000 by default
- Modify ports in respective configuration files if needed
π License\n\nThis project is licensed under the Apache License 2.0 - see the LICENSE file for details.
SafeRoute AI Development Team
For support and inquiries, contact the development team.
Built with β€οΈ for safer navigation