Back to work
FYP Case Study2025Final Year Project (FYP)

Blood Sugar Tracker

Final Year Project — A clinical web application that predicts patient blood glucose levels using a trained ElasticNet ML model and provides a real-time daily health monitoring dashboard.

Project Spec Sheet

Type
Final Year Project
Year
2025
Backend
Python / Flask
ML Model
ElasticNet
Tech Stack
PythonFlaskscikit-learnSQLAlchemyElasticNet MLSQLite
View on GitHub

Key Features

ML Glucose Prediction

ElasticNet regression model predicts blood glucose (mg/dL) from patient vitals with clinical precision.

Patient Dashboard

Manage patient records, view prediction history, and track health trends over time.

Daily Health Logs

Staff log weight, macros (carbs, protein, fat), activity calories, and heart rate per patient per day.

Role-Based Auth

Flask-Login with admin and staff roles. All forms protected by CSRF tokens via Flask-WTF.

Smart Alert Flags

Patients with high-risk predicted glucose readings are auto-flagged in the dashboard for immediate attention.

Report Export

Generate per-patient PDF clinical reports and CSV data exports for offline analysis.

Problem

Medical staff lacked a fast, data-driven tool to predict blood glucose levels from patient vitals. Manual tracking across spreadsheets was error-prone and provided no early alert for high-risk glucose readings.

My Role

Sole developer — designed the full-stack Flask architecture, trained the ElasticNet regression model on patient vitals data, built the patient management dashboard, daily log system, role-based auth, and PDF/CSV report export.

Outcome

Delivered a fully functioning clinical prediction system with ML-powered glucose forecasting, admin and staff role access, automated high-risk alert flags, and exportable patient reports.

Full-Stack Clinical Architecture

The application follows a traditional MVC architecture using Flask as the web framework, SQLAlchemy as the ORM, and a pre-trained scikit-learn ElasticNet model served via joblib.

[Patient / Staff / Admin Browser]
   │
   ▼
[Flask Routes (app.py)] ── CSRF Protected WTForms
   │
   ├── [SQLAlchemy ORM] ── SQLite / PostgreSQL DB
   │       └── User, Patient, DailyLog models
   │
   └── [ML Prediction Pipeline]
           ├── ElasticNet model (.pkl)
           ├── Feature Scaler (.pkl)
           └── Feature Names (JSON)
  • ML Pipeline: Patient vitals (weight, carbs, protein, fat, activity calories, heart rate, time-of-day) are scaled and passed to a trained ElasticNet regression model to predict blood glucose in mg/dL.
  • Auth Layer: Flask-Login handles session management with role separation (admin vs. staff). All form submissions are CSRF protected via Flask-WTF.

Technical Details & Implementation

  • ElasticNet Model Training: Trained on clinical patient vitals dataset using scikit-learn's ElasticNet regressor with cross-validated hyperparameter tuning (L1/L2 regularization ratio). Serialised with joblib for production serving.
  • Daily Log System: Staff log patient vitals once per day (enforced by unique DB constraint on user_id + log_date). Net calories are computed server-side from macronutrient inputs.
  • Alert System: Patients with predicted glucose readings above clinical thresholds are automatically flagged with `alert_flag=True` and highlighted in the dashboard.
  • Report Export: PDF reports are generated per patient with their prediction history and health trends. CSV exports are available for bulk data analysis.

Project Outcomes & Results

  • ML Accuracy: ElasticNet model achieved strong predictive performance on held-out validation data with low RMSE on blood glucose prediction.
  • Clinical Utility: The alert system automatically identifies high-risk patients, enabling faster clinical intervention.
  • Full Production Stack: Role-based auth, CSRF security, database migrations, PDF export, and a clean dashboard UI — all functional in a single deployable Python app.

Challenges & Key Decisions

  • Challenge: Ensuring the ML model returns clinically meaningful predictions from sparse or incomplete patient data inputs.
  • Solution: Applied feature scaling with a pre-fitted StandardScaler and used ElasticNet's regularization to prevent overfitting on the limited clinical dataset. Added server-side validation to reject incomplete vitals submissions before predictions are made.

Contribution Details

  • 100% Solo Development: Designed and built the entire system — ML model training pipeline, Flask backend, Jinja2 frontend templates, SQLAlchemy database schema, Flask-Migrate migrations, role-based authentication, and report generation.

Appreciate this build

0 appreciations

Other Projects