LifeLink is an emergency response web application powered by MongoDB (Mongoose) and Express.js / React, using Firebase Auth strictly for Google Sign-In. It bridges standby blood donors, individuals in critical need, and medical facilities through smart donor matching, real-time inventory management, spatial UI design, and role-based workflows.
Warning
Security Note: Real credentials and .env files are never committed to GitHub. Copy .env.example templates to .env in both server/ and client/ directories and configure your credentials locally.
- π Smart Donor Matching Engine: In-code spatial distance calculation and compatibility matrix ranking standby donors based on ABO/Rh RBC compatibility, 90-day donation cooldown eligibility (anchored to actual collection dates), proximity distance, and availability.
- β‘ Emergency Request Broadcast & Tracking: Instant creation of emergency blood requests (
/individual/create) with live matched donor rankings and automated notification dispatch. Recipients can monitor progress in real time via an interactive stepper tracking portal (/individual/track/:id). - π₯ Hospital Command Hub & Reserve Stock: Medical facilities manage reserve stock across all 8 standard blood groups, process incoming requests, allocate inventory units, inspect transaction ledgers, and verify collections via an interactive Confirm Donation dialog with date validation.
- π€ Donor Portal & Google Sign-In: Standby donors manage availability, view three-date donation history (
pledgedAt,donatedAt,confirmedAt) and live cooldown countdowns, and authenticate via traditional credentials or verified Google Single Sign-On (Firebase Auth ID Token verification). - π‘οΈ Role-Based Access Control: Strict JWT authentication with distinct access controls for standard
user(donor & recipient), verifiedhospital, and systemadmin. - π Warm Nocturne Glass & Spatial UI: Tactile editorial translucent UI pairing matte charcoal dark mode (
#141210) and warm cream alabaster light mode (#FAF7F2) with 5 spatial elevation tiers, subtle radial ambient glows, dynamic refraction filters, and Coral Ember focus rings. - π AI Insights & Platform Analytics: Administrative dashboard with Recharts analytics visualizations, emergency response indicators, shortage prediction alerts, and a role-aware, read-only AI Assistant chatbot.
- π§ͺ Comprehensive Automated Testing & QA: 379 automated Jest + Supertest backend tests (31 test suites, 100% pass) alongside automated WCAG 2.1 AA/AAA contrast checks and Playwright visual audits.
Interactive captures taken directly from the live running client (1440Γ900 @2x) across both Dark (Warm Nocturne) and Light (Warm Cream Alabaster) themes β spanning public discovery, onboarding, donor workflows, recipient request tracking, hospital blood bank operations, admin analytics, and the role-aware AI Assistant.
LifeLink features a bespoke "Warm Nocturne + Vital Rose-Crimson + Coral Ember" design system tailored for high-stakes medical coordination β replacing cold, glary blacks and blues with tactile warm charcoal in dark mode, warm cream alabaster in light mode, and strict accessible contrast:
-
Warm Nocturne + Vital Crimson + Coral Ember Direction:
-
Tactile Editorial Precision: Matte Warm Charcoal (
#141210) with smoked espresso-slate cards (#1D1A17) in dark mode, and Warm Cream Alabaster (#FAF7F2) with pure porcelain cards (#FFFFFF) in light mode. -
10% Emergency Crimson Budget: Vital Rose-Crimson (
#C81D3B/#FF6B7Bdark;#BE123Clight) is reserved strictly for life-critical signals (primary emergency CTAs, critical badges, urgent request status indicators, active alerts). It represents$\le 10%$ of any viewport, preserving instant urgency. -
Semantic Mapping: ONLINE / Verified Facility / Confirmed / Fulfilled
$\rightarrow$ success; cooldown / low stock / pending$\rightarrow$ warning; critical stock / urgent request$\rightarrow$ danger; Coral Ember / Terracotta informational highlights & keyboard focus$\rightarrow$ info / focus. Always paired with icons and text labels (never color alone).
-
Tactile Editorial Precision: Matte Warm Charcoal (
| Token | Dark Mode | Light Mode | Usage & Purpose |
|---|---|---|---|
canvas |
#141210 |
#FAF7F2 |
Base viewport foundation |
surface |
#1D1A17 |
#FFFFFF |
Core data cards, inputs, containers |
raised |
#27231F |
#F0EBE2 |
Filter panels, interactive forms, active cards |
overlay |
#312C27 |
#FFFFFF + shadow |
Dialog modals, full-screen sheets |
text-primary |
#F6F2EB |
#1C1917 |
High-contrast headings and key data values |
text-muted |
#ACA295 |
#635A52 |
Captions, secondary subtitles, metadata |
hairline |
rgba(255,245,235,0.10) |
rgba(28,25,23,0.10) |
Subtle warm borders and divider lines |
specular rim |
rgba(255,248,240,0.12) |
rgba(255,255,255,0.96) |
Top-edge optical specular highlight |
danger (text/icon/badge) |
#FF6B7B |
#BE123C |
Critical shortages, emergency request badges |
danger-solid (button fill) |
#C81D3B |
#BE123C |
Primary emergency CTAs with white text |
danger hover |
#E11D48 |
#9F1239 |
Interactive hover state for danger buttons |
danger pressed |
#9F1239 |
#881337 |
Pressed active state for danger buttons |
success |
#4ADE80 |
#157A3D |
ONLINE status, verified facilities, fulfilled donations |
warning |
#FBBF24 |
#9A5B00 |
Cooldown warnings, low stock, pending reviews |
info / focus |
#F29C79 |
#B53E12 |
Keyboard focus ring (2px Coral Ember / Terracotta), info pills |
ice (warm parchment highlight) |
#F6DFC9 |
#1C1917 |
Soft secondary highlights and subtle glow accents |
accent-donor |
#34D399 |
#0B5E58 |
Donor portal title dot, hero tint, tab indicator |
accent-hospital |
#7DD3FC |
#075985 |
Hospital command center title dot, hero tint, tab indicator |
accent-admin |
#C4B5FD |
#6D28D9 |
Admin governance center title dot, hero tint, tab indicator |
urgency-critical |
#FF6B7B |
#BE123C |
Emergency shortage chip (AlertCircle icon + Critical label) |
urgency-high |
#FB923C |
#A14A08 |
High urgency chip (ArrowUp icon + High label) |
urgency-medium |
#FBBF24 |
#9A5B00 |
Medium urgency chip (Minus icon + Medium label) |
urgency-low |
#7DD3FC |
#0369A1 |
Low urgency chip (ArrowDown icon + Low label) |
abo-o |
#34D399 |
#0B5E58 |
O family blood pills (O+ subtle fill, O- outlined) |
abo-a |
#7DD3FC |
#075985 |
A family blood pills (A+ subtle fill, A- outlined) |
abo-b |
#C4B5FD |
#6D28D9 |
B family blood pills (B+ subtle fill, B- outlined) |
abo-ab |
#FBBF24 |
#9A5B00 |
AB family blood pills (AB+ subtle fill, AB- outlined) |
chart-series (1-6) |
#F29C79, #34D399, #FBBF24, #C4B5FD, #FF6B7B, #ACA295 |
#C2410C, #0F766E, #A14A08, #6D28D9, #BE123C, #57534E |
Recharts series colors across dark & light palettes |
- 5-Tier Spatial Elevation System:
elevation-canvas(Level 0): Viewport foundation and atmospheric canvas.elevation-base(Level 1): Standard data cards, list tiles, and tabular rows.elevation-raised(Level 2): Active items, interactive forms, and filter panels.elevation-floating(Level 3): Floating navigation bar, AI chat widget, and toast alerts.elevation-overlay(Level 4): High-priority dialog modals and full-screen drawers.
- Atmospheric Canvas: 4 subtle radial ambient glows (Warm Coral Ember
rgba(232,106,80,0.085), Soft Rose Signalrgba(217,59,78,0.06), Soft Sage Glowrgba(74,222,128,0.04), and Warm Sand Tintrgba(251,191,36,0.035)) kept subtle in dark mode withprefers-reduced-motionfallback. - Optics & Refraction: Warm charcoal glass (
rgba(29,26,23,0.90)) with soft espresso depth shadows (--shadow-card,--shadow-elevated) in dark mode, clean porcelain glass (rgba(255,255,255,0.88)) with warm elevation shadows (0 1px 2px rgba(28,25,23,.04), 0 8px 24px -4px rgba(28,25,23,.06)) in light mode, SVG displacement map filters (#liquid-refraction), and top specular rims. - Accessibility & Contrast: Automated WCAG 2.1 AA/AAA compliance verified across all routes and state views in both dark and light modes via
check-contrast.jsandaudit-pages.js, with tabular numeric fonts (tabular-nums) preventing layout shifts.
| Layer | Technologies |
|---|---|
| Frontend | React 18, Vite 5, Tailwind CSS 3, Framer Motion, Lucide Icons, Recharts, Axios |
| Backend | Node.js, Express.js 4, Mongoose 9, firebase-admin 14 (Google SSO only), JWT, bcryptjs, Zod validation |
| Database & Cloud | MongoDB + Mongoose (Uniform Repository Architecture, replica-set transactions) |
| Authentication | Custom JWT + bcryptjs & Google Login (Firebase Auth ID Token verification) |
| Testing & QA | Jest, Supertest, mongodb-memory-server, Playwright, @axe-core/playwright (379 automated tests) |
| Role / Account Type | Registration | Key Privileges |
|---|---|---|
user (Donor & Recipient) |
Public registration / Google Sign-In | Post emergency requests, track request progress, pledge donations, manage availability & donor profile |
hospital |
Public registration (requires admin approval) | Broadcast emergency requests, manage RBC inventory units, ping matching donors, confirm fulfilled donations |
admin |
Database seed script | Approve hospital registrations, manage platform users & requests, view AI insights & analytics |
Note
Role Elevation Guard: Google Sign-In strictly provisions accounts with accountType: "user". Hospital and Admin accounts cannot be provisioned via Google Sign-In, protecting elevated system roles.
High-resolution diagram exports: Light (Report Print) β’ Dark (Mono Ink)
LifeLink pairs MongoDB (lifelink database with Mongoose schemas & replica-set transactions) with Firebase Authentication (Google Sign-In only), signed 30-day JWT sessions, and read-only AI tools:
- Persistence: 11 MongoDB collections (
users,donorprofiles,hospitals,bloodrequests,donations,inventorytransactions,donorrequestpings,notifications,aiinsights,loginlogs,audit_logs). - Security & Privacy: Passwords hashed with
bcryptjs(10 rounds); donor contact details (phone, email) strictly masked from public and AI model responses. - AI Mesh: Google Gemini operates exclusively via read-only function tools; conversation history lives ephemerally in React client memory.
- Detailed Specification & Lifecycle Diagrams: See docs/data-model.md for full collection schemas, the request state machine, and the donor pledge sequence diagram.
- Node.js (v18.0.0 or higher) and
npm - A MongoDB deployment configured as a replica set (MongoDB Atlas or a local
mongodreplica set for multi-document ACID transactions) - A Firebase Project with Firebase Authentication (Google Provider) enabled (used exclusively for Google Sign-In ID token verification)
git clone https://github.com/tejas-coder28/LifeLink.git
cd LifeLinkYou can install dependencies for the root, server, and client simultaneously from the repository root:
# Install all dependencies across client and server
npm run install:allOr install them individually:
# Server dependencies
cd server
npm install
# Client dependencies
cd ../client
npm installCopy server/.env.example to server/.env:
cp server/.env.example server/.envGenerate a Firebase Service Account key (for Google Sign-In verification only):
- In the Firebase Console, navigate to Project Settings > Service accounts.
- Click Generate new private key and download the resulting JSON file.
- Save the JSON file securely (e.g.
server/serviceAccountKey.jsonβ already included in.gitignore). - Configure
server/.env:
PORT=5000
MONGODB_URI=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/lifelink?retryWrites=true&w=majority
MONGODB_DB_NAME=lifelink
JWT_SECRET=your_super_secret_jwt_key
FIREBASE_SERVICE_ACCOUNT_PATH=./serviceAccountKey.json
NODE_ENV=developmentCopy client/.env.example to client/.env:
cp client/.env.example client/.envPopulate the Firebase Web SDK credentials from Project Settings > General > Your apps > Web app:
VITE_API_URL=http://localhost:5000/api
VITE_FIREBASE_API_KEY=your_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_idSynchronize MongoDB indexes (unique constraints, 2dsphere geo indexes, and TTL indexes):
npm run indexes:sync --prefix serverSeed initial demo accounts and inventory stock:
# From root
npm run seed
# Or to reset and re-seed clean data
npm run seed:resetVerify backend health:
# Start backend in development
npm run dev:serverVisit GET http://localhost:5000/api/health to confirm operational status:
{
"success": true,
"status": "connected",
"dbType": "mongodb",
"dbName": "lifelink",
"projectId": "your-firebase-project",
"timestamp": "..."
}You can run both client and server using the root convenience scripts or dedicated terminals:
# Terminal 1 β Start the API Server (Port 5000)
npm run dev:server
# Terminal 2 β Start the React Client (Port 5180)
npm run dev:client# Terminal 1:
cd server && npm run dev
# Terminal 2:
cd client && npm run devOpen your browser at http://localhost:5180.
Tip
The client Vite dev server runs on port 5180 with an automated proxy forwarding /api/* requests to the Express backend on http://127.0.0.1:5000.
LifeLink includes a rigorous automated testing and accessibility assurance suite:
# Run 379 automated backend tests across 31 suites
cd server
npm test- 31 Test Suites / 379 Tests: 100% pass rate against
mongodb-memory-serverreplica set. - Covers authentication, blood compatibility scoring, spatial matching algorithms, donation fulfillment, hospital workflows, multi-document ACID transaction integrity, unique pledge constraints, DB failure 503 guards, rate limiting, and role guards.
# Run automated color contrast validation
npm run check:contrast- Evaluates all token foreground and background color combinations in both Dark and Light modes.
- Enforces WCAG 2.1 AA/AAA compliance (normal text
$\ge 4.5:1$ , large text / UI elements$\ge 3.0:1$ ).
# Run headless browser audit with automated screenshot capture
npm run audit:pages- Traverses every public, donor, hospital, and admin route.
- Verifies contrast, focus rings, interactive states, and saves high-resolution screenshots to
scripts/screenshots/.
Seeded automatically by npm run seed:
| Role | Password | Access & Privileges | |
|---|---|---|---|
| User / Donor | user@lifelink.com |
user123 |
Standby donor dashboard, pledge donations, track requests, update availability & location |
| Hospital | hospital@lifelink.com |
hospital123 |
Broadcast emergency requests, manage 8-group RBC inventory stock, ping donors, confirm pledges |
| Admin | admin@lifelink.com |
admin123 |
Approve hospital registrations, manage platform accounts, view AI insights & analytics |
| Endpoint | Method | Role | Description |
|---|---|---|---|
/api/auth/register |
POST |
Public | Register standard donor or hospital account |
/api/auth/login |
POST |
Public | Authenticate with email/password and obtain JWT |
/api/auth/google |
POST |
Public | Verify Firebase Google ID token and issue JWT session |
/api/requests |
GET |
Public / Auth | List blood requests with filter criteria |
/api/requests |
POST |
user, hospital |
Create a new emergency blood request |
/api/requests/:id |
GET |
Authenticated | Retrieve request details with live matched donors |
/api/donors |
GET |
Public / Auth | Query standby donors by blood group and radius |
/api/donations/pledge |
POST |
user |
Pledge donation for an active emergency request (requires { requestId, units }) |
/api/donations/:id/complete |
POST, PATCH |
hospital, admin |
Confirm donation fulfillment ({ donatedAt? }, legacy alias /fulfill), update inventory & compute cooldown from donatedAt |
/api/donations/:id/decline |
POST, PATCH |
hospital, admin |
Release / decline a pledged donation (releasedAt recorded) |
/api/donations/history |
GET |
user |
Retrieve donor donation history (pledgedAt, donatedAt, confirmedAt, releasedAt) |
/api/hospitals/inventory |
GET, PUT |
hospital |
View and update RBC reserve units |
/api/hospitals/pending |
GET |
admin |
View hospital accounts awaiting verification |
/api/hospitals/:id/approve |
PUT |
admin |
Approve registered hospital |
/api/analytics |
GET |
admin |
Aggregate platform donation metrics and trends |
/api/ai/insights |
GET |
admin |
Predictive regional blood supply insights |
/api/ai/chat |
POST |
Public / Auth | Role-aware, data-aware AI Assistant powered by Google Gemini (strictly read-only) |
/api/health |
GET |
Public | Backend health check and MongoDB connection status |
LifeLink implements clinical donor safety standards, volume transparency, and auditable collection timestamps based on hospital and National Blood Transfusion Council (NBTC) guidelines:
-
Shared Blood Unit Configuration (
bloodUnits.js):-
ML_PER_UNIT = 450: Single whole-blood donation unit equivalent to$\approx 450\text{ ml}$ . -
MAX_UNITS_PER_DONOR_PER_PLEDGE = 1: Standard whole-blood donations are strictly capped at 1 unit per donor per donation to safeguard donor health and prevent post-donation syncope. -
formatUnits(n, options): Consistent volumetric display helper used across both server and client:"1 unit (β 450 ml)""2 units (β 900 ml)"-
"77 units (β 34.7 L)"(with litres formatting for facility stock reserves$\ge 1000\text{ ml}$ )
-
-
Three-Date Audit Trail & Shared Cooldown (
eligibility.js,dateFormatter.js,config/donation.js):- Every
Donationdocument preserves three distinct lifecycle timestamps:pledgedAt(when the donor pledged),donatedAt(actual blood collection date supplied upon confirmation), andconfirmedAt(server confirmation timestamp;releasedAtrecorded on released/declined pledges). -
donor.lastDonationDatealways tracks thedonatedAtof the donor's latest fulfilled donation rather than the confirmation click timestamp. - Shared
calculateEligibility()andcomputeNextEligibleDate()utilities (server/src/utils/eligibility.js&client/src/utils/eligibility.js) compute the 90-day cooldown directly fromdonatedAt, formatted uniformly viaformatDate()(en-IN, e.g.,"15 Nov 2026").
- Every
-
Pledge Confirmation Dialog (
PledgeModal.jsx):- Clicking "Respond / Pledge" opens an accessible confirmation modal showing remaining volumetric shortfall, live 90-day cooldown & availability guard, fixed 1-unit selector, and mandatory health affirmation checkbox before enabling submission.
-
Hospital Confirm Donation Dialog (
ConfirmDonationModal.jsx) & Server Guards (validateDonatedAt):- Confirming a donor's fulfillment opens an interactive dialog with a
Donation datedate-time input defaulting to now and a real-time cooldown preview ("Cooldown ends <date>"). - Both client and server validate
donatedAtinside an atomic MongoDB transaction (reads first, writes second):- Future collection date
$\rightarrow$ 400 Bad Request - Collection date earlier than
pledgedAt$\rightarrow$ 400 Bad Request - Backdated older than
MAX_DONATION_BACKDATE_DAYS(7days default)$\rightarrow$ 409 Conflictfor hospitals, allowed foradmin
- Future collection date
- Confirming a donor's fulfillment opens an interactive dialog with a
-
Consistent Status Dates Across Overview, History & AI:
- Donor History cards (
DonationHistoryCard.jsx): showPledged on <date> - awaiting hospital confirmation(pledged),Pledged on <date> - Donated on <date>+Next eligible: <date>(completed), andPledged on <date> - Released on <date>(released), with right-hand unit boxes showingDonated: <date>for completed donations orPledged: <date>otherwise. - Donor Overview card shows
Last Donation: <donatedAt>alongside"Eligible again on <date> (<n> days left)", matching hospital pledge rows and AI AssistantgetEligibilityreplies.
- Donor History cards (
-
One-Time Data Migration (
server/scripts/migrateDonationDates.js):- Idempotent migration script (
--dry-runsupported) normalizing historical fulfilled donations sodonatedAt = confirmedAtand recomputing each donor'slastDonationDatefrom their latestdonatedAt.
- Idempotent migration script (
-
AI Assistant Read-Only Guarantee:
- The AI assistant is strictly informational and read-only; it can never trigger or submit a pledge or confirm a donation.
- Pledge CTAs in chat navigate to
/donor/dashboard?tab=requests&request=<id>&action=pledgeas "Review & Pledge", scrolling to the card and opening the modal for donor review without auto-submitting.
LifeLink includes an embedded, role-aware, data-aware, and navigation-aware assistant powered by Google Gemini with a deterministic Keyword Router Fallback (Provider A):
-
Strict App-Only Scope: The assistant exclusively answers questions relating to LifeLink (blood requests, standby donors, blood bank inventory, cooldown eligibility, and platform navigation). Any off-topic query (weather, sports, politics, math, general programming, recipes, entertainment) immediately returns a fixed, polite refusal:
"I can only help with LifeLink: blood requests, donors, inventory and finding your way around the app."
-
Role-Scoped Read-Only Tools:
-
user/donor:getMyProfile,getEligibility(90-day cooldown calculation),getOpenRequestsForMe,getMyRequests,getMyDonationHistory,getMyAlerts. -
hospital:getInventory(all 8 RBC groups, total, low stock$\le 3$ , critical$= 0$ ),getIncomingDemands,getActiveRequests,getPendingPledges,getMatchingDonors(requestId),getMyVerificationStatus. -
admin:getPlatformStats,getPendingHospitals,getShortageAlerts,getRequestOverview. -
shared:getHowToGuide(topic)(returns navigation instructions and one-click deep-link action buttons).
-
-
Security & Data Isolation:
- Identity parameters (
userId,donorId,hospitalId) cannot be spoofed by the client or model; the server always injects identity directly from the verified JWTreq.user. - Hospital A cannot query requests or matching donors belonging to Hospital B (fails closed).
- Donors cannot see other users' contact information or exact coordinates.
- Identity parameters (
- Immediate Greeting Shortcut: Simple greetings ("hi", "hello", "thanks", "help") bypass external LLM calls and return an immediate role-specific greeting with 3 suggestion chips.
-
Zero-Downtime Fallback Guarantee: If
AI_PROVIDER=keyword,AI_API_KEYis omitted, the network fails, or the request times out ($\ge 8000\text{ms}$ ), the server logs a single structured warning (with zero secrets) and seamlessly fulfills the user query via the rule-based keyword router (Provider A).
- Authentication: Optional. If
Authorization: Bearer <token>is provided, the session inherits the user's role and data scope; otherwise it runs inpublicmode. - Rate Limit: 20 requests per minute per IP / user session. Returns
429 Too Many Requestswhen exceeded. - Request Payload:
{ "message": "What is our blood bank inventory?", "history": [ { "role": "user", "content": "hello" }, { "role": "assistant", "content": "Welcome to LifeLink Hospital Support..." } ], "currentPath": "/hospital/dashboard" } - Response Format:
{ "success": true, "message": "Chat response generated", "data": { "reply": "Total stock: 12 units. Critical (0 units): AB-, O-. Low (1-3 units): A-.", "actions": [ { "type": "navigate", "label": "Inventory Reserves", "path": "/hospital/dashboard", "tab": "inventory" } ], "suggestions": [ "Review incoming demands", "View active blood requests", "Check verification status" ], "provider": "gemini" } }
Configure in server/.env:
| Variable | Default | Purpose |
|---|---|---|
AI_PROVIDER |
gemini |
gemini (primary) or keyword (fallback-only mode) |
AI_API_KEY |
None | Google Gemini API key (or GEMINI_API_KEY) |
AI_MODEL |
gemini-2.5-flash |
Official Google GenAI model ID |
AI_TIMEOUT_MS |
8000 |
Timeout in milliseconds before falling back to Provider A |
LifeLink/
βββ client/ # React + Vite frontend (Port 5180)
β βββ src/
β β βββ api/ # Axios service API clients
β β βββ components/ # Modular UI component library
β β β βββ ai/ # AI Chat Widget & Insight Cards
β β β βββ auth/ # Google Login Button & Auth Panels
β β β βββ cards/ # DonationHistoryCard, DonorCard, RequestCard, StatCard
β β β βββ charts/ # Recharts Visualizations (BloodGroupBarChart, TrendLineChart, StatusPie)
β β β βββ common/ # GlassCard, GlassModal, Navbar, Footer, ThemeToggle
β β β βββ forms/ # ConfirmDonationModal, DonorProfileForm, InventoryForm, PledgeModal, RequestForm
β β βββ context/ # AuthContext, ThemeContext, ToastContext
β β βββ hooks/ # useTheme, useChartTheme, useTypewriterFill
β β βββ pages/ # Application views
β β β βββ admin/ # AdminDashboard, UserManagement, RequestManagement, AIInsights
β β β βββ auth/ # Login, Register, ForgotPassword
β β β βββ donor/ # DonorDashboard, DonorProfile, DonationHistory
β β β βββ hospital/ # HospitalDashboard, InventoryManager, MatchingDonors
β β β βββ individual/ # CreateRequest, TrackRequest, IndividualDashboard
β β β βββ public/ # Home, About, FindDonors, EmergencyRequest
β β βββ routes/ # ProtectedRoute and AccountTypeRoute wrappers
β β βββ theme/ # Central Warm Nocturne design tokens (tokens.js)
β β βββ utils/ # eligibility, dateFormatter, bloodCompatibility, requestRules, statusHelper
β β βββ firebase.js # Firebase Web SDK initialization
β β βββ index.css # Warm Nocturne Glass design system styles & CSS variables
β βββ tailwind.config.js # Tailwind configuration with spatial elevations
β βββ vite.config.js # Vite server configuration & API proxy
β βββ .env.example
βββ server/ # Express API backend (Port 5000)
β βββ scripts/
β β βββ migrateDonationDates.js # One-time idempotent donation date normalization & cooldown backfill
β β βββ syncIndexes.js # Synchronize Mongoose schema & TTL/geo indexes
β βββ src/
β β βββ config/ # mongo.js, donation.js (cooldown & backdate constants), Firebase Auth
β β βββ controllers/ # Express route handler controllers
β β βββ middleware/ # JWT Auth, RoleGuard, Zod Validation, RateLimiter
β β βββ models/ # 11 Mongoose schemas, indexes, and virtual JSON transforms
β β βββ repositories/ # MongoDB Mongoose Uniform Repository layer (.lean() + sessions)
β β βββ routes/ # Express API routers
β β βββ services/ # Domain logic, matching engine, MongoDB ACID transactions
β β βββ utils/ # eligibility, dateFormatter, bloodCompatibility, geo, responseHandler
β β βββ validations/ # Zod input validation schemas
β β βββ app.js # Express application setup & Mongo availability 503 guard
β β βββ index.js # Server entry point
β β βββ seed.js # MongoDB seed and reset script
β βββ tests/ # Automated Jest + Supertest + MongoMemoryReplSet suites (379 tests / 31 suites)
β βββ .env.example
βββ docs/ # Documentation & Visual Assets
β βββ screenshots/ # 25 live captured dark & light portal screenshots embedded in README
β βββ architecture/ # System architecture diagrams (light & dark PNG exports)
β βββ data-model.md # MongoDB collections, indexes, and domain lifecycles
β βββ design-system.md # Liquid Glass & Spatial UI specification
β βββ ui-audit.md # Comprehensive UI inventory and audit
βββ scripts/ # QA & Verification Tools
β βββ check-contrast.js # Automated WCAG 2.1 AA/AAA token contrast checker
β βββ audit-pages.js # Playwright + axe-core full-route auditor
βββ package.json # Monorepo management scripts
βββ README.md
| Script / Command | Exact Command | Purpose |
|---|---|---|
npm run install:all |
npm install --prefix server && npm install --prefix client |
Install all dependencies across both projects |
npm run dev:server |
npm run dev --prefix server |
Start Express backend in watch mode (Port 5000) |
npm run dev:client |
npm run dev --prefix client |
Start Vite frontend dev server (Port 5180) |
npm run seed |
npm run seed --prefix server |
Seed demo accounts, inventory, and sample requests |
npm run seed:reset |
npm run seed:reset --prefix server |
Clear and re-seed database |
| Donation Date Migration | node server/scripts/migrateDonationDates.js [--dry-run] |
Normalize historical donatedAt / confirmedAt & lastDonationDate |
npm run build |
npm run build --prefix client |
Build optimized client production bundle |
npm run check:contrast |
node scripts/check-contrast.js |
Run automated WCAG AA/AAA contrast audit |
npm run audit:pages |
node scripts/audit-pages.js |
Run Playwright visual and accessibility route audit |
This project is open-source and available under the MIT License.

























