A machine learning-powered web application that estimates diabetes risk from clinical health metrics, built with a FastAPI backend and a Next.js frontend. Originally a Streamlit app, rebuilt into a full separate backend/frontend architecture.
- AI-powered predictions β a Random Forest Classifier (scikit-learn) trained on the Pima Indians Diabetes Database estimates risk from 8 clinical inputs.
- Population comparison β each input shows the dataset's actual average alongside your entry, for context.
- Session history β every check you run stays visible in a running list for the current session.
- Downloadable report β generates a plain-text summary of your inputs and result.
- Location-aware doctor recommendation β if a result reads High Risk, a button finds nearby endocrinologists (Oladoc in Pakistan, Google Maps elsewhere), based on your browser's location.
- Animated ECG pulse visual β a live-drawing heartbeat-style line that changes color depending on the result.
- Backend: FastAPI, scikit-learn, pandas, deployed on Render
- Frontend: Next.js (App Router, JavaScript, Tailwind CSS), deployed on Vercel
- Model: Random Forest Classifier, ~80.5% accuracy, trained on the Pima Indians Diabetes Database
cd backend
python -m venv venv
venv\Scripts\Activate.ps1
pip install -r requirements.txt
uvicorn app.main:app --reload
Runs at http://127.0.0.1:8000.
cd frontend
npm install
npm run dev
Runs at http://localhost:3000. Requires a .env.local file containing:
NEXT_PUBLIC_API_URL=http://127.0.0.1:8000
DiabetesDetector/
βββ backend/
β βββ app/
β β βββ main.py # FastAPI app: loads model, exposes /predict
β β βββ model.pkl # Pre-trained Random Forest model
β βββ requirements.txt
βββ frontend/
β βββ app/
β β βββ layout.js # Fonts, metadata
β β βββ page.js # Main UI: form, pulse animation, results
β β βββ globals.css # Design tokens (colors, fonts)
β βββ package.json
βββ Notebook/
β βββ explore.ipynb # Data analysis & model training
β βββ model.pkl
βββ assets/
β βββ confusion_matrix.png
β βββ DiabetesDetector.gif
βββ model.py # Alternate training script (Pipeline + scaler)
The model achieves ~80.5% accuracy. Confusion matrix on held-out test data:
The model is particularly strong at correctly identifying healthy patients, with a focus on minimizing false negatives.
Syed Ali Faraz β GitHub Profile
If you found this tool insightful, please give the repository a β!
