Intelligent Route Safety Navigation System for India
- 🎯 Problem Statement
- ✨ Features
- 🏗️ Architecture
- 🛠️ Tech Stack
- 🚀 Getting Started
- 📖 Usage Guide
- 🔧 API Reference
- 🧪 Testing
- 🚢 Deployment
- 🗺️ Roadmap
- 🤝 Contributing
- 📄 License
|
India faces a critical road safety crisis with over 150,000 road fatalities annually. Traditional navigation systems focus solely on finding the shortest or fastest routes without considering safety factors. Safe Route addresses this gap by creating a platform where:
|
|
| Feature | Description |
|---|---|
| Safety-Prioritized Algorithm | Custom weighted algorithm balancing 70% safety + 30% travel time |
| Multiple Routing Services | Integration with OpenRouteService, GraphHopper, and OSRM |
| Fallback Mechanisms | Graceful degradation when external services are unavailable |
| Route Caching | Firebase-powered route caching for improved performance |
┌─────────────────────────────────────────────────────┐
│ 📍 Segment-Based Rating System │
│ ───────────────────────────────────────────────── │
│ • Roads divided into ~2km segments │
│ • Binary "Good" or "Bad" ratings │
│ • Aggregated 0-100 safety scores │
│ • Recent ratings given higher weight │
└─────────────────────────────────────────────────────┘
- Leaflet Integration - High-performance map rendering with React-Leaflet
- Visual Safety Indicators - Color-coded route segments based on safety ratings
- Interactive Elements - Clickable segments for rating submission
- Custom Markers - Start, destination, and user location markers
- Firebase Authentication - Secure email/password authentication
- Protected Routes - Map functionality accessible only to authenticated users
- User Data Storage - Firestore-based user profile management
- Location Permission - Consent-based location access during registration
- Geolocation Integration - Automatic detection of user's current location
- Search with Autocomplete - Location search powered by Nominatim API
- India-Specific Boundaries - Optimized for Indian geographical context
graph TB
subgraph Client["🖥️ Frontend (React)"]
A[App.js] --> B[MapView]
A --> C[Sidebar]
B --> D[Leaflet Map]
C --> E[PlaceSearch]
A --> F[Auth Context]
end
subgraph Server["⚙️ Backend (Node.js/Express)"]
G[Routes Controller] --> H[Safe Route Calculator]
I[Ratings Controller] --> J[Road Rating Model]
H --> K[GraphHopper Service]
H --> L[OSRM Service]
end
subgraph Firebase["☁️ Firebase"]
M[Authentication]
N[Firestore DB]
O[Hosting]
end
subgraph External["🌐 External APIs"]
P[OpenRouteService]
Q[GraphHopper API]
R[OSRM API]
S[Nominatim Geocoding]
end
Client <-->|REST API| Server
Server <--> Firebase
Server <--> External
Client <--> M
1️⃣ Location Input → User inputs start and destination locations
2️⃣ Route Request → Client requests route options from server
3️⃣ External API → Server communicates with routing services
4️⃣ Safety Enhancement → Server applies safety data to routes
5️⃣ Response Delivery → Enhanced routes returned to client
6️⃣ Visualization → Client renders routes with safety indicators
7️⃣ User Feedback → Ratings submitted back to server for storage
|
|
| Service | Purpose | Documentation |
|---|---|---|
| 🗺️ OpenRouteService | Primary routing service | Docs |
| 🚗 GraphHopper | Alternative routing | Docs |
| 🛣️ OSRM | Backup routing | Docs |
| 📍 Nominatim | Geocoding | Docs |
| 🔥 Firebase | Auth, DB, Hosting | Docs |
- Node.js v14 or higher
- npm v6 or higher
- Firebase Account with a configured project
- API Keys for routing services (optional, uses public APIs by default)
# 1️⃣ Clone the repository
git clone https://github.com/yourusername/SAFE_ROUTE.git
cd SAFE_ROUTE/safe-route
# 2️⃣ Install all dependencies (root, server, and client)
npm run install-all
# 3️⃣ Configure Firebase
# Create client/src/firebase/config.js with your Firebase config
# 4️⃣ Configure server environment
# Create server/.env with required environment variablesCreate client/src/firebase/config.js:
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_AUTH_DOMAIN",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_STORAGE_BUCKET",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID",
};
export default firebaseConfig;# 🚀 Start both server and client concurrently
npm start
# Or run separately:
# Terminal 1 - Start the server
cd server && npm run dev
# Terminal 2 - Start the client
cd client && npm startThe application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Register with email and password
- Grant location permission during registration
- Login to access the map interface
┌─────────────────────────────────────────────────────────┐
│ Step 1: Enter Start Location │
│ ───────────────────────────────────────────────────── │
│ • Use "Current Location" button, OR │
│ • Type address in the search box │
├─────────────────────────────────────────────────────────┤
│ Step 2: Enter Destination │
│ ───────────────────────────────────────────────────── │
│ • Type destination address │
│ • Select from autocomplete suggestions │
├─────────────────────────────────────────────────────────┤
│ Step 3: Toggle Safety Priority (Optional) │
│ ───────────────────────────────────────────────────── │
│ • Enable for safety-prioritized routing │
│ • Disable for fastest route │
├─────────────────────────────────────────────────────────┤
│ Step 4: Calculate Route │
│ ───────────────────────────────────────────────────── │
│ • Click "Calculate Route" button │
│ • View route with safety indicators │
└─────────────────────────────────────────────────────────┘
- Calculate a route between two locations
- Click on any segment of the displayed route
- In the popup, rate the road as "Good" or "Bad"
- Your rating will influence future route calculations
| Endpoint | Method | Description |
|---|---|---|
/api/routes/calculate |
POST | Calculate route between two points |
Request Body:
{
"start": { "lat": 28.6139, "lng": 77.209 },
"destination": { "lat": 28.5355, "lng": 77.391 },
"prioritizeSafety": true
}Response:
{
"success": true,
"route": [...],
"distance": 25.4,
"estimatedTime": 45,
"safetyScore": 78,
"segments": [...]
}| Endpoint | Method | Description |
|---|---|---|
/api/ratings |
POST | Submit a new road rating |
/api/ratings/bounds |
GET | Get ratings within map bounds |
# Run client tests
cd client && npm test
# Run server tests
cd server && npm testThe application uses Firebase Hosting with automated CI/CD via GitHub Actions.
- Merge to
main→ Deploys to production - Pull Requests → Creates preview deployments
# Build the client
cd client && npm run build
# Deploy to Firebase
firebase deploy --only hosting🔗 https://safe-route-127fd.web.app/
- Multi-service route calculation
- Crowdsourced road ratings
- Firebase authentication
- Interactive map interface
- Safety-prioritized routing algorithm
- Machine Learning Integration - Predictive safety models
- Detailed Rating Categories - Specific hazard types (potholes, traffic, etc.)
- Temporal Analysis - Time-based safety patterns (day/night, seasonal)
- Mobile Applications - Native iOS and Android versions
- Offline Functionality - Enhanced capabilities without internet
- Vehicle System Integration - API for in-vehicle navigation
SAFE_ROUTE/
├── 📁 .github/
│ └── 📁 workflows/ # GitHub Actions CI/CD
├── 📁 safe-route/
│ ├── 📁 client/ # React Frontend
│ │ ├── 📁 public/ # Static assets
│ │ └── 📁 src/
│ │ ├── 📁 components/ # React components
│ │ ├── 📁 contexts/ # React contexts
│ │ ├── 📁 firebase/ # Firebase config & services
│ │ ├── 📁 pages/ # Page components
│ │ ├── 📁 services/ # API services
│ │ ├── 📁 styles/ # CSS styles
│ │ └── 📁 utils/ # Utility functions
│ ├── 📁 server/ # Node.js Backend
│ │ ├── 📁 controllers/ # Route handlers
│ │ ├── 📁 models/ # Data models
│ │ ├── 📁 routes/ # API routes
│ │ └── 📁 utils/ # Utility functions
│ ├── 📄 firebase.json # Firebase configuration
│ ├── 📄 firestore.rules # Firestore security rules
│ └── 📄 package.json # Project dependencies
└── 📄 README.md # You are here!
Contributions are welcome! Please read our contributing guidelines before submitting a pull request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- OpenStreetMap for map data
- Leaflet for map visualization
- OpenRouteService for routing API
- Firebase for backend services
- The research community for guidance on safety metrics
This project is licensed under the ISC License - see the LICENSE file for details.
Made with ❤️ for safer roads in India