Skip to content

About

A real-time, AI-driven disaster response and relief coordination system designed to connect disaster victims with nearby, skilled volunteers and manage resources efficiently during emergencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

๐Ÿš€ Smart Resource Allocation & Trust Protocol (SRA-TP)

Hackathon Project Tech Stack Aesthetics

A real-time, AI-driven disaster response, relief coordination, and immutable trust validation system. It connects victims with nearby skilled volunteers while ensuring corruption-free aid tracking and tamper-proof reputation verification using a hybrid Web2/Web3 architecture.


๐ŸŒ Deployed Link


๐Ÿ“Œ Table of Contents

  1. ๐Ÿ“– Problem & Use Case
  2. ๐Ÿ’ก Concept & Architecture
  3. ๐Ÿ› ๏ธ Tech Stack
  4. ๐ŸŒŸ Key Features
  5. ๐ŸŽ›๏ธ How the Hybrid Flow Works
  6. ๐Ÿ”— Smart Contract & Blockchain Specifications
  7. โš™๏ธ Local Setup & Installation
  8. ๐Ÿ“Š Volunteer Matching Algorithm
  9. ๐Ÿ”ฎ Future Scope
  10. ๐Ÿ“ Directory Structure

๐Ÿ“– Problem & Use Case

During natural or man-made disasters (e.g., floods, earthquakes, industrial accidents), relief efforts are often plagued by:

  • Chaotic Communication & Language Barriers: Victims send pleas for help in local dialects, Hinglish, or regional languages, which slows categorization.
  • Inefficient Volunteer Allocation: Responders are dispatched without skill-matching or proximity awareness, leading to resource bottlenecks.
  • Relief Supply Corruption & Black Markets: Lack of traceability allows emergency inventory (food, medical kits) to be diverted, lost, or hoarded without clear accountability.
  • Fake Reviews & Rating Inflation: Bad-faith actors can inflate volunteer ratings or fabricate emergency completions.
  • Low Connectivity Barriers: Traditional complex web forms fail in zones where internet speeds drop, making offline SMS gateway integrations vital.

๐Ÿ’ก Concept & Architecture: The Hybrid Web2/Web3 "Trust Layer"

To solve this, the Smart Resource Allocation & Trust Protocol separates operations into a high-performance database tier and a permanent blockchain validator tier:

  1. Web2 Speed & Performance (Firebase Firestore + Google Gemini AI): Handles real-time communication, duplicate clustering, SMS mapping, Leaflet maps, and instant UI responsiveness.
  2. Web3 Trust Layer (L2 EVM Ledger / Arbitrum Sepolia): Every time a volunteer resolves a crisis, the action is anchored on-chain. Supply packs are represented as ERC-1155 semi-fungible tokens, tracking inventory transfer from NGO donors to volunteers and finally to the victim. Volunteer feedback and ratings are permanently minted as ERC-721 Soulbound Tokens (SBTs), preventing review manipulation.

๐Ÿ› ๏ธ Tech Stack

Component Technology Description
Backend Node.js + Express.js High-concurrency APIs, SMS routing, and blockchain interactions.
Database Firebase Firestore NoSQL cloud database for high-frequency logs, map coordinates, and active UI sync.
AI / NLP Google Gemini 2.5 Flash Translates regional dialects, extracts categories (Food, Medical, Shelter), and assigns urgency scores (1-5).
Smart Contracts Solidity (^0.8.20) The logic engine of the Trust Layer (RescueTrust.sol) implementing ERC-1155 and Custom SBTs.
Web3 Interface ethers.js (v6) Connects the backend server seamlessly to any L2 EVM network (or local fallback).
Frontend UI HTML5, CSS3, ES6+ JS, Leaflet.js Glassmorphic Dark UI, interactive maps with pulsating status nodes, and real-time step trackers.
Security Express Rate Limit Anti-spam and request throttling for victim forms, SMS, and restocks.

๐ŸŒŸ Key Features

๐Ÿง  Core System Features

  • AI-Powered dialect parsing: Converts regional text (Hindi, Marathi, Hinglish, English) into structured data with urgency indexing.
  • Interactive Dark Mode Map View: Powered by Leaflet.js and CartoDB Dark Matter. Plots active requests as color-coded, pulsating markers (pulsing faster for higher urgency).
  • Duplicate Request Clustering: Prevents double-dispatch by grouping reports with high spatial/semantic similarity.
  • Offline SMS Simulator: Parses simulated incoming SMS messages, leveraging Gemini to extract locations, category, and priority.
  • Dynamic Kanban Dashboard: Real-time drag-and-drop workflow status updates.

โ›“๏ธ Web3 Trust Layer Features

  • ERC-1155 Tokenized Relief Packs: Supply items (Food=1, Medical=2, Shelter=3, Other=4) are minted and tracked on-chain. When a request is resolved, tokens are transferred from the NGO to the volunteer.
  • Non-Transferable Soulbound Tokens (SBTs): Volunteer ratings and feedback are minted into immutable ERC-721-compliant SBTs associated with the volunteer's wallet. They cannot be traded, sold, or modified, creating a permanent reputation score.
  • Simulated L2 EVM Ledger & Block Explorer: In the absence of live RPC nodes, the backend activates a built-in persistent L2 simulator, writing transactions to a local ledger. The dashboard renders a real-time block explorer, displaying current block height, hash history, and gas stats.
  • Victim Delivery Confirmation: When victims mark a request as resolved, they sign off on the feedback. The system then mints the volunteer's SBT on-chain, proving the supply pack was delivered.

๐ŸŽ›๏ธ How the Hybrid Flow Works

                                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                  โ”‚  Victim Submits Crisis   โ”‚ (Web or SMS Simulator)
                                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                               โ”‚
                                               โ–ผ
                                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                  โ”‚   Google Gemini 2.5 AI   โ”‚ (Extracts urgency, category, translations)
                                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                               โ”‚
                                               โ–ผ
                                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                  โ”‚    Matching Engine       โ”‚ (Pairs with closest, skilled volunteer)
                                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                               โ”‚
                                               โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚                                                                                           โ”‚
 โ–ผ                                                                                           โ–ผ
 [WEB2 PERSISTENCE LAYER]                                                    [WEB3 TRUST LAYER (EVM / L2)]
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚    Firebase Firestore    โ”‚ (Realtime UI updates)                          โ”‚  Supply Pack Minted      โ”‚ (ERC-1155)
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚                                                                           โ”‚
             โ–ผ                                                                           โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚   Volunteer Resolves     โ”‚ (NGO confirms task)                            โ”‚  Transfer to Volunteer   โ”‚ (On-chain receipt)
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚                                                                           โ”‚
             โ–ผ                                                                           โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  Victim Signs Feedback   โ”‚ (Submits rating)                               โ”‚  Mint Reputation SBT     โ”‚ (ERC-721 Soulbound)
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”— Smart Contract & Blockchain Specifications

The system utilizes RescueTrust.sol to run its trust layer:

  • State Ledger (RescueRecord): Stores requestId, volunteer address, category, hours worked, and victim rating on-chain.
  • SBT Minting (mintSBT): Creates non-transferable ERC-721 tokens (VRES-SBT) verifying volunteer performance. Overrides transferFrom and approvals to revert, keeping tokens locked to the volunteer's address.
  • ERC-1155 Supplies (mintSupply & transferSupply):
    • Token ID 1: Food Packs
    • Token ID 2: Medical Kits
    • Token ID 3: Shelter Kits
    • Token ID 4: Other Supplies

โš™๏ธ Local Setup & Installation

Prerequisites

  • Node.js (v18.x or higher)
  • npm (bundled with Node)
  • Google Gemini API Key (Get one at Google AI Studio)
  • Firebase Project with Firestore Database enabled.

1. Clone & Enter Directory

git clone https://github.com/nityamm-coder/Smart-Resource-Allocation.git
cd Smart-Resource-Allocation

2. Install Dependencies

npm install

3. Setup Environment Variables

Create a .env file in the root directory:

PORT=3000
GEMINI_API_KEY=your_gemini_api_key_here

# Firebase Admin Credential JSON as a single-line string:
FIREBASE_SERVICE_ACCOUNT_KEY='{"type": "service_account", "project_id": "...", "private_key_id": "...", "private_key": "...", ...}'

# OPTIONAL: Configure live L2 EVM Blockchain (e.g., Arbitrum Sepolia)
# If left blank, the system automatically falls back to the persistent simulated local ledger
BLOCKCHAIN_PROVIDER_URL=https://sepolia-rollup.arbitrum.io/rpc
BLOCKCHAIN_PRIVATE_KEY=your_wallet_private_key_here
BLOCKCHAIN_CONTRACT_ADDRESS=your_deployed_rescue_trust_contract_address

4. Run the Project

  • Development Mode (Auto-reloads server):
    npm run dev
  • Production Mode:
    npm start

Open your browser to:


๐Ÿ“Š Volunteer Matching Algorithm

Every crisis submission invokes a real-time matching query:

  1. Available Filter: Filters out volunteers currently assigned to any unresolved (Open/In Progress) request to ensure single-task dedication.
  2. Weighted Scoring:
    • Category Match (+2 Points): Volunteer holds specific skills corresponding to the crisis (e.g., medical expertise).
    • Zone Match (+1 Point): Volunteer is located within the geographic neighborhood of the victim.
  3. Execution: The highest-scoring volunteer is assigned. If no available volunteers match, the request remains open for manual dispatch by the NGO.

๐Ÿ”ฎ Future Scope

  • Real-world SMS Gateway: Hooking the Express endpoints into Twilio/Africa's Talking API to support physical mobile text inputs.
  • Multi-Signature Aid Approvals: Require cryptographic signatures from both the NGO coordinator and the field volunteer before high-value supplies (e.g. specialized medical devices) are released on-chain.
  • Decentralized Identifiers (DIDs): Integrating DID/VC models for victims to request aid anonymously while preserving data privacy.
  • Routing Optimization: Adding Mapbox/OSRM routing engines to map the fastest routes for volunteers to bypass flood zones.

๐Ÿ“ Directory Structure

smart-resource-allocation/
โ”œโ”€โ”€ contracts/
โ”‚   โ””โ”€โ”€ RescueTrust.sol   # Solidity Smart Contract (Reputation SBTs & Supply Tracking)
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ index.html        # Victim Form (Dialect Translation & Urgency Classification)
โ”‚   โ”œโ”€โ”€ dashboard.html    # Coordinator Panel, L2 Block Explorer, CartoDB Interactive Map
โ”‚   โ”œโ”€โ”€ tracking.html     # Live Request timeline & feedback gateway
โ”‚   โ”œโ”€โ”€ app.js            # Frontend interactions and updates
โ”‚   โ””โ”€โ”€ style.css         # Styling with Dark glassmorphism elements
โ”œโ”€โ”€ server.js             # API backend, matching engine, and Gemini routing
โ”œโ”€โ”€ blockchainService.js  # L2 Provider layer & local persistent EVM simulator
โ”œโ”€โ”€ .local_blockchain.json# Persisted transaction ledger for simulated environment
โ”œโ”€โ”€ package.json          # Node dependencies
โ””โ”€โ”€ vercel.json           # Cloud deployment instructions

Coding Today! Engineering Tomorrow!

Made By: Nityam Mishra
Email: nityamm2005@gmail.com
GitHub: nityamm-coder

About

A real-time, AI-driven disaster response and relief coordination system designed to connect disaster victims with nearby, skilled volunteers and manage resources efficiently during emergencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages