LifeLine
Real-time hyperlocal blood emergency matching platform that replaces slow, chaotic phone call broadcasts with an automated, concurrency-safe matching network.
The Problem & Real-World Impact
In emergency healthcare, families lose critical hours manually broadcasting blood requests across WhatsApp groups with no coordination, leading to duplicate outreach, fake leads, and double-booked donors.
LifeLine solves this by combining natural-language AI parsing, sub-100ms geospatial donor search, and single-threaded Redis atomic distributed locking to guarantee zero double-booking race conditions under high concurrency.
Key Technical Architecture Highlights
-
Atomic Distributed Locking (SET NX PX 900000): Single-threaded Redis lock acquisition eliminates double-booking race conditions when multiple requesters attempt to claim the same donor simultaneously. Validated under 20 concurrent requests — exactly 1 acquired the lock and 19 failed with a
409 Conflict. -
Polyglot Persistence Architecture:
MongoDB Atlas
$geoNearaggregation pipeline resolves top-10 compatible donors within 50 km in under 100 ms; Redis for sub-millisecond locks and instant session revocation; PostgreSQL + Prisma ORM for immutable audit logging. -
Advisory AI with Resilient Fallbacks: Natural-language request parsing uses OpenRouter (GPT-4o-mini) wrapped in an 8-second
AbortControllertimeout and deterministic regex fallback (< 2 ms), guaranteeing the core application never hangs during medical emergencies. -
Dual-Token Auth & Instant Socket Revocation: 15-minute in-memory JWT access tokens paired with 7-day
httpOnly, SameSite=Strictrefresh cookies rotated in Redis. Logout triggers a WebSocketsession-revokedbroadcast that immediately terminates active sessions across all devices. - Auto-Escalation State Machine: If a reserved donor fails to respond within the 15-minute lock window (900s TTL), the state machine applies a -10 reliability penalty, releases the Redis lock, and automatically re-matches the request with the next nearest candidate.
Live Concurrency Pipeline & Mutex Visualizer
Watch 20 concurrent hospital threads race to acquire an atomic distributed lock (SET NX PX 900000) for donor don_8f91a in real time:
Verified System Benchmarks
Tech Stack Breakdown
Frontend Studio
React 18, TypeScript, Vite, Tailwind CSS v3, React Router v6, Lucide React, Framer Motion, Sonner toasts.
Backend Core
Node.js, Express.js, Socket.io, JWT, bcrypt, express-validator, Helmet, Morgan, cookie-parser.
Polyglot Persistence
MongoDB Atlas ($geoNear 2dsphere), Redis / Upstash (SET NX PX locks), PostgreSQL + Prisma ORM (relational audit logs).
AI & Resilience
OpenRouter API (GPT-4o-mini strict JSON mode), 8s AbortController timeout, deterministic regex fallback parser.