Skip to content
dkrrish9Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

37 Commits

Folders and files

Repository files navigation

πŸ›‘οΈ SafeWalk

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.


✨ Key Features

πŸ—ΊοΈ AI-Powered Safe Route Navigation

  • 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

🚨 SOS Emergency System

  • 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

πŸ“‹ Blockchain-Secured Incident Reporting

  • 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

πŸ”” Alert History

  • 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

πŸ‘€ User Profile & Guardian Management

  • 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

πŸ—οΈ Tech Stack

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

πŸ“ Project Structure

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

πŸ”— API Endpoints

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)

Submit Report Fields

Field Type Required
lat number βœ…
lng number βœ…
incident_type string βœ…
description string ❌
suspect_name string ❌
evidence_file file βœ…

Submit Report Response

{
  "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."
}

πŸš€ Setup & Installation

Prerequisites

  • Android Studio (Hedgehog or later)
  • JDK 17+
  • Firebase project with Firestore, Auth, and FCM enabled

Steps

  1. Clone the repository

    git clone https://github.com/your-username/SafeWalk.git
    cd SafeWalk
  2. Firebase Setup

    • Create a Firebase project at console.firebase.google.com
    • Enable Google Sign-In in Authentication
    • Enable Cloud Firestore
    • Download google-services.json and place it in app/
  3. API Keys

    • Add your Mapbox access token in local.properties:
      MAPBOX_ACCESS_TOKEN=pk.your_mapbox_token_here
  4. Build & Run

    ./gradlew assembleDebug

    Or open in Android Studio and click ▢️ Run.


πŸ”’ Security Features

  • 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

πŸ‘₯ Contribution And Description

Krrish - Core Architecture & Navigation

β€’ 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.

Arijeet - ML Integration & Backend

β€’ 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.

Manjeet - UI/UX Engineering & Refinement

β€’ 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.

Aranya - Blockchain & Decentralized Storage

β€’ 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) image

β€’ API Testing Interface For Backend image image


πŸ† Built For

Hackofiesta 2026 β€” ML Track


πŸ“„ License

This project is built for demonstration and hackathon purposes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages