Skip to content

asiimhusain/CureHelplus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

259 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CureHelp+ | AI-Powered Health Risk Analyzer

CureHelp+ Flask Python Machine Learning

Your Personal Health Companion for Predictive Diagnostics and Medical Assistance

🌟 Overview

CureHelp+ is a Flask-based healthcare analytics platform that combines classical ML risk prediction, chest X-ray screening, medical report parsing, chatbot support, consultant discovery, a full-screen medical blog portal, and downloadable PDF reporting in one workflow.

It supports:

  • Patient profile management with persistent storage and session sync
  • Account authentication (OTP email verification + Google sign-in)
  • Multi-disease risk prediction for tabular clinical inputs
  • Pneumonia & Tuberculosis X-ray analysis via image upload endpoints
  • Medical report autofill from uploaded CSV/PDF/XLS/XLSX files
  • User dashboard overview with prediction/report/history aggregates
  • Rule-based healthcare chatbot powered by curated datasets
  • Consultant directory search (hospitals + doctors)
  • Curated medical blog experience with interactive curved article navigator
  • Admin dashboard for operational visibility and patient management

πŸ”— Project Links (Legacy)

βœ… What’s New / Current Highlights

  • Admin panel with login, dashboard metrics, and patient deletion actions
  • Medical report upload with format validation and 200 MB size limit
  • Enhanced PDF reports with risk gauges and detailed protocols
  • Profile persistence layer with JSON and optional PostgreSQL backend
  • OTP-based signup/login flows, password reset, and Google OAuth sign-in
  • User profile photo upload and authenticated report/history tracking
  • Dedicated /blog page with interactive 3D wheel article navigation UI
  • Chest X-ray endpoints for pneumonia and tuberculosis risk scoring

🧠 Machine Learning Modules

Disease / Task Input Type Model/Approach Output
Type-2 Diabetes Tabular Serialized sklearn pipeline Probability (%)
Coronary Artery Disease Tabular Serialized sklearn pipeline Probability (%)
Anemia Tabular Risk + type model stack Probability (%) + severity/type
Pneumonia X-ray Image TensorFlow/Keras model (.keras) Probability + Normal/Pneumonia
Tuberculosis X-ray Image PyTorch model (.pth) Probability + Normal/Tuberculosis + confidence band

🧩 Core Features

1) Patient Profile Workflow

  • Create profile using JSON or multipart form data
  • Optional medical report upload during profile creation
  • Session tracks active profile and disease predictions
  • Search, list, and delete stored profiles

2) Prediction Workflow

  • Tabular predictions:
    • Type-2 Diabetes
    • Coronary Artery Disease
    • Anemia
  • Image predictions:
    • Pneumonia (multipart/form-data with image)
    • Tuberculosis (multipart/form-data with image)

3) Reports and Guidance

  • Session prediction summary endpoint
  • Filterable PDF export by selected diseases
  • Risk-sensitive recommendation text generation

4) Chatbot and Consultant Directory

  • Rule-based chatbot using bot_data/ datasets
  • Cached responses (TTL controlled by environment variable)
  • Consultant directory with hospitals/doctors and search support

5) Admin Panel

  • Admin login/logout and protected routes
  • Dashboard metrics: profile counts, prediction counts, high-risk indicators
  • Disease and gender breakdowns
  • Recent patient activity with delete operation

πŸ“ Project Structure (High Level)

  • app.py β†’ Flask entry point, route definitions, model inference orchestration
  • profile_manager.py β†’ profile persistence manager (JSON/PostgreSQL + fallback)
  • report_parser.py β†’ extraction + field mapping for CSV/PDF/XLS/XLSX reports
  • chatbot.py β†’ dataset loading, query processing, response formatting, cache
  • consultant.py β†’ hospitals/doctors catalog and provider search
  • makepdf.py β†’ PDF generation with gauge visualization and recommendations
  • admin/ β†’ admin blueprint, auth flow, templates, dashboard logic
  • models/ β†’ trained model artifacts used at runtime
  • bot_data/ β†’ chatbot knowledge datasets
  • templates/, static/ β†’ frontend templates and static assets

πŸš€ Quick Start

Prerequisites

  • Python 3.9 or higher
  • pip
  • Git
  • Optional: Docker
  • Optional: PostgreSQL (only if using DB-backed profile storage)

Installation

  1. Clone the repository
git clone https://github.com/asimhusain-ai/CureHelpPlus.git
cd CureHelpPlus
  1. Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\activate      # Windows
source .venv/bin/activate    # macOS / Linux
  1. Install dependencies
pip install --upgrade pip
pip install -r requirements.txt
  1. Run the application
flask --app app run
  1. Open in browser

βš™οΈ Environment Variables

Core App

Variable Description Default
CUREHELP_SECRET_KEY Flask session secret key curehelp-secret-key
TB_THRESHOLD Tuberculosis decision threshold (0-1) 0.50
MODEL_WARMUP_ENABLED Enable startup model warmup thread true
MODEL_HEALTH_CHECK_INTERVAL_SECONDS Periodic model health-check interval 300

Google OAuth

Variable Description Default
GOOGLE_CLIENT_ID Google OAuth client ID empty
GOOGLE_CLIENT_SECRET Google OAuth client secret empty
GOOGLE_REDIRECT_URI Explicit callback URL override empty
APP_BASE_URL Base URL used to compose callback when redirect URI is not set empty

Admin Authentication

Variable Description Default
CUREHELP_ADMIN_USER Admin username admin
CUREHELP_ADMIN_PASS Admin password curehelp

Chatbot

Variable Description Default
CHAT_CACHE_TTL_SECONDS Chat response cache TTL in seconds 300

Profile Storage Backend

Variable Description Default
PROFILE_STORAGE_BACKEND Force backend (json / postgres) auto-detect
DATABASE_URL PostgreSQL connection URL empty
PROFILE_STORAGE_STRICT Fail if postgres requested but unavailable false
PROFILE_RUNTIME_JSON_FALLBACK Enable runtime fallback to JSON on DB errors true
PROFILE_AUTO_MIGRATE_JSON Migrate JSON profiles into postgres on startup true
PROFILE_DB_CONNECT_TIMEOUT PostgreSQL connect timeout in seconds 2
PROFILE_DB_STATEMENT_TIMEOUT_MS PostgreSQL statement timeout in milliseconds 3000
PROFILE_SYNC_QUEUE_MAXSIZE Max queued async postgres sync operations 2000

These timeout controls help reduce login/reload delays when PostgreSQL is slow or temporarily unavailable by failing fast and allowing JSON fallback behavior.

Auth Email / OTP Delivery

Variable Description Default
SMTP_EMAIL_ADDRESS Sender email/login for SMTP auth empty
SMTP_APP_PASSWORD SMTP app password / auth token empty
SMTP_HOST SMTP server host smtp.gmail.com
SMTP_PORT SMTP server port 465
SMTP_USE_SSL Use implicit SSL SMTP connection true
SMTP_USE_TLS Upgrade plain SMTP with STARTTLS false
SMTP_TIMEOUT_SECONDS SMTP connect/send timeout 20

For Gmail, keep SMTP_USE_SSL=true and SMTP_PORT=465 with an app password. If OTP emails fail, auth APIs now return explicit SMTP errors.

🧾 Upload/Input Constraints

Medical Report Upload (POST /api/profile)

  • Allowed formats: .csv, .pdf, .xls, .xlsx
  • Maximum size: 200 MB

X-ray Upload (POST /api/pneumonia, POST /api/tuberculosis)

  • Allowed formats: .jpg, .jpeg, .png
  • Maximum size: 10 MB
  • Request type: multipart/form-data

πŸ”Œ API Endpoints (Current)

General

  • GET / β†’ frontend landing page
  • GET /blog β†’ medical blog portal with interactive wheel navigator
  • GET /api/config β†’ baseline normal values for selected diseases
  • GET /uploads/<path:subpath> β†’ serve uploaded report/photo assets

Authentication

  • GET /api/auth/status
  • POST /api/auth/signup
  • POST /api/auth/verify-otp
  • POST /api/auth/login
  • GET /verify-email
  • POST /api/auth/resend-verification
  • POST /api/auth/forgot-password
  • POST /api/auth/reset-password
  • POST /api/auth/logout
  • POST /api/auth/logout-all
  • GET /api/auth/profile
  • PATCH /api/auth/profile
  • GET /api/auth/google/start
  • GET /api/auth/google/callback

Profile and Session

  • POST /api/profile β†’ create profile (+ optional report upload)
  • GET /api/profile β†’ get currently active profile from session
  • GET /api/profiles?q=<name> β†’ list/search profiles
  • DELETE /api/profiles/<profile_id> β†’ delete profile (if not active)
  • POST /api/reset β†’ clear session profile and predictions
  • POST /api/profile/upload-photo β†’ upload/update authenticated user profile photo
  • POST /api/auth/reports β†’ upload authenticated medical report
  • DELETE /api/auth/reports/<report_id> β†’ delete authenticated medical report
  • GET /api/dashboard/overview β†’ authenticated dashboard summary and charts payload
  • GET /api/auth/history/export β†’ export authenticated activity history

Predictions

  • POST /api/diabetes
  • POST /api/heart
  • POST /api/anemia
  • POST /api/pneumonia (image upload)
  • POST /api/tuberculosis (image upload)

Reporting, Chat, and Directory

  • GET /api/report β†’ prediction summary for active session
  • GET /api/report/pdf?disease=Type-2 Diabetes,Coronary Artery Disease
  • POST /api/chat β†’ chatbot response
  • GET /api/consultants?q=<text> β†’ provider search
  • GET /api/metrics/latency β†’ p50/p95/p99 latency summary + model health snapshot

Admin

  • GET/POST /admin/login
  • POST /admin/logout
  • GET /admin/home
  • GET /admin/
  • POST /admin/patients/<profile_id>/delete
  • POST /admin/users/<user_id>/activate
  • POST /admin/users/<user_id>/deactivate
  • POST /admin/users/<user_id>/force-reset
  • POST /admin/users/<user_id>/delete

πŸ“¦ Required Runtime Artifacts

Ensure these model files are available under models/:

  • diabetes_model.pkl
  • diabetes_scaler.pkl
  • heart_model.pkl
  • heart_scaler.pkl
  • anemia_risk_model.pkl
  • anemia_type_model.pkl
  • feature_scaler.pkl
  • label_encoder.pkl
  • pneumonia_model.keras
  • tb_model.pth

Chatbot dataset files expected in bot_data/:

  • Disease precaution.csv
  • DiseaseAndSymptoms.csv
  • medquad.csv
  • humanqa.csv
  • Optional: Final_Augmented.csv

πŸ§ͺ Testing

Run all tests:

pytest

🐳 Docker

Build and run locally:

docker build -t curehelplus:latest .
docker run -p 5000:5000 curehelplus:latest

☁️ Deployment (Azure Container Apps - Legacy Flow)

  1. Build image
docker build -t curehelplus:latest .
  1. Push to Azure Container Registry
az acr login --name cureacr
docker tag curehelplus:latest cureacr.azurecr.io/curehelplus:latest
docker push cureacr.azurecr.io/curehelplus:latest
  1. Deploy
az containerapp up --name curehelplus --resource-group curehelplus --location central-india --image cureacr.azurecr.io/curehelplus:latest --target-port 5000 --ingress external --environment managedEnvironment-curehelplus-ade7

🌟 Contributing

Contributions are welcome.

  • Fork the repository
  • Create a feature branch
  • Add/modify tests where relevant
  • Open a pull request with a clear description

⚠️ Medical Disclaimer

CureHelp+ is intended for informational and educational support only. It does not provide a medical diagnosis and is not a substitute for professional healthcare advice.

Author

Made with ❀️ by Asim Husain β€” https://www.asimhusain.dev

About

Flask-based healthcare analytics platform for multi-disease risk prediction with AI chatbot guidance, consultant search, report autofill, and PDF medical reporting.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors