




| Technology | Purpose |
|---|---|
| React.js 19 | Modern JavaScript library for building component-based user interfaces with hooks and state management |
| React Router 7 | Declarative routing for React applications, enabling single-page navigation and protected routes |
| Tailwind CSS 4 | Utility-first CSS framework for rapid UI development with responsive design patterns |
| Axios | Promise-based HTTP client for making API requests with interceptors and error handling |
| Lucide React | Open-source icon library providing 1000+ consistent SVG icons as React components |
| Vite | Next-generation frontend build tool with lightning-fast HMR and optimized production builds |
| Technology | Purpose |
|---|---|
| Node.js | JavaScript runtime built on Chrome’s V8 engine for scalable server-side applications |
| Express.js | Minimal and flexible Node.js web framework for building REST APIs and web applications |
| MongoDB | NoSQL document database for flexible, schema-less data storage with high performance |
| Mongoose | Elegant MongoDB object modeling (ODM) with schema validation, middleware, and query building |
| JWT | JSON Web Tokens for stateless authentication and secure information exchange |
| bcryptjs | Password hashing library using bcrypt algorithm for secure password storage |
| AWS SDK | Amazon Web Services SDK for S3 file storage with pre-signed URLs and secure access |
| Multer | Node.js middleware for handling multipart/form-data for file uploads |
| PDFKit | PDF document generation library for creating pharmacy reports and medical documents |
| Twilio | Cloud communications platform for sending SMS notifications and alerts |
| Crypto | Node.js built-in module for cryptographic operations including API token generation |
| Technology | Purpose |
|---|---|
| Python 3.x | High-level programming language powering the machine learning and AI capabilities |
| FastAPI | Modern, fast web framework for building APIs with automatic OpenAPI documentation |
| Uvicorn | Lightning-fast ASGI server implementation for running FastAPI applications |
| Pydantic | Data validation library using Python type annotations for request/response schemas |
| NumPy | Fundamental package for numerical computing and array operations in Python |
| Pandas | Data manipulation and analysis library for structured data processing |
| Scikit-learn | Machine learning library for classification, regression, and clustering algorithms |
| OpenAI API | Integration with GPT models for document summarization and natural language processing |
| Python-dotenv | Environment variable management for configuration and secrets |
| HTTPX | Modern async HTTP client for making requests to external services |
| Feature | Description |
|---|---|
| Health Prediction | ML models predict health risks based on patient symptoms, vitals, and medical history |
| Diagnostic Assistance | AI-powered diagnostic suggestions based on symptom analysis and pattern recognition |
| Document Summarization | GPT-powered summarization of medical documents, lab reports, and patient records |
| Prescription Analysis | Analyze prescriptions for drug interactions, dosage validation, and contraindications |
| Report Analysis | Automated analysis of medical reports to identify abnormalities and critical findings |
| Health Recommendations | Personalized health recommendations based on patient data and medical guidelines |
useState, useEffect, and useContext.HealthPredictionExample.jsx reduce duplication.useNavigate is used for programmatic redirects after auth flows.VITE_API_URL).services/api.js with reusable methods.npm run dev enables near-instant feedback during UI development.vite.config.js handles environment variables and dev proxy behavior.authRoutes.js, adminRoutes.js, etc.)./api/documents/:documentId.authMiddleware.js verifies tokens and enforces role-based route protection.bcryptjs hashes passwords so plain-text credentials are never stored.bcrypt.compare() is used during sign-in for secure hash verification.config/s3Config.js with env-based credentials.multipart/form-data uploads in backend routes.req.file.crypto is used to generate secure external API tokens.randomBytes) for high entropy.app/api/schemas.py enforce required fields and types.BaseModel simplifies JSON serialization for ML outputs.joblib for fast startup inference.python-dotenv loads environment variables from .env files.load_dotenv().Health-Track/
├── backend/ # Express.js REST API server
│ ├── config/
│ │ └── s3Config.js # AWS S3 configuration for file storage
│ ├── middleware/
│ │ └── authMiddleware.js # JWT authentication middleware
│ ├── models/ # MongoDB Mongoose schemas
│ │ ├── Admin.js # Admin user with API token management
│ │ ├── Doctor.js # Doctor profiles and specializations
│ │ ├── Patient.js # Patient records and assignments
│ │ ├── Pharmacist.js # Pharmacist profiles and inventory access
│ │ ├── Medicine.js # Medicine inventory with stock tracking
│ │ ├── Document.js # Medical documents with S3 storage
│ │ ├── Report.js # Generated PDF reports
│ │ ├── Schedule.js # Appointment scheduling
│ │ ├── Transaction.js # Pharmacy inventory transactions
│ │ └── User.js # Base user authentication
│ ├── routes/ # API route handlers
│ │ ├── authRoutes.js # Authentication (sign-up, sign-in)
│ │ ├── adminRoutes.js # Admin operations and statistics
│ │ ├── doctorRoutes.js # Doctor patient management
│ │ ├── pharmacistRoutes.js # Pharmacy inventory and reports
│ │ ├── documentRoutes.js # Document upload/download with S3
│ │ ├── patientRoutes.js # Patient health records
│ │ └── aiRoutes.js # AI/ML microservice integration
│ ├── db.js # MongoDB connection with Mongoose
│ ├── server.js # Express server entry point
│ ├── package.json
│ └── vercel.json # Vercel deployment config
├── frontend/ # React.js SPA with Vite
│ ├── src/
│ │ ├── pages/ # React page components
│ │ │ ├── Homepage.jsx # Landing page with features
│ │ │ ├── SignIn.jsx # Multi-role authentication
│ │ │ ├── SignUp.jsx # Admin registration
│ │ │ ├── AdminDashboard.jsx # Admin panel with statistics
│ │ │ ├── DoctorDashboard.jsx # Doctor patient management
│ │ │ ├── PatientDashboard.jsx # Patient health records
│ │ │ ├── PharmacistDashboard.jsx # Pharmacy inventory system
│ │ │ └── NotFound.jsx # 404 error page
│ │ ├── services/ # API service layer
│ │ │ ├── api.js # Axios API client with interceptors
│ │ │ ├── authService.js # Authentication service
│ │ │ └── aiService.js # AI/ML service integration
│ │ ├── components/ # Reusable React components
│ │ │ └── HealthPredictionExample.jsx
│ │ ├── App.jsx # Main app with routing and auth
│ │ ├── main.jsx # React entry point
│ │ └── index.css # Tailwind CSS global styles
│ ├── public/
│ ├── package.json
│ └── vite.config.js # Vite build configuration
├── ml-microservice/ # Python FastAPI ML service
│ ├── app/
│ │ ├── api/
│ │ │ ├── v1/
│ │ │ │ ├── endpoints/ # AI/ML endpoint handlers
│ │ │ │ │ ├── diagnostic.py # Diagnostic assistance
│ │ │ │ │ ├── document_summarization.py # Document AI summarization
│ │ │ │ │ ├── health_prediction.py # Health risk prediction
│ │ │ │ │ ├── prescription.py # Prescription analysis
│ │ │ │ │ ├── recommendations.py # Health recommendations
│ │ │ │ │ └── report_analysis.py # Medical report analysis
│ │ │ │ └── router.py # API v1 router
│ │ │ └── schemas.py # Pydantic request/response models
│ │ ├── core/
│ │ │ ├── config.py # FastAPI configuration
│ │ │ └── logger.py # Structured logging setup
│ │ └── services/
│ │ └── ml_service.py # ML model inference logic
│ ├── main.py # FastAPI application entry point
│ ├── requirements.txt # Python dependencies
│ └── README.md # ML service documentation
└── docs/
├── screenshots/ # Application screenshots
└── roadmap.txt # Development roadmap
{
fullname: String (required),
email: String (unique, required),
password: String (required, hashed),
role: String (default: "admin"),
gender: String (enum: ["male", "female", "other", ""]),
phone: String,
timestamps: true
}
{
name: String (required),
email: String (unique, required),
password: String (required, hashed),
specialization: String,
admin_id: ObjectId (ref: "Admin", required),
role: String (default: "doctor"),
timestamps: true
}
{
name: String (required),
email: String (unique, required),
password: String (required, hashed),
doctor_id: ObjectId (ref: "Doctor", required),
admin_id: ObjectId (ref: "Admin"),
role: String (default: "patient"),
timestamps: true
}
{
name: String (required),
email: String (unique, required),
password: String (required, hashed),
gender: String (enum: ["male", "female", "other", ""]),
phone: String,
inventory: [String],
admin_id: ObjectId (ref: "Admin", required),
role: String (default: "pharmacist"),
timestamps: true
}
{
name: String (required),
description: String,
quantity: Number (default: 0),
category: String,
expiryDate: Date,
price: Number,
patient_id: ObjectId (ref: "Patient"),
doctor_id: ObjectId (ref: "Doctor"),
pharmacist_id: ObjectId (ref: "Pharmacist"),
timestamps: true
}
{
title: String (required),
description: String,
fileUrl: String,
patient_id: ObjectId (ref: "Patient"),
doctor_id: ObjectId (ref: "Doctor"),
uploadedBy: ObjectId (ref: "Doctor"),
fileName: String,
originalName: String,
fileType: String,
fileSize: Number,
s3Key: String,
s3Url: String,
category: String (enum: ["lab-report", "prescription", "scan", "consultation", "other"]),
status: String (enum: ["pending", "verified", "under-review"]),
timestamps: true
}
{
type: String (required, enum: ["add", "issue", "remove", "update"]),
medicineName: String (required),
medicineId: ObjectId (ref: "Medicine"),
quantity: Number (required),
price: Number,
totalAmount: Number,
patientName: String,
notes: String,
pharmacist_id: ObjectId (ref: "Pharmacist", required),
previousQuantity: Number,
newQuantity: Number,
timestamps: true
}
{
title: String (required),
description: String,
reportType: String (enum: ["inventory", "transaction", "summary", "custom"]),
pharmacist_id: ObjectId (ref: "Pharmacist", required),
fileName: String,
originalName: String,
fileType: String (default: "application/pdf"),
fileSize: Number,
s3Key: String,
s3Url: String,
dateFrom: Date,
dateTo: Date,
generatedAt: Date,
status: String (enum: ["generating", "completed", "failed"]),
timestamps: true
}
{
doctor_id: ObjectId (ref: "Doctor"),
patient_id: ObjectId (ref: "Patient"),
appointmentDate: Date (required),
notes: String,
timestamps: true
}
http://localhost:5000| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API status and version |
| GET | /api/health |
Health check with uptime |
/auth)| Method | Endpoint | Description | Request Body |
|---|---|---|---|
| POST | /sign-up |
Register new admin (role must be “admin”) | { fullname, email, password, role: "admin" } |
| POST | /sign-in |
Sign in for all roles | { email, password, role } |
Note: The
/sign-upendpoint only allows admin registration. Therolefield must be set to"admin". Other user types (doctors, pharmacists, patients) are created by admins through the admin routes.
Response: Returns JWT token and user object
/admin)| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /add-user |
Add doctor or pharmacist | Yes (Admin) |
| GET | /users |
Get all staff (doctors/pharmacists) | Yes (Admin) |
| DELETE | /remove-user/:id |
Remove doctor or pharmacist | Yes (Admin) |
| GET | /patients |
Get all patients | Yes (Admin) |
| POST | /add-patient |
Add a new patient | Yes (Admin) |
| DELETE | /remove-patient/:id |
Remove a patient | Yes (Admin) |
| GET | /profile |
Get admin profile | Yes (Admin) |
| PUT | /profile |
Update admin profile | Yes (Admin) |
| PUT | /change-password |
Change admin password | Yes (Admin) |
/doctor)| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /my-patients |
Get patients assigned to doctor | Yes (Doctor) |
| POST | /add-patient |
Add a new patient | Yes (Doctor) |
| DELETE | /remove-patient/:id |
Remove a patient | Yes (Doctor) |
/pharmacist)| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /add-medicine |
Add medicine to inventory | Yes (Pharmacist) |
| GET | /medicines |
Get all medicines | Yes (Pharmacist) |
| PUT | /update-medicine/:id |
Update medicine details | Yes (Pharmacist) |
| POST | /issue-medicine |
Issue medicine to patient | Yes (Pharmacist) |
| DELETE | /remove-medicine/:id |
Remove medicine from inventory | Yes (Pharmacist) |
| GET | /inventory-stats |
Get inventory statistics | Yes (Pharmacist) |
| GET | /transactions |
Get all transactions | Yes (Pharmacist) |
| GET | /profile |
Get pharmacist profile | Yes (Pharmacist) |
| PUT | /profile |
Update pharmacist profile | Yes (Pharmacist) |
| PUT | /update-password |
Change pharmacist password | Yes (Pharmacist) |
| GET | /reports |
Get all generated reports | Yes (Pharmacist) |
| POST | /generate-report |
Generate a new PDF report | Yes (Pharmacist) |
| GET | /report-download/:reportId |
Get report download URL | Yes (Pharmacist) |
| DELETE | /report/:reportId |
Delete a report | Yes (Pharmacist) |
/api/documents)| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /upload |
Upload a medical document | Yes (Patient) |
| POST | /list |
Get all documents for patient | Yes (Patient) |
| POST | /view/:documentId |
Get pre-signed URL to view document | Yes (Patient) |
| POST | /download/:documentId |
Get pre-signed URL to download | Yes (Patient) |
| DELETE | /:documentId |
Delete a document | Yes (Patient) |
/ai)| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /health-prediction |
Predict health risks from patient data | Yes |
| POST | /diagnostic |
Get diagnostic suggestions from symptoms | Yes |
| POST | /document-summarization |
AI-powered document summarization | Yes |
| POST | /prescription-analysis |
Analyze prescriptions for interactions | Yes |
| POST | /report-analysis |
Analyze medical reports for abnormalities | Yes |
| POST | /recommendations |
Generate personalized health recommendations | Yes |
/admin)| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /generate-api-token |
Generate new API token for admin | Yes (Admin) |
| GET | /api-token |
Get current API token info | Yes (Admin) |
| DELETE | /api-token |
Revoke current API token | Yes (Admin) |
| GET | /validate-token/:apiToken |
Validate API token (public) | No |
| GET | /critical-diseases |
Get disease statistics from AI | Yes (Admin) |
| GET | /weekly-activity |
Get 7-day activity analytics | Yes (Admin) |
| GET | /emergency/patient/:patientId |
Get complete patient data for emergency access | Yes (Admin) |
The application uses Mongoose as the ODM (Object Document Mapper) for MongoDB. Key database interactions include:
db.js)doctor_id in Patient)createdAt and updatedAt fieldsClone the repository
git clone https://github.com/abhinavkumar2369/Health-Track.git
cd Health-Track
Backend Setup
cd backend
npm install
Frontend Setup
cd ../frontend
npm install
ML Microservice Setup
cd ../ml-microservice
pip install -r requirements.txt
# or using a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Start the Backend Server
cd backend
npm start
# or for development with hot reload:
npm run dev
The backend server will start at http://localhost:5000
Start the ML Microservice
cd ml-microservice
python main.py
# or using uvicorn directly:
uvicorn main:app --reload --port 8000
The ML service will start at http://localhost:8000
API documentation available at http://localhost:8000/docs
Start the Frontend Development Server
cd frontend
npm run dev
The frontend will start at http://localhost:5173 (default Vite port)
Build Frontend for Production
cd frontend
npm run build
backend/.env)Create a .env file in the backend directory:
# Server Configuration
PORT=5000
NODE_ENV=development
# MongoDB Configuration
MONGO_URI=mongodb://localhost:27017/health-track
# Or use MongoDB Atlas:
# MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/health-track
# JWT secret (set a strong value in production)
JWT_SECRET=your_super_secret_jwt_key_change_this_in_production
# ML Microservice Configuration
ML_SERVICE_URL=http://localhost:8000
# AWS S3 configuration (optional)
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_REGION=your_aws_region
AWS_BUCKET_NAME=your_bucket_name
# Twilio configuration (optional)
TWILIO_ACCOUNT_SID=your_twilio_sid
TWILIO_AUTH_TOKEN=your_twilio_token
TWILIO_PHONE_NUMBER=your_twilio_phone
frontend/.env)Create a .env file in the frontend directory:
# Backend API URL
VITE_API_URL=http://localhost:5000
# ML service URL (if accessed directly from the frontend)
VITE_ML_SERVICE_URL=http://localhost:8000
ml-microservice/.env)Create a .env file in the ml-microservice directory:
# Server Configuration
PORT=8000
HOST=0.0.0.0
LOG_LEVEL=INFO
# Backend Service URL
BACKEND_SERVICE_URL=http://localhost:5000
# OpenAI API configuration (document summarization)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-3.5-turbo
# CORS Configuration
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:5000
# ML Model Configuration
MODEL_PATH=./models
ENABLE_GPU=false
http://localhost:5173This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.