Skip to content

Chayapathi077/Glucotect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glucotect — AI-Powered Diabetes Risk Prediction Platform

glucotect1

Project Overview

What is Glucotect? Glucotect is a web-based AI-powered diabetes risk prediction platform that helps users understand their diabetes risk and detect potential diabetes-related complications — all from a clean, premium browser interface.

Think of it like a smart health screening tool. The user enters their health metrics (like glucose level, BMI, blood pressure), and Glucotect's trained machine learning models instantly analyse the data and tell them whether they're at High Risk or Low Risk for diabetes. If the risk is high, the user can go deeper with a detailed health check that screens for 5 additional diabetes-related diseases simultaneously.

The entire system is powered by Python, machine learning models trained on real clinical datasets, and a modern glassmorphism UI — no hospital visit required.


How Does It Work?

For Users (People Who Want to Check Their Health)

  1. Open the App — The user opens Glucotect in their browser (runs locally via Flask at http://127.0.0.1:5000). They're greeted with a sleek, dark glassmorphic input form.
  2. Enter Health Metrics — The user fills in 8 key health parameters:
    • Glucose Level (mg/dL)
    • Blood Pressure (mmHg)
    • Skin Thickness (mm)
    • Insulin Level (mu U/ml)
    • BMI (kg/m²)
    • Waist Circumference (cm)
    • Diabetes Pedigree Function
    • Age (years)
  3. Prediction Runs — The moment they click "Predict", the data is sent to the Flask backend, which does two things in parallel:
    • Runs the data through a trained Random Forest Classifier to get a model-based probability.
    • Compares each value against clinically defined normal ranges to calculate a range-based risk score.
    • The two scores are intelligently combined for a final verdict.
  4. Result is Shown — The user sees a clear High Risk / Low Risk verdict along with a probability percentage.
  5. Deep Dive (if High Risk) — If the user is flagged as High Risk, they can click "Check Further" which opens a detailed health check form. This screens for 5 diabetes-related conditions:
    • ❤️ Cardiovascular Disease
    • 🫘 Nephropathy (Kidney Disease)
    • 👁️ Retinopathy (Eye Disease)
    • 🦶 Neuropathy (Nerve Damage)
    • 🫀 Liver Disease
  6. Detailed Report — After submitting the detailed form, a comprehensive report is generated showing the risk level and probability for each of the 5 conditions, with a critical warning banner if 2 or more are flagged high risk.
glucotect2
  1. View Records — Every prediction is automatically saved to a local SQLite database. Users can visit the View Records page to see their full prediction history and delete old entries.

The Key Idea

Glucotect combines two risk assessment methods and merges them into a single, more accurate prediction:

  • ML Model Prediction: A Random Forest model trained on the Pima Indians Diabetes Dataset that has learned patterns from thousands of real patient records.
  • Range-Based Risk Scoring: A rule-based system that calculates how far each health metric deviates from clinically defined healthy ranges.

If either method signals danger, the system flags High Risk — making it both sensitive and robust.


Technologies Used

Frontend (What You See)

Technology What It Does
HTML5 + Jinja2 The structure of every page. Jinja2 is Flask's template engine that lets Python variables and logic appear directly in HTML.
Vanilla CSS A single shared style.css file handles the entire design system — gradients, glassmorphism cards, animations, layout.
Bootstrap 5 Provides the responsive grid system (row, col-md-6) for the form layout and utility classes.
Font Awesome 6 The icon library powering every icon — the heartbeat logo, phone icon in the footer, history icon, etc.
Google Fonts (Poppins) The premium typeface used throughout the entire app for a modern, clean look.
Vanilla JavaScript Handles the modal popups (Contact & Privacy Policy), form keyboard navigation, and click-outside-to-close behaviour.

Backend (Behind the Scenes)

Technology What It Does
Flask (Python) The web framework that powers the entire backend — serving pages, receiving form data, running predictions, and managing records.
Jinja2 Templating Flask's built-in engine that merges Python prediction results into HTML pages dynamically.
SQLite A lightweight, file-based database (predictions.db) that stores every prediction with its timestamp, result, probability, and inputs.
Python Session Flask sessions temporarily store detailed health check results between the form submission and the report page.

Machine Learning

Technology What It Does
scikit-learn The Python library used to train all machine learning models — Random Forest classifiers for all 6 predictions.
Random Forest Classifier The core algorithm. An ensemble of decision trees that votes on whether a patient is high or low risk.
joblib Saves and loads the trained ML models as .pkl and .joblib files so they don't need to be retrained on every app start.
NumPy & Pandas Used during model training to process and analyse the diabetes dataset.
StandardScaler Normalises the input features before feeding them into the diabetes model so all values are on the same scale.

ML Models in the Project

Model File Predicts
diabetes_model.pkl Main diabetes risk (High / Low)
cardio_model.pkl Cardiovascular disease risk
nephropathy_model.pkl Kidney disease risk
retinopathy_model.pkl Eye disease risk
neuropathy_model.pkl Nerve damage risk
liver_model.pkl Liver disease risk

API Endpoints

Glucotect exposes both traditional web routes (for the HTML interface) and modern JSON API endpoints (ready for any future React/mobile frontend):

Web Routes

Route Method Description
/ GET Home page — the main prediction form
/predict POST Receives form data, runs prediction, shows result
/result GET Fetches the latest result from DB
/detailed-check GET Shows the detailed health check form
/run-detailed-prediction POST Runs all 5 secondary model predictions
/view-last-detailed-report GET Displays the detailed report from session
/records GET Shows the full prediction history table
/delete_record/<id> POST Deletes a specific record from the DB

JSON API Routes

Route Method Description
/api/predict POST Same as /predict but returns JSON — for React/JS frontend
/api/records GET Returns all records as a JSON array
/api/delete_record/<id> POST Deletes a record, returns JSON status
/api/run-detailed-prediction POST Runs detailed prediction, returns JSON results

Architecture Diagram

┌──────────────────────────────────────────────────────┐
│                   USER'S BROWSER                     │
│                                                      │
│  ┌──────────────┐  ┌────────────┐  ┌──────────────┐  │
│  │  HTML + CSS  │  │ JavaScript │  │  Bootstrap 5 │  │
│  │  (UI Pages)  │  │  (Modals,  │  │  (Grid/Form) │  │
│  │              │  │  Keyboard) │  │              │  │
│  └──────┬───────┘  └─────┬──────┘  └──────────────┘  │
│         │                │                           │
└─────────┼────────────────┼───────────────────────────┘
          │  HTTP Request  │
          ▼                ▼
┌──────────────────────────────────────────────────────┐
│              FLASK BACKEND (app.py)                  │
│                                                      │
│  ┌──────────────────────────────────────────────┐    │
│  │              Route Handlers                  │    │
│  │  /predict  /detailed-check  /records  /api/* │    │
│  └──────────────────┬───────────────────────────┘    │
│                     │                                │
│         ┌───────────┼────────────┐                   │
│         ▼           ▼            ▼                   │
│  ┌────────────┐ ┌────────┐ ┌──────────────────────┐  │
│  │  ML Models │ │SQLite  │ │   StandardScaler /   │  │
│  │ (.pkl files│ │   DB   │ │   Range Risk Logic   │  │
│  │  x 6 models│ │(.db)   │ │                      │  │
│  └────────────┘ └────────┘ └──────────────────────┘  │
│                                                      │
│  ┌────────────────────────────────────────────────┐  │
│  │           Jinja2 Template Engine               │  │
│  │  input.html / result.html / records.html /     │  │
│  │  detailed_check.html / detailed_report.html    │  │
│  └────────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────────┘

Project File Structure

Glucotect/
│
├── app.py                    ← Main Flask application & all routes
├── train_models.py           ← Script used to train all ML models
├── diabetes_prediction.py    ← Helper prediction logic
│
├── diabetes_model.pkl        ← Trained diabetes classifier
├── scaler.pkl                ← StandardScaler for input normalisation
├── cardio_model.pkl          ← Cardiovascular risk model
├── nephropathy_model.pkl     ← Kidney disease model
├── retinopathy_model.pkl     ← Eye disease model
├── neuropathy_model.pkl      ← Nerve damage model
├── liver_model.pkl           ← Liver disease model
│
├── predictions.db            ← SQLite database (auto-created)
│
├── static/
│   └── style.css             ← Entire design system (glassmorphism, animations)
│
└── templates/
    ├── input.html            ← Main prediction form
    ├── result.html           ← Prediction result page
    ├── records.html          ← Prediction history table
    ├── detailed_check.html   ← Detailed health symptoms form
    └── detailed_report.html  ← Detailed multi-disease report

Summary

Glucotect is an AI-powered, multi-model diabetes risk screening platform. Users enter 8 health metrics and instantly receive a risk verdict powered by a Random Forest machine learning model combined with clinical range analysis. High-risk users can go further with a 5-condition detailed screening covering cardiovascular, kidney, eye, nerve, and liver disease.

It is built with Flask (Python) on the backend, scikit-learn for all 6 machine learning models, SQLite for local data persistence, and a premium glassmorphic HTML/CSS UI that makes it feel like a professional medical-grade application — while remaining fully local, private, and fast.

📄 License

© 2026 Glucotect. All rights reserved.

About

An AI diabetes prediction platform combining Random Forest models with clinical range analysis to evaluate risk and screen for five systemic complications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors