Skip to content

Latest commit

ย 

History

History
122 lines (82 loc) ยท 3.14 KB

File metadata and controls

122 lines (82 loc) ยท 3.14 KB

๐Ÿšจ SOS Emergency Response Backend

This is the backend service for the SOS Emergency Response System, built using Node.js, Express.js, and Supabase. It powers emergency data processing, AI-based request validation, secure user authentication, and communication with the officials' dashboard.


๐Ÿš€ Features

  • ๐Ÿ“ค Image Upload API โ€“ Uploads and stores emergency images for AI validation.
  • ๐Ÿง  AI Verification โ€“ Integrates with a YOLOv8 model (external) to classify emergencies.
  • ๐Ÿ” Authentication โ€“ Auth flow with Supabase Auth.
  • ๐Ÿ“ Geolocation API โ€“ Stores and fetches user/emergency coordinates.
  • ๐Ÿ”— Encrypted Database Sync โ€“ Emergency data is AES-encrypted before being stored in Supabase.
  • ๐Ÿ‘ฎ Official Review System โ€“ Officials fetch and decrypt reports via a secure dashboard.

๐Ÿ“ Project Structure

/routes/
  โ”œโ”€โ”€ fileUpload.ts       # Handles file/image uploads
  โ”œโ”€โ”€ requests.ts         # Emergency request logic
  โ”œโ”€โ”€ auth.ts             # Authentication routes
  โ””โ”€โ”€ locationsRouter.ts  # Location-based APIs

/config/
  โ””โ”€โ”€ supabase.ts         # Supabase client configuration

index.ts                 # Main Express app

โš™๏ธ Setup Instructions

1. Clone the repository

git clone https://github.com/your-username/sos-backend.git
cd sos-backend

2. Install dependencies

npm install

3. Configure environment variables

Create a .env file in the root:

SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_service_key

4. Start the server

npm run dev     # for development using ts-node
# or
npm run build && npm start   # for production

Server runs on: http://localhost:5000


๐Ÿงช API Endpoints

POST /upload

Upload emergency-related image or video (handled by fileUploadRouter).

POST /auth

Handles signup/login of users via Supabase.

POST /requests

Accepts emergency requests, including media and metadata.

GET /locations

Used by responders to receive real-time locations of emergencies.


๐Ÿ” AES Encryption Flow

  • After an image is uploaded and verified via ML,
  • The image is encrypted using AES encryption before being stored in the Supabase bucket.
  • When fetched by authorized officials, the data is decrypted in real-time on the official dashboard.

๐Ÿง‘โ€๐Ÿš’ Admin (Official) Workflow

  • Admins can view decrypted emergency requests.
  • They can accept or reject based on AI + manual review.
  • Only one responder can lock each request (no duplication).

๐Ÿ“ฆ Built With


๐Ÿ™‹ Author

Arpit Gupta
Feel free to reach out for collaboration or integration assistance.


๐Ÿ“„ License

This project is licensed under the MIT License.