How kumar-laxmi/heart-disease-prediction-system works
Project Type and Purpose
• This is a full-stack, monolithic Django web application enhanced with a Machine Learning component for heart disease prediction.
• The “health_desease” folder is the Django project (settings, routing, ASGI/WSGI), and “health” is the primary Django app (models, views, templates, static files, REST serializers, API views).
• It uses SQLite as its database, Bootstrap/CSS/JS for front-end styling, and Python ML libraries (scikit-learn, pandas, numpy) for training and prediction.
File Structure Analysis
Top-level:
• manage.py – Django CLI
• health_desease/ – Django project config
• health/ – core app (models, views, serializers, templates, static assets)
• Machine_Learning/ – Jupyter notebook and raw CSV for offline ML experimentation
• db.sqlite3, media/ – persistent storage (DB, uploaded CSV, images)
• .github/workflows – CI (CodeQL analysis)
Key patterns:
• MVC:
– Models in health/models.py
– Views/API endpoints in health/views.py & health/api_views.py
– Templates in health/templates & static assets in health/static
• REST API layer via serializers (health/serializers.py) & API views
• ML logic lives partly in the notebook and partly in a helper function (prdict_heart_disease) invoked by a Django view or API endpoint.
README Insights
• Describes modules for Patient, Doctor, Admin flows.
• Technology stack confirms Django, Bootstrap, scikit-learn, SQLite.
• ML training uses GradientBoostingClassifier on data loaded from a CSV stored in the database (Admin_Health_CSV model).
a. Main Components
1. Client Layer
– Web Browser (Patient/Doctor/Admin)
2. Presentation Layer
– Django Templates + Static Assets (CSS, JS, Images)
– Client-side Bootstrap & JavaScript
3. Application Layer
– Django Web Server (Gunicorn / uWSGI behind Nginx)
– URL Routing (health_desease/urls.py, urls1.py, routing.py for ASGI)
– Views & API Views (health/views.py, health/api_views.py)
– DRF Serializers (health/serializers.py)
4. Business-Logic Layer
– ML Prediction Function (prdict_heart_disease)
– Data-mining Notebook (Machine_Learning/Heart prediction.ipynb)
5. Data Layer
– SQLite Database (db.sqlite3) with tables: Users, Patients, Doctors, Feedback, Admin_Health_CSV, Prediction Logs, etc.
– Media Storage (media/heart.csv, uploaded files)
6. External Services
– None in current scope (optionally email/SMS or third-party ML API if extended)
b. Relationships & Data Flows
1. Client sends HTTP(S) requests to the Web Server.
2. Nginx (or built-in server) routes to Gunicorn → Django.
3. Django URL dispatcher invokes corresponding View or APIView.
4. If prediction request: View calls prdict_heart_disease → loads CSV from DB media location → uses scikit-learn model → returns prediction.
5. View queries/updates SQLite via Django ORM (Models).
6. Response rendered via a Template or as JSON (API).
7. Static assets served either by Django or a static server.
8. Admin interface uses Django’s built-in admin or custom templates.
c. Architectural Patterns & Principles
– Layered (Presentation, Application, Business, Data)
– MVC / MVT (Model-View-Template)
– Single-page flows for ML prediction and CRUD operations for users, doctors, feedback
– Reusable ML module invoked from web layer
d. Key Technologies & Libraries
– Python / Django Framework (health_desease, health app)
– Django REST Framework (serializers & API views)
– Bootstrap, CSS, JavaScript for front-end
– scikit-learn, pandas, numpy for ML
– SQLite for development DB
– GitHub Actions / CodeQL for CI
Essential Elements to Capture
• User roles and entry points (Patient, Doctor, Admin).
• Separation of concerns: UI, API, ML logic, Persistence.
• Interaction points between Django’s view layer and ML code.
• Data sources (heart.csv in media vs. historical logs in SQLite).