Health-Track

Health Track Banner

Overview

Health Track Banner

Features

Screenshots

Homepage

homepage-1 homepage-2 homepage-3 homepage-4

Authentication

Sign In Page Sign Up Page

Admin Dashboard

Admin


Technologies Used

Frontend

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

Backend

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

ML/AI Microservice

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

AI/ML Features

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

Technology Implementation and Usage

Frontend Technologies

React.js 19

React Router 7

Tailwind CSS 4

Axios

Lucide React

Vite

Backend Technologies

Node.js

Express.js

MongoDB

Mongoose

JWT (JSON Web Tokens)

bcryptjs

AWS SDK (Amazon S3)

Multer

PDFKit

Twilio

Crypto (Node.js Built-in)

ML/AI Microservice Technologies

Python 3.x

FastAPI

Uvicorn

Pydantic

NumPy

Pandas

Scikit-learn

OpenAI API

Python-dotenv

HTTPX

Database & Storage

MongoDB & Mongoose Integration

AWS S3 & Document Management


Project Architecture

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

Data Structures

MongoDB Models

Admin Schema

{
  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
}

Doctor Schema

{
  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
}

Patient Schema

{
  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
}

Pharmacist Schema

{
  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
}

Medicine Schema

{
  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
}

Document Schema

{
  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
}

Transaction Schema

{
  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
}

Report Schema

{
  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
}

Schedule Schema

{
  doctor_id: ObjectId (ref: "Doctor"),
  patient_id: ObjectId (ref: "Patient"),
  appointmentDate: Date (required),
  notes: String,
  timestamps: true
}

API Documentation

Base URL

Health Check Endpoints

Method Endpoint Description
GET / API status and version
GET /api/health Health check with uptime

Authentication Routes (/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-up endpoint only allows admin registration. The role field 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 Routes (/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 Routes (/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 Routes (/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)

Document Routes (/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/ML Routes (/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 API Token Routes (/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)

Database Interaction

The application uses Mongoose as the ODM (Object Document Mapper) for MongoDB. Key database interactions include:

  1. Connection Management: Singleton pattern with connection pooling (db.js)
  2. CRUD Operations: Full create, read, update, delete operations for all entities
  3. References: Documents use ObjectId references for relationships (e.g., doctor_id in Patient)
  4. Timestamps: All models include automatic createdAt and updatedAt fields
  5. Indexing: Unique indexes on email fields for fast lookups

Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/abhinavkumar2369/Health-Track.git
    cd Health-Track
    
  2. Backend Setup

    cd backend
    npm install
    
  3. Frontend Setup

    cd ../frontend
    npm install
    
  4. 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
    

Running the Application

  1. 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

  2. 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

  3. Start the Frontend Development Server

    cd frontend
    npm run dev
    

    The frontend will start at http://localhost:5173 (default Vite port)

  4. Build Frontend for Production

    cd frontend
    npm run build
    

Environment Variables

Backend (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 (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 (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

Usage

Getting Started as an Administrator

  1. Open the homepage at http://localhost:5173
  2. Select Sign Up to create an administrator account
  3. Complete the registration form
  4. After successful registration, the application redirects to the Admin Dashboard

Admin Dashboard

Doctor Dashboard

Pharmacist Dashboard

Patient Dashboard

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

Credits