Skip to content

rajanithii/AI-EMERGENCY-ALERT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚨 LifeLine β€” AI Emergency SOS Alert System

LifeLine Banner Python FastAPI SQLAlchemy AI Powered Status

"Every second counts. LifeLine makes sure help is already on the way."

A real-time AI-powered emergency alert system that connects patients to the nearest hospital β€” automatically, intelligently, instantly.

πŸš€ Features β€’ 🧠 How It Works β€’ βš™οΈ Tech Stack β€’ πŸ› οΈ Setup β€’ πŸ“Έ Screenshots β€’ πŸ—ΊοΈ Roadmap


🌟 What is LifeLine?

LifeLine is an AI-powered emergency SOS web application built to bridge the critical gap between someone in distress and the nearest available hospital β€” in under 10 seconds.

When a user triggers an SOS:

  • A 5-second countdown gives them a chance to cancel accidental triggers
  • Their GPS location is captured automatically
  • Their pre-registered medical conditions are sent to the API
  • The AI finds the shortest-distance hospital using routing analysis
  • The hospital receives an instant real-time alert with patient details and location

πŸ’‘ Built as a Hackathon project. Designed for real-world deployment in India's emergency response ecosystem.


πŸš€ Features

Feature Description
πŸ†˜ One-Tap SOS Single button triggers the entire emergency flow
⏱️ 5-Second Safety Countdown Prevents accidental alerts with a cancellable timer
πŸ“ Auto GPS Location Capture Browser geolocation API captures exact coordinates
🧠 AI Hospital Routing Finds shortest-distance hospital using pre-registered medical data
πŸ₯ Hospital Dashboard Real-time alert receiver for hospital staff
πŸ—ΊοΈ Live Alert Map Real-time map showing active SOS locations
πŸ“‹ Medical Profile Integration Pre-registered conditions sent with every alert
πŸ” Encrypted Data Patient data encrypted using cryptography library
⚑ Real-time Updates Instant sender ↔ receiver communication

🧠 How It Works

USER PRESSES SOS BUTTON
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  5-Second Countdown β”‚  ← User can cancel if accidental
β”‚  ⏱️  5 4 3 2 1...   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ (not cancelled)
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  GPS Location        β”‚  ← Browser Geolocation API
β”‚  πŸ“ lat, lng capture β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI Analysis (FastAPI Backend)       β”‚
β”‚  β€’ Patient's pre-registered          β”‚
β”‚    medical conditions                β”‚
β”‚  β€’ Location coordinates              β”‚
β”‚  β€’ Distance to all registered        β”‚
β”‚    hospitals                         β”‚
β”‚  β†’ Returns: Nearest suitable hospitalβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Patient sees:       β”‚     β”‚  Hospital receives:   β”‚
β”‚  βœ… Alert sent       β”‚     β”‚  πŸ”” SOS Notification  β”‚
β”‚  πŸ₯ Hospital name    β”‚     β”‚  πŸ“ Patient location  β”‚
β”‚  πŸ“ Distance/ETA    β”‚     β”‚  🩺 Medical conditionsβ”‚
β”‚  πŸ—ΊοΈ Live map        β”‚     β”‚  ⏰ Time of alert     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βš™οΈ Tech Stack

Backend

Technology Purpose
Python 3.10+ Core language
FastAPI High-performance REST API framework
SQLAlchemy ORM for database operations
SQLite Lightweight database (upgradeable to PostgreSQL)
Uvicorn ASGI server
cryptography Patient data encryption
python-dotenv Environment variable management
requests External API calls for routing

Frontend

Technology Purpose
HTML5 / CSS3 Structure and styling
JavaScript SOS countdown, geolocation, real-time updates
Geolocation API Browser GPS capture
Leaflet.js / Maps API Live alert map visualization

πŸ› οΈ Local Setup

Prerequisites

  • Python 3.10+
  • pip
  • Git

Step 1: Clone the Repository

git clone https://github.com/<your-username>/lifeline.git
cd lifeline

Step 2: Create Virtual Environment

python -m venv .venv

# Windows PowerShell
.venv\Scripts\Activate.ps1

# Windows CMD
.venv\Scripts\activate.bat

# Mac / Linux
source .venv/bin/activate

Step 3: Install Dependencies

pip install fastapi uvicorn sqlalchemy requests python-dotenv cryptography

Step 4: Set Up Environment Variables

cp .env.example .env
# Edit .env with your configuration

Step 5: Initialize Database

python -c "from newalert.backend.database import init_db; init_db()"

Step 6: Run the Server

# Development (localhost β€” allows browser geolocation)
python -m uvicorn newalert.backend.main:app --reload --host 127.0.0.1 --port 8000

Step 7: Open in Browser

http://127.0.0.1:8000

⚠️ Note: Browsers require HTTPS for geolocation on non-localhost origins. Use localhost for development or deploy with HTTPS for production.


πŸ“ Project Structure

lifeline/
β”œβ”€β”€ newalert/
β”‚   └── backend/
β”‚       β”œβ”€β”€ main.py          ← FastAPI app entry point
β”‚       β”œβ”€β”€ database.py      ← SQLAlchemy models & DB init
β”‚       β”œβ”€β”€ routes/
β”‚       β”‚   β”œβ”€β”€ alert.py     ← SOS alert endpoints
β”‚       β”‚   └── hospital.py  ← Hospital dashboard endpoints
β”‚       └── utils/
β”‚           β”œβ”€β”€ geo.py       ← Distance calculation & routing
β”‚           └── encrypt.py   ← Data encryption utilities
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html           ← User SOS page
β”‚   β”œβ”€β”€ hospital.html        ← Hospital dashboard
β”‚   └── static/
β”‚       β”œβ”€β”€ style.css
β”‚       └── app.js           ← Countdown, geolocation logic
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ requirements.txt
└── README.md

πŸ” Security & Privacy

  • βœ… Patient medical data is encrypted before storage
  • βœ… .env, certs/, and lifeline.db are gitignored β€” never committed
  • βœ… Location data is only used during active alert β€” not stored permanently
  • βœ… Hospital access is authenticated β€” no public access to patient data

πŸ—ΊοΈ Roadmap

  • SOS button with 5-second countdown
  • GPS location capture
  • AI-powered nearest hospital routing
  • Hospital real-time alert dashboard
  • Live alert map
  • Medical profile integration
  • πŸ”œ SMS/WhatsApp notification to family contacts
  • πŸ”œ Deploy on AWS EC2 with HTTPS
  • πŸ”œ Mobile PWA (installable on phone)
  • πŸ”œ Multi-language support (Tamil, Hindi)
  • πŸ”œ Ambulance tracking integration
  • πŸ”œ Voice-activated SOS trigger

πŸ† Built For

Inter-College Hackathon 2025 β€” Problem Statement: AI Solutions for Rural Healthcare

πŸ₯‡ Selected to represent college | Successfully built & demonstrated working prototype


🀝 Contributing

Pull requests are welcome! For major changes, please open an issue first.

git checkout -b feature/your-feature-name
git commit -m "Add: your feature description"
git push origin feature/your-feature-name

πŸ‘¨β€πŸ’» Author

Rajanithi N

  • πŸŽ“ AI & Data Science Student β€” Dhanalakshmi Srinivasan University
  • πŸ“§ rajanithiff@gmail.com
  • πŸ… IBM | Google | Microsoft | AWS Certified (Coursera)

πŸ“„ License

This project is licensed under the MIT License.


⭐ If LifeLine helped or inspired you, give it a star!

Built with ❀️ to save lives

About

Many emergency deaths happen due to delay in reaching the right hospital. During critical situations, people waste valuable time searching for hospitals, checking availability, and arranging ambulances. There is no smart system that instantly connects patients to the most suitable hospita

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors