Skip to content

KGFCH2/LifeLine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

339 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

Demo Mode


                    ██╗     ██╗███████╗███████╗    ██╗     ██╗███╗   ██╗███████╗+
                    ██║     ██║██╔════╝██╔════╝    ██║     ██║████╗  ██║██╔════╝+
                    ██║     ██║█████╗  █████╗      ██║     ██║██╔██╗ ██║█████╗  +
                    ██║     ██║██╔══╝  ██╔══╝      ██║     ██║██║╚██╗██║██╔══╝  +
                    ███████╗██║██║     ███████╗    ███████╗██║██║ ╚████║███████╗+
                    ╚══════╝╚═╝╚═╝     ╚══════╝    ╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝+

                                "Saving minutes. Saving lives."

LifeLine+ is a high-fidelity, production-grade Demonstration Platform built for the Google Solution Challenge 2026. It serves as a comprehensive showcase of how modern AI, real-time geolocation, and cloud-native architecture can revolutionize emergency response in India.

Note

This platform is currently in Demo Mode, optimized for presentation and speed. Timeouts, driver acceptances, and AI verifications are tuned for immediate feedback during live demonstrations.

🌍 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, and police coordination 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 with Distance-first fallback logic to ensure 10+ results for hospitals, doctors, police, and pharmacies
🗺️ Maps Google Maps JS API with AdvancedMarkerElement, 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, distance-based simulation timers (1-4 min), Socket.io live GPS simulation with unique unit IDs
📊 Activity Reports High-fidelity PDF generation with brand branding, user details, and persistent digital verification logic on every page
🤖 AI Health v2.0 Advanced triage chatbot with session persistence (LocalStorage), robust error handling, transcript export (.txt), and copy-to-clipboard
🚓 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 Enterprise-grade security with failover Google OAuth and Firebase dual-verification logic
⚡ Unified UX Persistent TopNav/Footer visibility during tracking, minimalist single-column layout, and premium borderless aesthetic
🏆 Gamification Silver, Gold, and Platinum user levels based on verified emergency service contributions
🖼️ Branded Assets High-resolution favicon.png and professional SVG-based map markers with "LifeLine+ Service" branding

🧱 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/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. Book a doctor appointment and test 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.

⏱️ Dynamic Simulation (Distance-Based)

  • Ambulance Acceptance: In production, drivers have several minutes to accept. In Demo Mode, the backend simulates a nearby driver acceptance in exactly 5 seconds, allowing for an immediate transition to the live tracking view.
  • Distance-Based Timer: The ETA simulation is no longer fixed. It calculates simulation speed based on the actual road distance—ensuring a realistic flow between 1 to 4 minutes depending on the route.
  • Real-time Map Movement: The ambulance marker on the map uses a smooth animation library to simulate actual driving speeds, following the actual road path from the Google Directions API.

Faster response. Safer India.

License

This project is licensed under the LICENSE file.