Passive Ride Monitoring β’ Deterministic Risk Assessment β’ Explainable Safety Escalation
Real-time telemetry, deterministic risk scoring, and transparent safety state transitions.
Problem β’ Why SafeCorridor? β’ Features β’ Architecture β’ Performance β’ API β’ Installation β’ Roadmap β’ Contributing
|
Language Kotlin + Python |
Architecture Client β API β Risk Engine |
Communication REST + WebSocket |
Platform Android |
License MIT |
|
π± Start Ride |
π Collect GPS |
π§ Analyze Behaviour |
Accumulate Risk |
π Update Dashboard |
π End Ride |
Modern ride-monitoring systems often rely on proprietary black-box algorithms or community-driven reporting, leaving passengers vulnerable when active communication is impossible. Erratic driving behavior, unprompted prolonged stops, and significant deviations from expected routes are strong early indicators of compromised safety, but these metrics are rarely analyzed collectively in real-time to escalate safety states transparently.
| Conventional Systems | SafeCorridor |
|---|---|
| Black-box decisions | Deterministic evaluation |
| Binary alerts | Progressive risk accumulation |
| Minimal transparency | Explainable decision logs |
| Static thresholds | Behavior over time |
| Manual interpretation | Visual risk timeline |
| Capability | Status |
|---|---|
| Passive Monitoring | β |
| Route Corridor Analysis | β |
| Risk Accumulation | β |
| Explainability Logs | β |
| Real-time Dashboard | β |
| Offline Buffering | π§ |
| Authentication | π§ |
- Deterministic over probabilistic: The current implementation prioritizes deterministic mathematical models and explainable rules over opaque predictive models.
- Explainability before automation: Every alert must have a traceable, logged reason.
- Privacy by default: Data is strictly session-scoped.
- No long-term profiling: No driver habits or historical paths are analyzed.
- Observable system behavior: The dashboard reflects exactly what the backend sees.
- Progressive risk accumulation: Risk builds incrementally based on sustained evidence.
Android App
β
βΌ
REST API (FastAPI)
β
βΌ
Session Manager
β
βΌ
Risk Engine
β
βΌ
State Machine
β
βββββββββββββββΊ SQLite
β
βΌ
WebSocket Manager
β
βΌ
React Dashboard
GPS β Android Foreground Service β REST API β Validation β Risk Engine β State Machine β SQLite β WebSocket β Dashboard
A core tenet of SafeCorridor is that the dashboard should never output a generalized "Danger" warning without evidence. Every point of risk is strictly traceable to an observable ride behavior.
13:42:12 Minor route deviation (+0.8)
13:42:17 Elevated speed (+1.1)
13:42:23 Moving away from destination (+1.4)
13:42:28 Unexpected stop (+1.6)
Risk = 46
State = MONITORING
Initializes a new ride session.
- Request:
{ "startLocation": { "lat": 21.14, "lon": 79.08 }, "endLocation": { "lat": 21.16, "lon": 79.09 } } - Response:
{ "sessionId": "1783375333839" }
Ingests high-frequency GPS telemetry.
- Request:
{ "sessionId": "1783375333839", "location": { "lat": 21.15, "lon": 79.085 }, "speed": 15, "accuracy": 8 } - Response:
{ "riskScore": 4.5, "severity": "NORMAL", "reasons": [] }
Finalizes and archives the active session.
- Request:
{ "sessionId": "1783375333839" } - Response:
{ "status": "ended" }
Health check to verify backend operational status.
- Response:
{ "status": "healthy" }
The system relies on hard mathematical constants configurable within backend/risk_engine.py:
| Parameter | Default | Description |
|---|---|---|
MAJOR_CORRIDOR_M |
100.0 |
Maximum tolerated cross-track distance before a persistent deviation is recorded. |
MINOR_CORRIDOR_M |
20.0 |
Threshold for detecting minor early-warning deviations. |
MAX_SPEED_MPS |
30.0 |
Upper threshold for unsafe speed (108 km/h). |
ELEVATED_SPEED_MPS |
20.0 |
Threshold for tracking aggressive or increasing speed (72 km/h). |
DECAY_RATE |
0.5 |
Points deducted per second when behavior returns to normal parameters. |
SafeCorridor is engineered for high-throughput, low-latency telemetry ingestion:
- Telemetry interval: 5 seconds
- Average latency: <100 ms
- Memory: ~30 MB footprint
- Database: SQLite WAL (Write-Ahead Logging)
- Risk evaluation: O(1) time complexity
- Location accuracy: 6β12 m typical
safecorridor/
βββ android-app/ # Foreground telemetry collection
β βββ app/src/main/
β βββ build.gradle.kts
βββ backend/ # REST API, risk evaluation, state management, persistence
β βββ main.py
β βββ risk_engine.py
β βββ session_manager.py
β βββ database.py
βββ dashboard/ # Real-time monitoring interface
β βββ src/
β βββ public/
β βββ package.json
βββ LOCAL_SETUP.md # Comprehensive local setup guide
For a comprehensive step-by-step guide on running the emulator and dashboard together, see LOCAL_SETUP.md.
Requirements:
- Python 3.10+
- Node.js 18+
- Android Studio Iguana+
- Git
Quick Start Backend:
git clone https://github.com/ShadyNights/Safe-Corridor.git
cd Safe-Corridor/backend
pip install -r requirements.txt
python main.pyQuick Start Dashboard:
cd ../dashboard
npm install
npm run dev- Android telemetry
- Dashboard
- Risk engine
- Explainability engine
- Session management
- Offline buffering
- PostgreSQL
- Authentication
- CI/CD
- No external emergency integration (e.g., 911 dispatch).
- Single-device ride monitoring only.
- Relies on local SQLite storage.
- No user authentication layer.
- Offline buffering is still under development.
These limitations are intentional design boundaries rather than system failures.
Testing: Automated unit and integration tests are planned as part of the project's next engineering milestone.
Security:
- Session isolation is enforced.
- Input validation via Pydantic.
- HTTPS enforcement (Planned).
- Authentication (Planned).
- Device authentication (Planned).
Contributions are welcome. Please ensure that PRs strictly adhere to the project's deterministic and privacy-first engineering philosophies.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/OfflineBuffering). - Ensure no random generators (
Math.random(),random.choice) are used for core telemetry or state logic. - Commit your changes (
git commit -m 'feat: add offline buffering to TrackerService'). - Push to the branch (
git push origin feature/OfflineBuffering). - Open a Pull Request.
Kashif Ansari
- GitHub: @ShadyNights
- LinkedIn: kashifansari18
This project is licensed under the MIT License - see the LICENSE file for details.
SafeCorridor
Deterministic Engineering β’ Explainable Decision Making β’ Privacy by Design
Made with Python, FastAPI, React, Kotlin, and SQLite.