Dr.AI is a security-conscious healthcare application prototype and LLM-powered healthcare workflow prototype engineered to demonstrate AI safety guardrails, role-based authorization boundaries, conflict-free appointment scheduling, simulated telehealth workflows, and simulated prescription workflows.
Notice: This project is an engineering exploration and prototype. It does not provide medical diagnoses or clinical validation.
To maintain technical honesty, every feature is explicitly classified below:
| Feature / Domain | Status | Description & Traceable Evidence |
|---|---|---|
| Authentication & Password Security | IMPLEMENTED |
Bcrypt hashing (10 salt rounds), password hidden from queries (select: false), reset tokens stored as SHA-256 with 1-hour TTL, password reset invalidates active tokens. Tested in dr-ai-backend/tests/auth.test.ts. |
| Role-Based Access Control (RBAC) | IMPLEMENTED |
Strict server-side JWT verification with algorithm whitelisting (HS256). Separate boundaries for patient, doctor, and admin. Patients cannot self-assign doctor roles. Tested in dr-ai-backend/tests/rbac.test.ts. |
| Appointment Engine & Concurrency | IMPLEMENTED |
MongoDB-backed appointments with compound unique indexes (doctorId, date, time) preventing double-booking (409 Conflict). Validated state machine (scheduled β in_progress β completed / cancelled). Tested in dr-ai-backend/tests/appointments.test.ts. |
| Clinical AI Safety Layer | IMPLEMENTED |
Deterministic pre-flight regex check intercepts acute emergencies (chest pain, stroke, dyspnea, suicide) before LLM inference. OpenAI structured JSON differential diagnosis with deterministic fallback when API keys are unconfigured. Zero fabricated confidence percentages. Tested in dr-ai-backend/tests/ai_safety.test.ts. |
| Input Sanitization & Injection Guards | IMPLEMENTED |
Centralized NoSQL injection mitigation, safe parameter validation, path traversal guards, and PII masking (SSN, payment card). Route-specific rate limiters. Tested in dr-ai-backend/tests/security.test.ts and src/security_suite.test.ts. |
| Telehealth Video Consult | SIMULATED / HYBRID |
Real browser webcam/microphone capture via navigator.mediaDevices.getUserMedia with self-view rendering. Remote participant is explicitly labeled as a demonstration preview. |
| Prescription Records | SIMULATED |
Server-side Mongoose Prescription model with cryptographic Rx IDs, doctor-only issuance, and ownership checks. UI and PDF exports are stamped: DEMO PRESCRIPTION β NOT DIGITALLY SIGNED. |
| Emergency Facility Locator | SIMULATED AVAILABILITY |
Real browser GPS geolocation (navigator.geolocation.getCurrentPosition) with regional fallback. ER wait times are clearly labeled as [DEMO DATA β SIMULATED AVAILABILITY]. |
| Multi-Party WebRTC Signaling | PLANNED |
LiveKit / SFU peer signaling mesh planned for multi-participant clinical teleconferences. |
| DEA / EPCS E-Prescribing Gateway | PLANNED |
Surescripts certified identity proofing and DEA-compliant digital signing keys planned for legal pharmacy routing. |
βββββββββββββββββββββββββββββββ
β Browser / React Frontend β
β (Axios Client + JWT Auth) β
ββββββββββββββββ¬βββββββββββββββ
β HTTPS / JSON
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Express Security Pipeline (dr-ai-backend) β
β β
β [Helmet Security Headers] βββΊ [CORS Whitelist] βββΊ [Observability / Req ID] β
β β β
β [Rate Limiter] βββββββββ [NoSQL & Path Sanitizer] βββββββ β
β β β
β βΌ β
β [JWT Authenticate & Authorize Middleware (Patient / Doctor / Admin)] β
ββββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
βΌ βΌ βΌ
ββββββββββββββββββββββ ββββββββββββββββββββββ ββββββββββββββββββββββ
β Auth & Profiles β β Appointments API β β Clinical AI Triage β
β - Bcrypt hash β β - Concurrency lock β β - Emergency Filter β
β - Token expiration β β - State machine β β - Structured Diff β
β - Password reset β β - Ownership check β β - OpenAI fallback β
βββββββββββ¬βββββββββββ βββββββββββ¬βββββββββββ βββββββββββ¬βββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββ
β MongoDB Persistence β
β - Users & Doctors β
β - Compound Index Slots β
β - Prescriptions & Chats β
βββββββββββββββββββββββββββββββ
Healthcare AI must never attempt speculative diagnosis during acute emergencies. Our ClinicalConversationService checks queries against red-flag clinical signatures:
- Cardiovascular: Crushing chest pain, left-arm radiating pressure, cold sweats.
- Neurological: Sudden facial droop, asymmetric arm weakness, acute slurred speech (FAST criteria).
- Respiratory: Severe dyspnea, acute respiratory distress, inability to speak in full sentences.
- Psychiatric / Poisoning: Suicidal ideation, drug overdose ingestion.
When triggered, LLM generation is bypassed entirely and the patient receives emergency escalation directives (911 dispatch guidance).
- Clinical outputs provide qualitative urgency rankings (High, Moderate, Low) rather than pseudo-scientific percentages (e.g., "94.2% match").
- Every differential response includes explicit educational source provenance (
clinical_guidelines_v1oropenai_gpt4o). - Clarifying questions and red-flag warning signs are structured according to clinical decision support standards.
- Tokens are signed with
HS256using validated server secrets (minimum 32 characters; rejected if set to default placeholders). - Passwords require minimum 8 characters with at least one number and letter.
- Doctor accounts cannot be self-registered via the public sign-up endpoint.
- User profile updates reject privilege escalation attempts (e.g. mass assignment of
role: admin).
dr-ai-clone/
βββ src/ # React 18 SPA Frontend
β βββ components/
β β βββ Navbar.tsx # Role-aware nav with authenticated demo indicator
β β βββ Footer.tsx # Transparent prototype notices and legal terms
β β βββ BookingModal.tsx # Conflict-aware appointment scheduling dialog
β β βββ PrescriptionModal.tsx # Honest unsigned demo consultation PDF exporter
β β βββ EmergencyModal.tsx # Emergency 911 dispatch hotline modal
β β βββ BodyMap.tsx # Interactive anatomical symptom locator
β β βββ VitalsChart.tsx # SVG clinical telemetry visualizer
β βββ context/
β β βββ AuthContext.tsx # Server-backed auth state with scoped demo evaluator
β β βββ AppointmentContext.tsx # API-driven appointment state & doctor catalog
β β βββ ThemeContext.tsx # Dark/Light mode theme state
β βββ pages/
β β βββ Home.tsx # Truthful hero, architecture metrics, and FAQs
β β βββ Chat.tsx # Clinical AI assistant with fallback provenance
β β βββ VideoConsult.tsx # Simulated telehealth room with local media preview
β β βββ Hospitals.tsx # Geolocation GPS locator with demo availability
β β βββ Login.tsx / Signup.tsx # Real backend auth forms + demo quick-logins
β β βββ ForgotPassword.tsx # Cryptographic token password recovery
β β βββ Profile.tsx # Patient health records & vitals dashboard
β βββ services/
β β βββ api.ts # Axios client with Bearer auth & 401 interceptor
β β βββ authService.ts # Auth API endpoints
β β βββ appointmentService.ts # Booking and doctor catalog endpoints
β β βββ chatService.ts # Clinical message and intake endpoints
β β βββ prescriptionService.ts # Prescriptions API endpoints
β βββ utils/
β βββ sanitize.ts # Client input sanitization and PII masking
β
βββ dr-ai-backend/ # Production-Oriented Express API
βββ src/
β βββ config/env.ts # Strict environment configuration & secrets check
β βββ errors/AppError.ts # Typed operational error hierarchy
β βββ middleware/
β β βββ auth.ts # HS256 JWT verify & RBAC gate
β β βββ errorHandler.ts # Centralized safe error responder
β β βββ observability.ts # Structured logging with correlation IDs
β β βββ rateLimiter.ts # Route-specific brute-force protections
β β βββ sanitize.ts # NoSQL injection and path traversal guards
β βββ models/
β β βββ User.ts # Bcrypt hashed credentials & roles
β β βββ Doctor.ts # Provider credentials & slot schema
β β βββ Appointment.ts # Concurrency-safe appointments with state machine
β β βββ Prescription.ts # Audited medication orders with crypto IDs
β β βββ Chat.ts # Clinical dialogue turns & triage audits
β βββ routes/
β β βββ auth.ts # Register, Login, Me, Profile, Password Reset
β β βββ doctors.ts # Provider queries with seed fallback
β β βββ appointments.ts # Double-booking protected scheduler
β β βββ chat.ts # Guardrailed clinical AI intake & triage
β β βββ prescriptions.ts # Doctor-authorized prescription creation
β βββ services/
β β βββ ClinicalConversationService.ts # Deterministic emergency intercept & AI logic
β β βββ EmailService.ts # Password recovery delivery abstraction
β βββ seed/seed.ts # Database seeder for demo accounts & doctors
β βββ app.ts # Express application configuration
β βββ server.ts # Database connection & HTTP server entry
βββ tests/
βββ auth.test.ts # Authentication integration tests
βββ rbac.test.ts # Role-based access control tests
βββ appointments.test.ts # Double-booking & concurrency tests
βββ ai_safety.test.ts # Deterministic emergency intercept tests
βββ security.test.ts # Sanitization & rate limiting tests
- Node.js: v18+ (tested up to Node v26)
- MongoDB: Optional for development (runs with automatic offline fallback, or connects to MongoDB on
localhost:27017)
Copy example environment files before launching:
# Frontend environment (.env)
cp .env.example .env
# Backend environment (dr-ai-backend/.env)
cp dr-ai-backend/.env.example dr-ai-backend/.envKey environment variables:
- Frontend (
.env):REACT_APP_API_URL: Backend API base URL (default:http://localhost:5000/api)REACT_APP_DEMO_MODE: Enables quick-login evaluator accounts (default:true)
- Backend (
dr-ai-backend/.env):PORT: HTTP server port (default:5000)NODE_ENV:development|production|testMONGODB_URI: MongoDB connection URI (default:mongodb://localhost:27017/dr-ai)JWT_SECRET: Signing secret (required in production, min 32 characters)OPENAI_API_KEY: Optional OpenAI key; falls back to deterministic triage if omittedCORS_ORIGIN: Allowed frontend origin (default:http://localhost:3000)DEMO_MODE: Enables demo seed data (default:true)
Install dependencies and start services concurrently:
# Install root and backend dependencies
npm install --legacy-peer-deps
npm --prefix dr-ai-backend install --legacy-peer-deps
# Start both Backend (port 5000) and Frontend (port 3000)
npm run dev
# (or: npm start)Verified access points:
- Frontend: http://localhost:3000
- Backend: http://localhost:5000
- Health Check: http://localhost:5000/api/health
# Run frontend test suite (30 unit & security tests)
npm test
# Run backend integration & concurrency test suite (69 tests)
npm run test:backend
# Run deterministic AI safety & triage evaluation harness
npm run evaluate:ai
# Build production artifacts
npm run build
npm run build:backendFor frictionless evaluation without registering a new email:
| Role | Password | Permissions | |
|---|---|---|---|
| Demo Patient | patient@example.com |
PatientPass123 |
AI symptom triage, appointment booking, personal vitals |
| Demo Doctor | doctor@example.com |
DoctorPass123 |
Clinical consult reviews, prescription issuance |
| Demo Admin | admin@example.com |
AdminPass123 |
System oversight, user list access |
To maintain strict engineering honesty, the following genuine architectural boundaries apply:
- Not a Diagnostic Medical Device: Dr.AI is an engineering prototype for demonstrating decision support workflows. It has not undergone clinical validation, FDA 510(k) clearance, or CE mark certification.
- Deterministic Pre-Flight Emergency Filter: While regex-based emergency screening catches recognized high-acuity keywords, unlisted idiosyncratic phrases may bypass pre-flight checks and fall back to LLM inference or default guidelines.
- Simulated Telehealth Media Mesh: Video consultations render the user's local camera/mic stream alongside simulated provider demonstration streams. Multi-participant SFU signaling (e.g. LiveKit) is planned for future implementation.
- Demonstration Prescription Records: Prescriptions generated in this application are stamped
DEMO PRESCRIPTION β NOT DIGITALLY SIGNEDand cannot be dispensed at pharmacies. Integration with Surescripts / DEA EPCS gateways is planned. - Simulated Hospital Telemetry: ER wait times, bed availability, and trauma capabilities are simulated demonstration records. The system does not interface with municipal 911 dispatch networks.
- Persistence Fallback: When MongoDB is not running locally, backend endpoints operate in an ephemeral in-memory fallback mode. Full persistence requires an active MongoDB database.
Dr.AI is a software architecture prototype designed for clinical decision support research, engineering demonstrations, and medical triage interface exploration.
- Not an FDA-Cleared Device: Dr.AI is not a diagnostic device and must not be used as a replacement for professional clinical judgment, physical examination, or diagnostic laboratory testing.
- Emergency Situations: In the event of acute chest pain, neurological deficit, severe shortness of breath, heavy hemorrhage, or suicidal thoughts, contact emergency services (911 in the US, 112 in the EU, 999 in the UK) immediately.
- Prescription Simulation: Prescriptions generated within this application are simulation records for user-interface demonstration and cannot be dispensed at commercial pharmacies.
This project is licensed under the MIT License.