A comprehensive web-based platform for diabetes risk assessment, health data visualization, and AI-powered health assistance.
- Overview
- Features
- Technology Stack
- Getting Started
- Project Structure
- API Endpoints
- Contributing
- License
Diabetes Care Home is an open-source application that combines machine learning with interactive health tools to support diabetes awareness and management. The platform enables users to:
- Assess their diabetes risk using a trained machine learning model
- Explore and visualize health data patterns through interactive charts
- Get instant answers to health queries via an AI-powered chatbot
- Access evidence-based lifestyle recommendations
- Connect with a community through a discussion forum
Diabetes affects millions worldwide, and early detection is crucial for effective management. This platform aims to make diabetes risk assessment accessible to everyone while providing educational resources and community support.
Medical Disclaimer: This application is intended for educational and informational purposes only. It does not provide medical advice, diagnosis, or treatment recommendations. Always consult a qualified healthcare professional for medical concerns.
The core feature uses a machine learning model trained on the Pima Indians Diabetes Dataset. Users input eight health parameters:
| Parameter | Description | Unit |
|---|---|---|
| Pregnancies | Number of pregnancies | Count |
| Glucose | Plasma glucose concentration (2 hours after glucose tolerance test) | mg/dL |
| Blood Pressure | Diastolic blood pressure | mm Hg |
| Skin Thickness | Triceps skin fold thickness | mm |
| Insulin | 2-Hour serum insulin | mu U/ml |
| BMI | Body Mass Index | kg/mΒ² |
| Diabetes Pedigree Function | Genetic predisposition score | Score |
| Age | Age of the individual | Years |
The model processes these inputs through a StandardScaler for normalization and returns a binary prediction (Diabetic / Not Diabetic).
The diabetes prediction model is trained on the Pima Indians Diabetes Dataset. Due to limitations of the dataset, gender and individual height/weight values are not included as input features. BMI is used as a combined indicator of height and weight.
Interactive visualization tools for understanding diabetes-related health patterns:
- Correlation Heatmap β Displays relationships between all health variables using Seaborn
- Glucose Distribution β Interactive histogram showing glucose level patterns across the dataset
- BMI Distribution β Visual analysis of Body Mass Index distribution
All charts are rendered using Plotly for interactivity and Matplotlib/Seaborn for statistical visualizations.
An intelligent assistant powered by Google Gemini API that can:
- Answer diabetes-related health questions
- Provide general information about symptoms, causes, and management
- Offer guidance on lifestyle modifications
- Respond in a conversational, user-friendly manner
Curated, evidence-based guidance covering:
- Dietary recommendations for blood sugar management
- Exercise and physical activity guidelines
- Stress management techniques
- Sleep hygiene practices
- Regular monitoring schedules
A simple discussion platform where users can:
- Share their experiences and stories
- Ask questions to the community
- Provide peer support
- View posts in reverse chronological order
| Technology | Purpose | Version |
|---|---|---|
| Python | Core programming language | 3.8+ |
| Flask | Web application framework | 2.x |
| Flask-CORS | Cross-Origin Resource Sharing | Latest |
| Scikit-learn | Machine learning model | Latest |
| Pandas | Data manipulation and analysis | Latest |
| NumPy | Numerical computing | Latest |
| Gunicorn | Production WSGI server | Latest |
| Technology | Purpose |
|---|---|
| HTML5 | Page structure and semantics |
| CSS3 | Styling and animations |
| Tailwind CSS | Utility-first CSS framework |
| JavaScript | Client-side interactivity |
| Technology | Purpose |
|---|---|
| Plotly | Interactive web-based charts |
| Matplotlib | Static chart generation |
| Seaborn | Statistical data visualization |
| Technology | Purpose |
|---|---|
| Google Gemini API | Conversational AI chatbot |
| google-generativeai | Python SDK for Gemini |
| Technology | Purpose |
|---|---|
| Render | Cloud hosting platform |
| Gunicorn | Production-grade WSGI server |
| python-dotenv | Environment variable management |
| Docker | Containerization |
Before you begin, ensure you have the following installed:
- Python 3.8 or higher
# Check Python version python --version
* **pip package manager**
```bash
# Check pip version
pip --version
- Git
# Check Git version
git --version
-
Docker Desktop (Optional, for containerized setup)
-
Required if you plan to run the application using Docker.
-
Google Gemini API Key β Required for the chatbot feature
-
Visit Google AI Studio
-
Sign in with your Google account
-
Click "Create API Key"
-
Copy and save the key securely
# Clone via HTTPS
git clone [https://github.com/your-username/diabetes-care-home.git](https://github.com/your-username/diabetes-care-home.git)
# Or clone via SSH
git clone [email protected]:your-username/diabetes-care-home.git
# Navigate to project directory
cd diabetes-care-home
Creating a virtual environment isolates project dependencies from your system Python.
Windows (Command Prompt):
python -m venv venv
venv\Scripts\activate
Windows (PowerShell):
python -m venv venv
.\venv\Scripts\Activate.ps1
macOS / Linux:
python3 -m venv venv
source venv/bin/activate
You should see (venv) prefix in your terminal indicating the virtual environment is active.
# Upgrade pip to latest version
pip install --upgrade pip
# Install all required packages
pip install -r requirements.txt
This installs the following packages:
- flask, flask-cors
- numpy, pandas
- matplotlib, seaborn, plotly
- scikit-learn
- python-dotenv
- google-generativeai
- gunicorn
Create a .env file in the project root directory:
Windows (Command Prompt):
echo GEMINI_API_KEY=your_api_key_here > .env
Windows (PowerShell):
"GEMINI_API_KEY=your_api_key_here" | Out-File -FilePath .env -Encoding utf8
macOS / Linux:
echo "GEMINI_API_KEY=your_api_key_here" > .env
Or manually create the file with the following content:
GEMINI_API_KEY=your_actual_gemini_api_key
Security Note: Never commit your
.envfile to version control. It should already be listed in.gitignore.
Ensure the following pre-trained model files exist in the project root:
diabetes_model.pklβ Trained classification modelscaler.pklβ Feature scaler for input normalizationdiabetes.csvβ Dataset for visualization features
If missing, you can retrain the model using the provided Jupyter notebook:
# Install Jupyter if not available
pip install jupyter
# Launch Jupyter and run train.ipynb
jupyter notebook train.ipynb
Development Mode:
python app.py
Production Mode (using Gunicorn):
gunicorn app:app --bind 0.0.0.0:5000
Open your web browser and navigate to:
http://localhost:5000
You should see the Diabetes Care Home landing page.
If you prefer to run the application in a consistent containerized environment, follow these steps instead of the manual installation.
- Prerequisite: Ensure Docker Desktop is installed and running on your machine.
- Configure Env: Create the
.envfile as described in Step 4 above. - Run: Open your terminal in the project root and run:
docker-compose up --build
- Access: Open your browser to
http://localhost:5000.
To stop the container, press Ctrl+C in the terminal.
diabetes-care-home/
β
βββ app.py # Main Flask application
β βββ Route definitions # All URL endpoints
β βββ ML model loading # Pickle file loading
β βββ Gemini integration # AI chatbot logic
β βββ Forum API # Post management
β
βββ diabetes_model.pkl # Trained scikit-learn model
βββ scaler.pkl # StandardScaler for feature normalization
βββ diabetes.csv # Pima Indians Diabetes Dataset
β
βββ train.ipynb # Jupyter notebook for model training
β
βββ requirements.txt # Python package dependencies
βββ Dockerfile # Docker build instructions
βββ docker-compose.yml # Container orchestration
βββ .env # Environment variables (not in repo)
βββ .gitignore # Git ignore rules
β
βββ static/ # Static assets
β βββ doctor.png # Image assets
β
βββ templates/ # Jinja2 HTML templates
βββ home.html # Landing page (route: /)
βββ index.html # Prediction form (route: /index)
βββ explore.html # Data visualization (route: /explore)
βββ chatbot.html # AI chatbot interface (route: /chatbot)
βββ life.html # Lifestyle tips (route: /life)
βββ forum.html # Community forum (route: /forum)
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Landing page |
| GET | /index |
Diabetes prediction form |
| POST | /predict |
Process prediction form submission |
| GET | /explore |
Data visualization dashboard |
| GET | /chatbot |
AI chatbot interface |
| GET | /life |
Lifestyle recommendations page |
| GET | /forum |
Community forum page |
| Method | Endpoint | Description | Request Body | Response |
|---|---|---|---|---|
| POST | /generate |
Send message to AI chatbot | {"message": "your question"} |
{"reply": "AI response"} |
| GET | /api/posts |
Retrieve all forum posts | β | Array of post objects |
| POST | /api/posts |
Create new forum post | {"content": "post text"} |
Created post object |
Chat with AI Assistant:
curl -X POST http://localhost:5000/generate \
-H "Content-Type: application/json" \
-d '{"message": "What are the symptoms of diabetes?"}'
Create Forum Post:
curl -X POST http://localhost:5000/api/posts \
-H "Content-Type: application/json" \
-d '{"content": "Hello, this is my first post!"}'
Get All Forum Posts:
curl http://localhost:5000/api/posts
We welcome contributions from developers of all skill levels.
Follow the Code Of Conduct: CODE_OF_CONDUCT.md
This project is open source and available under the MIT License.
MIT License
Copyright (c) 2024 Anshika Singh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Anshika Singh
- Pima Indians Diabetes Dataset β UCI Machine Learning Repository
- Google Gemini β AI chatbot capabilities
- Flask β Web framework
- Tailwind CSS β UI styling
Making diabetes care smarter and more accessible.