AI-Powered Safety Route & Incident Reporting Platform
SafeWalk is a comprehensive safe route finder application that combines Machine Learning, Blockchain, and Real-Time Navigation to help people navigate cities safely and report incidents with tamper-proof evidence.
- Three-Route Comparison System β Queries Mapbox with Walking, Cycling, and Driving profiles to generate three distinct real-world paths
- ML Risk Scoring β Each route is independently evaluated by our FastAPI ML model that analyzes neighborhood safety based on crime data, lighting, and crowd density
- Color-Coded Visualization β Routes are rendered in Green (Safe), Yellow (Moderate), and Red (High Risk) directly on the map
- Interactive Selection β Tap any route on the map or its corresponding card to select it for navigation
- Collapsible Search UI β Input panel auto-collapses when routes are displayed to maximize map visibility
- 3-Second Hold to Trigger β Press and hold the SOS button with a visual progress ring
- Multi-Channel Alerts β Simultaneously sends SMS alerts to registered guardians and in-app notifications to nearby community members
- Police Notification β Auto-logs emergency alerts to the nearest police station
- Location Sharing β Shares real-time Google Maps location link with all recipients
- Immutable Evidence β Reports are permanently stored on the Ethereum Sepolia blockchain
- IPFS Storage β Evidence images are uploaded to Pinata/IPFS for decentralized storage
- Multipart Submission β Supports category, description, suspect name, GPS coordinates, and photo evidence
- Dual Storage β Reports are saved to both Firestore (for querying) and blockchain (for immutability)
- Verification Dialog β Shows Etherscan TX link and IPFS URL after each submission
- Guardian Alerts β View all SOS alerts received as a guardian
- Community Alerts β View nearby emergency alerts received as a community member
- Real-Time Updates β Powered by Firestore snapshot listeners
- Quick Action β Tap any alert to open the victim's location in Google Maps
- Google Sign-In β Seamless authentication via Firebase Auth
- Guardian System β Add/remove emergency contacts who receive SOS alerts
- Community Mode β Opt-in to receive nearby emergency alerts from other users
- Anonymous Reporting β Cryptographic identity protection for reporters
| Layer | Technology |
|---|---|
| Frontend | Kotlin, Android SDK, ViewBinding |
| Maps | OSMDroid (OpenStreetMap) |
| Routing | Mapbox Directions API (Walking/Cycling/Driving profiles) |
| ML Backend | FastAPI + Python ML Model (deployed on Render) |
| Blockchain | Ethereum Sepolia Testnet, Solidity Smart Contracts |
| File Storage | Pinata (IPFS) for evidence images |
| Database | Firebase Firestore |
| Authentication | Firebase Auth (Google Sign-In) |
| Notifications | Firebase Cloud Messaging (FCM) |
| SMS | Android SmsManager |
| Networking | Retrofit2 + OkHttp + Gson |
| Architecture | MVVM + Navigation Component + SafeArgs |
app/src/main/java/com/example/safewalk/
βββ data/
β βββ model/
β β βββ MLModels.kt # ML prediction request/response
β β βββ Report.kt # Incident report data model
β βββ network/
β βββ MLApiService.kt # ML prediction API (POST /predict)
β βββ BlockchainApiService.kt # Web3 API (POST /api/reports/submit)
β βββ RetrofitClient.kt # Retrofit instances (ML + Blockchain)
βββ service/
β βββ MyFirebaseMessagingService.kt # FCM push notifications
βββ ui/
β βββ alerts/
β β βββ AlertsFragment.kt # Alert history (Guardian + Community)
β βββ auth/
β β βββ AuthActivity.kt # Google Sign-In flow
β βββ dialogs/
β β βββ GuardianSheet.kt # Add/manage guardians bottom sheet
β β βββ SOSDialog.kt # Emergency SOS trigger dialog
β βββ home/
β β βββ HomeFragment.kt # Dashboard with quick actions
β βββ map/
β β βββ MapFragment.kt # Map + 3-route comparison system
β βββ profile/
β β βββ ProfileFragment.kt # User profile & settings
β βββ report/
β βββ ReportFragment.kt # Incident report form
β βββ ReportPreviewFragment.kt # Preview + blockchain submission
β βββ ReportsListFragment.kt # All/My Reports with filters
β βββ ReportAdapter.kt # Report card RecyclerView adapter
β βββ ReportViewModel.kt # Report form state management
βββ MainActivity.kt # Navigation host + bottom nav
Base URL: https://ml-api-6v4v.onrender.com
| Method | Endpoint | Description |
|---|---|---|
POST |
/predict |
ML route safety prediction (JSON) |
POST |
/api/reports/submit |
Submit incident to blockchain (multipart/form-data) |
POST |
/api/reports/resolve |
Resolve a blockchain report (JSON) |
| Field | Type | Required |
|---|---|---|
lat |
number | β |
lng |
number | β |
incident_type |
string | β |
description |
string | β |
suspect_name |
string | β |
evidence_file |
file | β |
{
"status": "success",
"blockchain_receipt": "https://sepolia.etherscan.io/tx/0x...",
"ipfs_url": "https://gateway.pinata.cloud/ipfs/Qm...",
"resolution_secret": "a8008120aaed...",
"message": "Report successfully filed on-chain and cached for ML mapping."
}- Android Studio (Hedgehog or later)
- JDK 17+
- Firebase project with Firestore, Auth, and FCM enabled
-
Clone the repository
git clone https://github.com/your-username/SafeWalk.git cd SafeWalk -
Firebase Setup
- Create a Firebase project at console.firebase.google.com
- Enable Google Sign-In in Authentication
- Enable Cloud Firestore
- Download
google-services.jsonand place it inapp/
-
API Keys
- Add your Mapbox access token in
local.properties:MAPBOX_ACCESS_TOKEN=pk.your_mapbox_token_here
- Add your Mapbox access token in
-
Build & Run
./gradlew assembleDebug
Or open in Android Studio and click
βΆοΈ Run.
- Blockchain Immutability β Reports cannot be altered or deleted once submitted to Ethereum
- IPFS Evidence β Evidence images are stored on a decentralized network, preventing censorship
- Anonymous Authentication β Cryptographic identity protection for reporters
- End-to-End SMS β Emergency alerts sent via device SMS for reliability when internet is unavailable
- Resolution Secret β Only the original reporter can resolve/close their report using a unique secret key
β’ Type-Safe Navigation: Implemented the Jetpack Navigation Component using a centralized nav_graph.xml. Utilized SafeArgs for robust, type-safe data passing between fragments, reducing runtime crashes during screen transitions.
β’ Modular UI Design: Developed a fragment-based architecture using View Binding, ensuring a responsive and memory-efficient user interface. Safety & Geospatial Integration
β’ Geospatial Implementation: Integrated Mapbox SDK and OpenStreetMap (osmdroid) to provide real-time location tracking and navigation features.
β’ Emergency Systems: Developed the SOS Alert System and Community Mode, enabling rapid emergency responses and user-to-user safety networking.
β’ Device Integration: Leveraged the Android Contacts API (Content Providers) to allow seamless integration of local device contacts into the app's "Trusted Contacts" list.
β’Blockchain Integration: Implemented a permanent incident reporting system by connecting to a Web3/Blockchain API using Retrofit and OkHttp.
β’ Data Resiliency: Engineered complex GSON models with @SerializedName alternates to handle varied backend JSON structures, ensuring that critical data like Transaction Hashes and Report IDs are always accurately captured and displayed.
β’ Firebase Middleware: Integrated Firebase Authentication (Google Auth) and Cloud Firestore for secure, real-time user data management.
β’ Designed and implemented the machine learning pipeline for safety prediction using an XGBoost classifier trained on geospatial crime data.
β’ Performed feature engineering, including temporal encoding, complaint density, severity metrics, and spatial features like distance to police stations.
β’ Developed a route-based inference system that breaks a path into coordinate points, predicts risk for each segment, and aggregates them into an overall safety score.
β’ Built the FastAPI backend for real-time ML inference, including feature extraction, prediction endpoints, and structured responses with segment-wise risk analysis.
β’ Interface Optimization: Executed precise UI refinements by optimizing layout padding and typography scales across the application, ensuring a consistent and accessible user experience in accordance with Material Design principles.
β’ Component Styling: Standardized UI elements within the Report Fragment and SOS Dialog to enhance visual hierarchy and readability.
β’ Functional Logic & Feature Development
β’ Feature Implementation: Developed and integrated the Report Preview page, providing users with a critical validation step to verify incident details before they are finalized and committed to the blockchain.
β’ Emergency Functional Logic: Engineered the "Call Police" integration within the SOS Dialog, bridging the gap between digital alerts and immediate physical safety resources.
β’ Event Handling: Implemented the selection logic and state management for category buttons in the Report Fragment, ensuring accurate data capture for incident reporting.
β’ Stability & Debugging
β’ Fragment Lifecycle Management: Resolved critical issues within the Report Fragment, improving the stability of the reporting flow and ensuring reliable user input handling.
β’ Collaborative Refinement: Performed iterative bug fixes and UI adjustments based on testing, contributing to the overall polish and production readiness of the application.
β’ Immutable Incident Logging: Engineered a tamper-proof reporting system powered by Ethereum (Sepolia Testnet), ensuring that all safety reports are permanently recorded and cannot be altered or deleted.
β’ Decentralized Evidence Storage: Integrated Pinata (IPFS) for decentralized, content-addressed storage of media evidence, ensuring high availability and data persistence outside of traditional centralized databases.
β’Cryptographic Data Integrity: Implemented SHA-3 (Keccak-256) hashing to anchor suspect data and media CIDs on-chain, creating a verifiable link between the blockchain record and the stored IPFS content.
β’Smart Contract Interaction Layer: Developed a robust backend bridge using Web3.py to handle automated transaction signing, gas management, and interaction with the SafetyReports smart contract.
β’Anonymous Resolution Protocol: Designed a secure Zero-Knowledge-inspired resolution mechanism using hashed tokens, allowing users to verify or resolve reports anonymously without exposing sensitive identifiers.
β’On-Chain Transparency: Integrated automated transaction tracking, providing users with Etherscan receipts and IPFS gateways for real-time verification of filed reports.
β’ Evidences Stored In Pinata In Hashed Format (CID)

β’ API Testing Interface For Backend

Hackofiesta 2026 β ML Track
This project is built for demonstration and hackathon purposes.