Academic Context: Minor Project-I submitted in partial fulfilment of the requirements for the degree of Bachelor of Technology in Computer Science & Engineering Institution: Dev Bhoomi Uttarakhand University (DBUU), Dehradun Batch: 2026 β 2027 Supervisor: Mr. Mukesh Rajput (Assistant Professor, Department of CSE, SoEC, DBUU) Project Team: Arushi Saxena (24BTCSE0241), Anurag Suyal (24BTCSE0264), Aman Singh Kunwar (24BTCSE0321), Shubham Kumar (24BTCSE0333)
SAFORA is a community-powered personal safety navigation and emergency response application designed for campus and urban environments. While standard navigation systems focus solely on distance and speed, SAFORA empowers walkersβespecially women and students traveling at night or in unfamiliar areasβto evaluate safety risks in real time.
Users crowdsource hazard reports (poor lighting, road hazards, waterlogging, isolated areas, harassment hotspots), view an algorithmic safety score, share their journey during Safe Walk mode, and trigger an instant One-Tap SOS to trusted contacts.
flowchart TD
User(["π€ Mobile User (Student / Citizen)"])
Admin(["π‘οΈ Operations Lead (Web Admin Only)"])
subgraph MobileApp ["Mobile Safety App (React Native + TypeScript)"]
Radar["Safety Radar & Geospatial Canvas"]
SafeWalk["Safe Walk Engine (150m Corridor)"]
SOS["One-Tap SOS Emergency Trigger"]
end
subgraph WebAdmin ["Web Operations Command (React + Vite - Web Only)"]
CommandMap["Live Operations Map"]
IncidentQueue["Real-time SOS Dispatch Queue"]
Moderation["Hazard Moderation & Verification Hub"]
UserMgmt["User Directory"]
end
subgraph BackendGateway ["Backend API & Real-Time Gateway (Node.js + Express)"]
Auth["JWT Auth & Role Guards"]
ScoreEngine["Decay-Weighted Safety Score Engine"]
IncidentMgr["Incident & Socket.IO Dispatcher"]
end
subgraph SpatialDB ["Spatial Data Store (PostgreSQL + PostGIS)"]
PostGIS[("PostGIS Engine<br/>geography(Point, 4326) + GiST Indexes")]
end
subgraph ExternalServices ["External Services & Notifications"]
FCM["Firebase Cloud Messaging (FCM)"]
Cloudinary["Cloudinary Evidence Storage"]
Contacts["π₯ Trusted Contacts (SMS & Push)"]
end
User <--> MobileApp
Admin <--> WebAdmin
MobileApp <==>|"HTTPS (REST) & WSS (Socket.IO)"| BackendGateway
WebAdmin <==>|"HTTPS (REST) & WSS (Socket.IO)"| BackendGateway
BackendGateway <-->|"ST_DWithin & GiST Spatial Query"| SpatialDB
BackendGateway -->|"Emergency Push"| FCM
BackendGateway -->|"Media Storage"| Cloudinary
FCM --> Contacts
The diagram above shows the target architecture the project is built toward. Live location streaming to guardians and automatic server-side deviation alerts are active development work β see Development Status below for what's built today versus in progress.
This project follows a staged plan (docs/v1/ β docs/v2/ β docs/v3/) rather than a single big-bang build. V1 is the version being built for this submission and targets the six modules below; not everything in this README is live yet.
| Area | Status |
|---|---|
| Auth, hazard reporting, offline queue, safety-score calculation | β Working |
| Live location streaming to guardians during Safe Walk | π§ In progress β see docs/v1/tasks.md (task 5β6) |
| Automatic server-side deviation escalation (beyond the phone-side 60s prompt) | π§ In progress β docs/v1/tasks.md (task 7) |
| Safety-score heatmap on the map screen | π§ In progress β docs/v1/tasks.md (task 8) |
| Background tracking with screen locked, lock-screen SOS audio, ETA notification | π§ In progress β docs/v1/tasks.md (tasks 13β15) |
| Admin dashboard β hazard moderation, SOS queue | β Working |
| Admin "live" Safe Walk radar | π§ Sample-data fallback being removed β docs/v1/tasks.md (task 3) |
| One-tap SOS (GPS + battery + audio, FCM push, manual SMS/dialer fallback) | β Working |
Full live status, file-level tasks, and acceptance tests are tracked in docs/v1/tasks.md β that file, not this README, is the source of truth while V1 is in progress.
Documentation is organised into three stages, plus an archive of earlier drafts:
| Folder | Contents |
|---|---|
π docs/v1/ |
This submission. Architecture, API, database schema, safety algorithms, mobile features, admin panel, setup, task list, and testing/submission checklist for the current build. |
πΊοΈ docs/v2/ |
Product roadmap beyond the submission: accounts hardening, real per-mode routing & voice guidance, no-unlock SOS triggers, staged chat, Hindi/Uttarakhand localisation, weather & earthquake data, security/privacy/DPDP compliance. |
π docs/v3/ |
Research notes on the synopsis's future-scope items (AI safe-route scoring, offline mesh SOS messaging, AI hazard image detection) β honestly scoped, not scheduled. |
ποΈ docs/archive/ |
Earlier documentation drafts, kept for reference during the transition to the v1/v2/v3 structure. |
| π Academic Synopsis PDF | Approved project synopsis submitted to Dev Bhoomi Uttarakhand University. |
Start here: docs/README.md (folder index) β docs/v1/README.md (this submission's scope) β docs/v1/tasks.md (what's being worked on right now).
Based on Section 4.2 of the Project Synopsis. Items marked π§ are in active development for this submission β see Development Status.
-
Module 1: User Authentication, Onboarding & Session Management
- Secure stateless authentication using JSON Web Tokens (JWT) and bcrypt password hashing.
-
4-Slide First-Install Onboarding Flow (
OnboardingScreen.tsx) introducing the Safety Score, Safe Walk, Instant SOS, and Community Reporting, with "Skip" and "Get Started" triggers. - Rehydration splash loader preventing login screen flicker on app resume; guest mode examiner bypass.
-
Module 2: Community Hazard Reporting & Offline Queue
- Crowdsourced hazard pinning with category selection (lighting, construction, waterlogging, isolated trail, traffic) and severity ratings (1 to 5).
- Anti-abuse mechanisms: rate limiting (20 report submissions per 15-minute window per user) and strict schema input validation.
- In-memory server-side caching for nearby-hazard and safety-score queries, invalidated on new report submission.
-
Offline Incident Queue: stores unsubmitted hazard reports in
AsyncStoragewhen internet drops, automatically syncing once connection is restored.
-
Module 3: Safety Score & Calibrated Multi-Modal Routing
- Real-time score computation (0β100) combining hazard severity, distance falloff, recency exponential decay (
$t_{\text{half}} = 24\text{h}$ ), and community confirmations. Seedocs/v1/safety-algorithms.mdfor the exact formula. - Spatial analysis endpoint via PostGIS
ST_ClusterDBSCAN(GET /api/reports/clusters), grouping hazards within ~330m for density analytics. π§ Rendering this as a heatmap on the map/home screens is in progress. -
Calibrated Multi-Modal Travel Time estimates (Walk / 2-Wheeler / Car), based on fixed speed constants over the routed distance:
-
Walk:
$1.60\text{ m/s}$ ($5.8\text{ km/h}$ ) β ~10.4 mins per 1 km. -
2-Wheeler:
$8.88\text{ m/s}$ ($32\text{ km/h}$ ) + 20s buffer β ~2.2 mins per 1 km. -
Car:
$7.22\text{ m/s}$ ($26\text{ km/h}$ ) + 45s buffer β ~3.0 mins per 1 km.
-
Walk:
-
Known limitation: all three modes currently route over the same street geometry (a single routing call); real per-mode route differentiation is planned for
docs/v2/. - Proximity-biased local search powered by the Photon OpenStreetMap engine, with a MapTiler fallback.
- Real-time score computation (0β100) combining hazard severity, distance falloff, recency exponential decay (
-
Module 4: Safe Walk Mode & Geospatial Canvas
- Server-side route-compliance monitoring along a configured 150-meter corridor.
- Dual-Strategy Geolocation: high-accuracy GPS with automatic fallback to cellular triangulation.
- Layered basemap switcher: dark and light themes over OpenStreetMap tiles, plus Esri World Imagery for satellite view.
-
Note on offline tile caching: an earlier bulk offline-tile-prefetch approach is being reworked (
docs/v2/) to comply with OpenStreetMap's tile usage policy and to add proper attribution. - Hierarchical Android hardware back navigation: step-back through search dropdowns β hazard cards β tab history β double-tap exit on Home.
-
Confirm-before-escalate: on a route deviation, the walker gets a 60-second on-phone prompt before contacts are notified. π§ A server-side backstop (so an escalation still fires if the app is killed or the phone loses signal) and live location streaming to guardians are in progress for this submission β see
docs/v1/architecture.mdΒ§3βΒ§4.
-
Module 5: Guardian SOS, Safety Alerts Center & Audio Evidence
-
Hybrid dispatch:
- Online: captures GPS coordinates, battery level, and up to 30 seconds of recorded audio; looks up guardians by email and dispatches Firebase push notifications.
- Offline fallback: manual SMS composer pre-filled with a live Google Maps location link, and one-tap dialer fallback to trusted contacts or 112, requiring no internet connection.
- Guardian email verification: shows whether an added contact is a Safora member (in-app push + audio playback) or SMS-only.
-
Safety Alerts Center (
NotificationScreen.tsx): unread-count badge, GPS map links, and an embedded audio evidence player. - Test SOS drills: lets a walker rehearse the SOS flow without alerting real contacts.
- One-tap native dialer fallback (
tel:112,tel:108,tel:1090).
-
Hybrid dispatch:
-
Module 6: Administrative Moderation & Diagnostics
- Moderation workflow to mark hazard reports as active, resolved, duplicate, or fake.
- Live system health checks and database latency diagnostics (
/api/diagnostics). - π§ The Safe Walk radar's fallback to illustrative sample data (when no walk is active) is being replaced with a proper empty state β see
docs/v1/tasks.md(task 3).
| Layer | Technology | Engineering Rationale |
|---|---|---|
| Mobile App | React Native 0.87.1 + TypeScript |
Native mobile performance with Hermes bytecode engine and Fabric (New Architecture) enabled. |
| Spatial Canvas | OpenMapView.tsx (Leaflet in a WebView) |
Hardware-accelerated WebView map with a layered basemap switcher (dark/light OpenStreetMap tiles, Esri satellite imagery). |
| Routing Engine | OSRM + calibrated multi-modal speed constants | Real street-network route geometry with distance-based travel-time estimates per mode (see Module 3's known limitation above). |
| State & Navigation | Zustand + Native Stack Navigator | Fast, decoupled state management with native transitions, session hydration, and persistent AsyncStorage. |
| Backend API | Node.js + Express + TypeScript | Asynchronous REST API with in-memory caching for hot spatial queries and a Socket.IO WebSocket gateway. |
| Database | PostgreSQL 15+ with PostGIS | Uses geography(Point, 4326) for true ellipsoidal distance accuracy across the earth's curved surface. |
| Spatial Indexing | GiST (reports_location_gist_idx) |
Efficient bounding-box search for hazard proximity lookups (ST_DWithin) and clustering. |
| Notifications | Firebase Cloud Messaging (FCM) | Push alerts for SOS dispatch; deviation-escalation push is part of this submission's in-progress work. |
Full technology deltas against the original synopsis (e.g. Leaflet vs. the synopsis's originally-named mapping library) are documented in docs/v1/tech-stack.md.
The project is configured as an npm workspace monorepo:
safora/
βββ apps/
β βββ backend/ # Express.js + TypeScript API server (Port 5000)
β β βββ src/
β β β βββ config/ # Database pool, diagnostics, environment
β β β βββ controllers/ # Route controllers (auth, reports)
β β β βββ middleware/ # Auth guards, validation, rate limiting
β β β βββ routes/ # Express routers (/api/auth, /api/reports)
β β β βββ app.ts # Server bootstrap & Socket.IO initialization
β β βββ .env
β β βββ package.json
β β
β βββ frontend/ # Vite + React + Tailwind Admin Console (Port 5173)
β β βββ src/
β β β βββ components/ # Command map, dispatch console, diagnostics
β β β βββ pages/ # Admin dashboard, incident moderation
β β β βββ services/ # Socket.IO client & API integration
β β βββ .env
β β βββ package.json
β β
β βββ mobile/ # React Native mobile application
β βββ android/ # Android Gradle project (New Arch, arm64-v8a ABI)
β βββ src/
β β βββ screens/ # UI screens (Home, Map, SafeWalk, Profile, Auth)
β β βββ navigation/ # RootNavigator (Native Stack)
β β βββ services/ # Location engine, API client (Axios)
β β βββ store/ # Zustand global state
β β βββ theme/ # Typography, colors, styles
β βββ metro.config.js # Monorepo resolution with extraNodeModules
β βββ package.json
β
βββ packages/
β βββ shared-types/ # Shared TypeScript interfaces (User, HazardReport, etc.)
β βββ src/
β βββ package.json
β
βββ docs/ # Technical documentation & Academic Synopsis
β βββ v1/ # This submission β architecture, API, DB, tasks, testing
β βββ v2/ # Post-submission product roadmap
β βββ v3/ # Research notes on synopsis future-scope items
β βββ archive/ # Earlier documentation drafts
β βββ setup.md # Developer setup & run guide
β βββ SAFORA_Synopsis_Formatted.pdf
β βββ README.md # Docs folder index
β
βββ README.md # Root repository documentation (this file)
- Node.js:
v20.xorv22.x&npm - PostgreSQL:
15+with thepostgisextension enabled (e.g. via Neon) - Android SDK: Platform 34/35, NDK
27.1.12297006, OpenJDK 17
From the root repository:
npm installOn a fresh database, initDatabase() creates the schema automatically on first backend start. On an existing database, apply the V1 migration once before starting the new backend build β see docs/v1/database.md Β§7 for the exact script.
cd apps/backend
npm run dev- API Base URL:
http://localhost:5000/api - Health Check:
http://localhost:5000/api/health - Live Diagnostics:
http://localhost:5000/api/diagnostics
Set INTERNAL_TICK_SECRET in apps/backend/.env before running β it protects the internal watchdog endpoint. See docs/v1/setup.md for the full list of new V1 environment variables.
In a second terminal:
cd apps/mobile
npm start -- --reset-cacheIn a third terminal:
cd apps/mobile
npm run androidTo package the standalone APK for physical testing without a local dev server:
cd apps/mobile/android
.\gradlew assembleDebugCompiled APK path:
apps/mobile/android/app/build/outputs/apk/debug/app-debug.apk (size will change as V1's background-service work lands; last verified build was ~59 MB, optimised for arm64-v8a)
To maintain high quality within the academic timeline, strict boundaries are enforced:
- Included in Minor Project-I Scope (see
docs/v1/for the exact task list):- Fully functional React Native mobile application, Android.
- Node.js/Express backend with Socket.IO real-time location streaming to guardians.
- PostgreSQL + PostGIS spatial querying (
ST_DWithin) and DBSCAN hazard clustering, rendered as a heatmap. - Safe Walk corridor compliance with both phone-side and server-side deviation escalation.
- One-tap SOS emergency alert dispatch, with background tracking that survives a locked screen.
- Administrative moderation and system diagnostics.
- Planned for the post-submission product roadmap (see
docs/v2/):- Account/session hardening, email verification, real per-mode routing with voice guidance, no-unlock SOS triggers, staged chat, Hindi/Uttarakhand localisation, weather & earthquake-aware safety scoring.
- Explicitly Out of Scope for now (see
docs/v3/for the research notes):- AI-based safe-route recommendation (lighting/crowd predictive models).
- Offline Bluetooth / Wi-Fi Direct mesh communication.
- AI image hazard detection from camera photos.
- Hardware wearable SOS device integration.
This project is developed as an academic Minor Project-I under the School of Engineering and Computing (SoEC), Dev Bhoomi Uttarakhand University (DBUU), Dehradun. All rights reserved by the project authors and institution.