βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT LAYER β
β β
β React Frontend (Port 5173) β
β βββ Premium UI with Glassmorphism β
β βββ JWT Authentication & Context β
β βββ React Router for Navigation β
β βββ Axios API Client β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β HTTP/REST API
ββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββ
β BACKEND LAYER β
β β
β Express.js Server (Port 5000) β
β βββ JWT Authentication Middleware β
β βββ Multer File Upload Handler β
β βββ MongoDB Integration (Mongoose) β
β βββ RESTful API Routes β
β βββ /api/auth (Login, Register, Profile) β
β βββ /api/patients (CRUD Operations) β
β βββ /api/vitals (Health Metrics) β
β βββ /api/reports (Documents & Files) β
β βββ /api/ai (Proxy to AI Service) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββ΄βββββββββββ¬ββββββββββββββββββββββββββββββββββ
β β β
βββββββββ΄βββββββββ βββββββββββ΄βββββββββ βββββββββββ΄ββββββββββ
β MongoDB β β File Storage β β AI Service β
β Database β β (uploads/) β β (Port 8000) β
β β β β β β
β Collections: β β Medical Docs: β β FastAPI Server β
β β’ users β β β’ X-rays β β βββ Gemini API β
β β’ patients β β β’ Lab Reports β β βββ LangChain β
β β’ vitals β β β’ PDFs β β βββ RAG System β
β β’ reports β β β’ Images β β β
ββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββββ
{
_id: ObjectId,
email: String (unique, indexed),
password: String (bcrypt hashed),
name: String,
role: "admin" | "staff",
phone: String,
isActive: Boolean,
createdAt: Date,
updatedAt: Date
}Indexes: email (unique)
{
_id: ObjectId,
patientId: String (auto-generated: ICU000001),
name: String,
age: Number,
dateOfBirth: Date,
gender: "male" | "female" | "other",
reasonForAdmission: String,
roomNumber: String,
bedNumber: String,
admissionDate: Date,
dischargeDate: Date | null,
assignedDoctor: String,
status: "admitted" | "discharged",
emergencyContact: {
name: String,
phone: String,
relation: String
},
medicalHistory: String,
allergies: [String],
bloodType: String,
createdBy: ObjectId (ref: User),
createdAt: Date,
updatedAt: Date
}Indexes: patientId (unique), status
{
_id: ObjectId,
patientId: ObjectId (ref: Patient),
heartRate: Number (bpm),
bloodPressureSystolic: Number (mmHg),
bloodPressureDiastolic: Number (mmHg),
oxygenSaturation: Number (%),
temperature: Number (Β°F),
respiratoryRate: Number (breaths/min),
bloodSugar: Number (mg/dL),
co2Level: Number (%),
notes: String,
recordedBy: ObjectId (ref: User),
timestamp: Date,
createdAt: Date,
updatedAt: Date
}Indexes: patientId, timestamp, compound(patientId+timestamp)
{
_id: ObjectId,
patientId: ObjectId (ref: Patient),
title: String,
type: "text" | "image" | "pdf",
category: "lab" | "radiology" | "clinical" | "discharge" | "consultation" | "other",
// For text reports
content: String,
// For file uploads
fileUrl: String,
fileName: String,
fileSize: Number,
mimeType: String,
// Metadata
description: String,
tags: [String],
uploadedBy: ObjectId (ref: User),
// AI Processing
aiProcessed: Boolean,
aiExtractedText: String,
aiSummary: String,
timestamp: Date,
createdAt: Date,
updatedAt: Date
}Indexes: patientId, timestamp, type, compound(patientId+timestamp)
Implementation:
- JWT-based token authentication
- Bcrypt password hashing (10 rounds)
- Role-based access control (Admin/Staff)
- Protected routes with middleware
- Automatic token refresh
Security Measures:
- HTTP-only tokens (recommended for production)
- Password strength validation
- Account deactivation support
- Session timeout (7 days default)
API Endpoints:
POST /api/auth/login- User loginPOST /api/auth/register- Create new user (Admin only)GET /api/auth/me- Get current userPUT /api/auth/updatepassword- Change passwordPUT /api/auth/updateprofile- Update profile
Features:
- Create, Read, Update, Delete patients
- Auto-generated Patient IDs (ICU000001, ICU000002...)
- Separate views for Admitted vs Discharged
- Search functionality
- Comprehensive patient profiles
- Emergency contact information
- Medical history tracking
- Allergy management
API Endpoints:
GET /api/patients?status=admitted- Get patients by statusGET /api/patients/:id- Get single patientPOST /api/patients- Create patientPUT /api/patients/:id- Update patientDELETE /api/patients/:id- Delete patient (Admin only)PUT /api/patients/:id/discharge- Discharge patient
Vital Signs Tracked:
- Heart Rate (bpm)
- Blood Pressure (Systolic/Diastolic)
- Oxygen Saturation (%)
- Temperature (Β°F)
- Respiratory Rate (breaths/min)
- Blood Sugar (mg/dL)
- CO2 Level (%)
Features:
- Time-filtered queries (Last Hour, 24h, 7 days, All)
- Latest vital reading endpoint
- Trend analysis capability
- Staff attribution (who recorded)
- Notes support
API Endpoints:
GET /api/vitals/patient/:id?timeRange=24h- Get vitals with time filterGET /api/vitals/patient/:id/latest- Latest readingPOST /api/vitals- Record new vitalsPUT /api/vitals/:id- Update vitalsDELETE /api/vitals/:id- Delete record
Frontend Integration Needed:
- Recharts line/area charts for trends
- Real-time vital display
- Form for recording new readings
- Alert system for abnormal values
Report Types:
- Text Reports - Clinical notes, observations
- Images - X-rays, CT scans, photos
- PDFs - Lab results, discharge summaries
Features:
- Multer file upload (10MB limit)
- File type validation (JPEG, PNG, PDF)
- Categorization system
- Tagging support
- Download functionality
- AI processing integration
- Metadata management
API Endpoints:
GET /api/reports/patient/:id?type=pdf- Get patient reportsPOST /api/reports/text- Create text reportPOST /api/reports/upload- Upload file (multipart/form-data)PUT /api/reports/:id- Update report metadataDELETE /api/reports/:id- Delete reportGET /api/reports/:id/download- Download file
Storage:
- Files stored in
backend/uploads/ - Database stores metadata and file paths
- Automatic cleanup on deletion
Powered By:
- Google Gemini 1.5 Flash
- FastAPI microservice
- LangChain framework
Capabilities:
A. Comprehensive Patient Analysis:
Input: Patient data + 24h vitals + all reports
Output:
1. Critical Alerts
2. Vital Signs Trends
3. Risk Assessment
4. Clinical Recommendations
5. Priority Score (1-10)
B. Conversational Chatbot:
- Context-aware responses
- Access to patient history
- Medical knowledge base
- Multi-turn conversations
C. Multimodal File Processing:
- Extract text from PDFs
- Analyze medical images
- Generate summaries
- Auto-populate aiExtractedText and aiSummary fields
API Endpoints:
Backend Proxy:
POST /api/ai/insights/:patientId- Generate insightsPOST /api/ai/chat/:patientId- Chat interface
AI Service Direct:
POST /api/generate-insights- Full analysisPOST /api/chat- ChatbotPOST /api/process-file- File analysisGET /health- Service status
Example Insight Response:
{
"success": true,
"data": {
"insights": "**CRITICAL ALERTS:**\n- Oxygen saturation declining (92% β 88%)\n- Blood pressure elevated...",
"generatedAt": "2024-01-15T10:30:00Z",
"patientName": "John Doe"
}
}App
βββ AuthProvider (Context)
βββ Router
βββ Login (Public)
βββ Dashboard (Protected)
β βββ Navbar
β βββ StatCards
β βββ SearchBar
β βββ PatientCard[] (Admitted & Discharged)
β
βββ PatientDetail (Protected)
βββ Navbar
βββ PatientHeader
βββ TabNavigation
βββ TabContent
βββ VitalsMonitor
β βββ VitalCharts (Recharts)
β βββ TimeFilter
β βββ AddVitalsForm
β
βββ ReportsSection
β βββ FileUploader
β βββ ReportList
β βββ ReportViewer
β
βββ AIAssistant
βββ GenerateButton
βββ InsightsDisplay
βββ Chatbot
Color Palette:
Primary Blue: hsl(210, 100%, 50%)
Secondary Green: hsl(160, 60%, 45%)
Accent Purple: hsl(280, 60%, 60%)
Warning Orange: hsl(30, 100%, 55%)
Danger Red: hsl(0, 80%, 55%)Typography:
- Font: Inter (sans-serif)
- Heading Weights: 600-700
- Body: 400-500
Effects:
- Glassmorphism on cards
- Smooth transitions (250ms cubic-bezier)
- Hover lift effects
- Pulsing animations on icons
- β JWT token validation
- β Password hashing (bcrypt, 10 rounds)
- β Role-based middleware
- β File upload validation
- β CORS configuration
- β Helmet.js security headers
- β Input sanitization
- β Error handling (no stack traces in prod)
- β Token storage in localStorage
- β Automatic token injection
- β Auth context for global state
- β Protected routes
- β Auto-logout on 401
- HTTP-only cookies for tokens
- Rate limiting
- Request logging
- HTTPS enforcement
- Environment-based secrets
- Database encryption at rest
- File virus scanning
- Indexed fields: email, patientId, status, timestamp
- Compound indexes on frequent queries
- Pagination support (ready to implement)
- Lean queries for list views
- 10MB upload limit
- Streaming downloads
- Lazy loading for large lists
- Background AI processing
- Code splitting (via Vite)
- Lazy route loading
- Optimized re-renders
- Debounced search
- β Local MongoDB
- β Development servers
- β Sample data seeding
- MongoDB Atlas
- Environment variables management
- CI/CD pipeline setup
- Testing suite
- Cloud hosting (AWS/Azure/GCP)
- Load balancing
- CDN for static assets
- Monitoring & logging
- Backup strategies
- SSL certificates
-
Complete Vitals Monitor UI
- Integrate Recharts
- Implement time filters
- Add vital recording form
-
Build Reports Section
- File upload UI with drag-drop
- Report gallery view
- PDF/Image preview
-
Implement AI Insights UI
- "Generate Analysis" button
- Insights display with formatting
- Chatbot interface
-
User Management (Admin)
- Staff list view
- Add/edit/deactivate staff
- Permission management
-
Enhanced Patient Profile
- Edit mode
- Medical history timeline
- Allergy highlighting
-
Notifications System
- Critical vital alerts
- New report notifications
- AI insight badges
-
Analytics Dashboard
- Patient statistics
- Vital trends overview
- Resource utilization
-
Export Functionality
- PDF patient reports
- CSV data export
- Print views
-
AI Service
- Requires Gemini API key
- Rate limits apply (free tier)
- File processing is placeholder
-
Real-time Updates
- No WebSocket implementation
- Manual refresh needed
-
Mobile Optimization
- Responsive but not PWA
- No offline support
-
Testing
- No automated tests yet
- Manual testing only
{
"express": "^4.18.2",
"mongoose": "^8.0.3",
"jsonwebtoken": "^9.0.2",
"bcryptjs": "^2.4.3",
"multer": "^1.4.5-lts.1",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"helmet": "^7.1.0",
"morgan": "^1.10.0",
"axios": "^1.6.2"
}{
"react": "^18.2.0",
"react-router-dom": "^6.20.1",
"axios": "^1.6.2",
"recharts": "^2.10.3",
"lucide-react": "^0.294.0"
}fastapi==0.109.0
uvicorn==0.27.0
langchain==0.1.0
langchain-google-genai==0.0.6
google-generativeai==0.3.2
PyPDF2==3.0.1
Pillow==10.2.0
Project Status: β Backend Complete | π‘ Frontend 70% Complete | π‘ AI Service Complete (Testing Required)
Estimated Time to Full Completion: 8-12 hours of focused development
Main Missing Components:
- Recharts integration (2-3 hours)
- Reports UI with file upload (2-3 hours)
- AI Insights UI with chat (2-3 hours)
- Testing & bug fixes (2-3 hours)