Skip to content

KGFCH2/LifeLine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

168 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚨 LifeLine+

LifeLine+ β€” Real-time Emergency Response Platform for India

Google Solution Challenge Hack2Skill

LifeLine+

React 18 Vite 5 Node.js Express Socket.io Google Maps Gemini AI Firebase


                    β–ˆβ–ˆβ•—     β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ•—     β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—+
                    β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•    β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•+
                    β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—      β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  +
                    β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β•      β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  +
                    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—+
                    β•šβ•β•β•β•β•β•β•β•šβ•β•β•šβ•β•     β•šβ•β•β•β•β•β•β•    β•šβ•β•β•β•β•β•β•β•šβ•β•β•šβ•β•  β•šβ•β•β•β•β•šβ•β•β•β•β•β•β•+

                                "Saving minutes. Saving lives."

LifeLine+ is a production-ready full-stack emergency response platform built for India. It accelerates crisis coordination in hospitality and public spaces by combining real-time ambulance tracking, smart hospital discovery, traffic-aware routing, police alerts, doctor bookings, and AI-powered emergency verification β€” all in one unified mobile-first experience.

🌍 Live Deployment

The platform is successfully deployed on two different cloud stacks:

☁️ Google Cloud Run Stack

⚑ Hybrid Stack (Vercel + Render)


🧭 Problem Statement

[Rapid Crisis Response] Accelerated Emergency Response and Crisis Coordination in Hospitality

This project is our submission for the Google Solution Challenge 2026, hosted on the Hack2Skill platform.

Emergency response often breaks down because nearby services, traffic-aware routes, ambulance availability, police coordination, and verified civilian help are disconnected. LifeLine+ turns those fragmented steps into one live, mobile-first emergency workflow.

✨ Core Features

Area Implementation
πŸ“ Smart Discovery Browser geolocation + Google Places API for hospitals, doctors, police, and pharmacies
πŸ—ΊοΈ Maps Google Maps JS API, markers, route polylines, traffic layer, dark mode, 2D/tilted satellite 3D toggle
πŸš‘ Emergency Flow Auto-select nearest open hospital, fetch alternate Directions API routes, rank fastest by traffic ETA
🚐 Ambulance Booking Stable zone-based ambulance fleet, 5-minute production acceptance window, Socket.io live GPS simulation
πŸš— Civilian Mode Gemini validates vehicle number, purpose, and contact before temporary emergency activation
πŸš“ Police Alerts Google Places police station detection around route points, alert broadcast through Socket.io
πŸ₯ Doctors Google Places-backed nearby doctor/clinic discovery, specialty filter, slots, booking confirmation
πŸ” Auth Firebase Google sign-in primary flow + email/name localStorage fallback session
⚑ UX Blinkit/Uber-inspired card UI, sticky bottom nav, floating SOS, voice trigger, PWA support

🧱 Tech Stack

Layer Tools
Frontend React 18, Vite, React Router, Tailwind CSS, Vite PWA, Firebase Web SDK
Maps Google Maps JavaScript API, Places API, Directions API, Distance Matrix API
Realtime Socket.io client/server
Backend Node.js, Express, Helmet, CORS, Compression, Morgan
AI Gemini 1.5 Flash through backend API
Persistence Optional Firebase Admin Firestore writes with in-memory fallback
Deploy Successfully deployed on Google Cloud Run and Vercel+Render

πŸ“ Folder Structure

Life_Line/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ firebaseAdmin.js
β”‚   β”‚   └── googleMaps.js
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ ambulance.js
β”‚   β”‚   β”œβ”€β”€ booking.js
β”‚   β”‚   β”œβ”€β”€ police.js
β”‚   β”‚   β”œβ”€β”€ routes.js
β”‚   β”‚   β”œβ”€β”€ services.js
β”‚   β”‚   └── verify.js
β”‚   β”œβ”€β”€ sockets/
β”‚   β”‚   └── handlers.js
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ .env.example
β”‚   β”œβ”€β”€ package.json
β”‚   └── server.js
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── lifeline.svg
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ index.css
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ .env.example
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”œβ”€β”€ ARCHITECTURE.md
β”œβ”€β”€ CORE_LOGIC.md
β”œβ”€β”€ INSTRUCTIONS.md
β”œβ”€β”€ LICENSE
└── README.md

βš™οΈ Quick Start

1. Backend

cd backend
cp .env.example .env
npm install
npm run dev

Backend runs on http://localhost:5000.

2. Frontend

cd frontend
cp .env.example .env
npm install
npm run dev

Frontend runs on http://localhost:5173.

3. Health Check

curl http://localhost:5000/api/health

πŸ”‘ Environment Variables

Private secrets belong only in .env. The committed .env.example files use placeholders.

Backend .env

PORT=5000
GOOGLE_MAPS_API_KEY=your_google_maps_api_key
GEMINI_API_KEY=your_gemini_api_key
FIREBASE_PROJECT_ID=your_firebase_project_id
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nyour_key\n-----END PRIVATE KEY-----\n"
FIREBASE_CLIENT_EMAIL=your_service_account_email
FRONTEND_URL=http://localhost:5173
NODE_ENV=development
DRIVER_RESPONSE_TIMEOUT_MS=5000

Frontend .env

VITE_GOOGLE_MAPS_API_KEY=your_google_maps_api_key
VITE_GEMINI_API_KEY=your_gemini_api_key
VITE_FIREBASE_API_KEY=your_firebase_web_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_project.firebasestorage.app
VITE_FIREBASE_MESSAGING_SENDER_ID=000000000000
VITE_FIREBASE_APP_ID=1:000000000000:web:0000000000000000000000
VITE_FIREBASE_MEASUREMENT_ID=G-XXXXXXXXXX
VITE_BACKEND_URL=http://localhost:5000

πŸ“‘ API Endpoints

Method Endpoint Purpose
GET /api/health Server, Firebase, Maps, Gemini status
GET /api/nearest-services Google Places nearby hospitals, police, doctors, pharmacies
GET /api/nearest-services/details/:placeId Place details
GET /api/routes/emergency Directions API routes with traffic ETA
GET /api/routes/traffic Distance Matrix traffic probe
GET /api/ambulance-request/nearby Nearby ambulances from live fleet state
POST /api/ambulance-request/request Create emergency ambulance request
GET /api/ambulance-request/request/:requestId Request status
POST /api/ambulance-request/location-update Driver GPS update
POST /api/verify/civilian Gemini civilian emergency verification
POST /api/verify/chat Gemini emergency assistant through backend
GET /api/booking/doctors Places-backed doctor discovery
GET /api/booking/slots/:doctorId Appointment slots
POST /api/booking/appointment Book doctor appointment
GET /api/police/stations Nearby police stations from Places API
POST /api/police/alert Police alert with route context

πŸš€ Deployment

Frontend on Vercel

cd frontend
npm run build

Set every VITE_* variable in Vercel Project Settings before deploying.

Backend on Render

cd backend
npm start

Set backend env variables in Render. Use NODE_ENV=production for the real 5-minute ambulance response window.

πŸ§ͺ Verification

Recommended checks before deployment:

cd backend && npm start
cd frontend && npm run build

Manual flow to validate:

  1. Open http://localhost:5173.
  2. Allow location access.
  3. Sign in with Firebase Google or email fallback.
  4. Open Emergency Mode.
  5. Confirm nearest hospital route and route alternatives.
  6. Book ambulance and watch Socket.io tracking updates.
  7. Test Civilian Mode and police alert activation.
  8. Book a doctor appointment.

☁️ Google Cloud Run Deployment

LifeLine+ is fully deployable on Google Cloud Run with auto-scaling, HTTPS, and full WebSocket support.

Prerequisites

  1. Install Google Cloud SDK
  2. Authenticate: gcloud auth login
  3. Set project: gcloud config set project YOUR_PROJECT_ID

Backend Deployment

# Build and deploy backend
gcloud run deploy lifeline-backend \
  --source ./backend \
  --platform managed \
  --region asia-south1 \
  --allow-unauthenticated \
  --set-env-vars "GOOGLE_MAPS_API_KEY=your_key,GEMINI_API_KEY=your_key,FIREBASE_PROJECT_ID=your_id,FRONTEND_URL=https://your-frontend-url.run.app,NODE_ENV=production"

Frontend Deployment

# Build and deploy frontend
gcloud run deploy lifeline-frontend \
  --source ./frontend \
  --platform managed \
  --region asia-south1 \
  --allow-unauthenticated \
  --set-env-vars "VITE_BACKEND_URL=https://your-backend-url.run.app"

Environment Variables

Backend:

  • GOOGLE_MAPS_API_KEY - Google Maps API key
  • GEMINI_API_KEY - Gemini AI API key
  • FIREBASE_PROJECT_ID - Firebase project ID
  • FIREBASE_PRIVATE_KEY - Firebase service account private key
  • FIREBASE_CLIENT_EMAIL - Firebase service account email
  • FRONTEND_URL - Frontend Cloud Run URL (for CORS)
  • NODE_ENV=production - Production mode

Frontend:

  • VITE_BACKEND_URL - Backend Cloud Run URL

Health Checks

Both services include health check endpoints:

  • Backend: https://your-backend-url.run.app/health
  • Frontend: https://your-frontend-url.run.app/health

πŸ“š Project Docs

File Purpose
INSTRUCTIONS.md File-by-file working principles and runbook
ARCHITECTURE.md Mermaid architecture diagrams
CORE_LOGIC.md Emergency pipelines and process flows
LICENSE Project license

πŸ‘₯ Team: LifeLine+

We are the LifeLine+ team, participating in the Google Solution Challenge 2026 hosted by Hack2Skill.

Note: This project was built for hackathon purposes as part of the Google Solution Challenge 2026.

Member Role
Babin Bid Team Lead, Full Stack Developer
Atanu Saha Frontend Developer
Rohit Kumar Adak Idea Provider, Tech Architect & Backend Developer
Sagnik Bachhar Researcher

⚠️ Safety Note

LifeLine+ is built for rapid coordination, but life-threatening emergencies should still call official Indian emergency numbers such as 108 or 112 immediately.

Faster response. Safer India.

License

This project is licensed under the LICENSE file.