How nishok-12/meditrain_ai works
1. Purpose and Runtime
MediTrain AI is a Flask-based medical-assistance application with separate doctor and patient chat experiences, disease-related prediction pages, account/profile/history functionality, and a guest quick-chat path. Its executable entry point is Final_project/app.py; it runs as a Python 3.8+ web server, locally documented on port 9999 and deployable to Render.
2. Web Application Boundary
Final_project/app.py is the central composition point for Flask routes, request handling, template rendering, model/data loading, and persistence. Server-rendered UI templates define the application’s main surfaces:
• Final_project/templates/home.html
• Final_project/templates/chat.html
• Final_project/templates/pchat.html
Authenticated account workflows are represented by Final_project/templates/login.html, Final_project/templates/register.html, and Final_project/templates/profile.html. Static CSS and packaged inference assets are served from Final_project/static/.
3. Dual Chat / Guidance Flows
The product distinguishes doctor-oriented and patient-oriented conversational paths, with quick chat available without login and profile/history requiring authentication. The model-development boundary is split by audience:
• Models/Doctor Model/symptom_disease.ipynb
• Models/Doctor Model/disease_treatment.ipynb
• Models/Patient Model/disease_symptom.ipynb
• Models/Patient Model/disease_treatment.ipynb
These notebooks are offline training/experimentation artifacts; production inference consumes serialized assets packaged under Final_project/static/model/.
4. ML Inference Assets
The deployed application uses locally stored, scratch-built sklearn-style classifiers and text vectorizers rather than a remote model API or pretrained model service. Core prediction artifacts include:
• Final_project/static/model/logistic_regression_model.pkl
• Final_project/static/model/tfidf_vectorizer.pkl
• Final_project/static/model/enhanced_treatment_prediction_model.joblib
Additional disease-specific artifacts support diabetes, heart-disease, and Alzheimer-related views: diabetes.pkl, hdp_model.pkl, and alzheimer_model.pkl in Final_project/static/model/. Corresponding page boundaries are Final_project/templates/diabetes.html, Final_project/templates/heart_disease.html, and Final_project/templates/alzheimer.html.
5. Data Pipeline and Knowledge Inputs
Raw Kaggle-derived source data is retained separately from transformed datasets:
• Datasets/Actual_downloaded_datasets/dataset.csv
• Datasets/Actual_downloaded_datasets/symptom_precaution.csv
• Datasets/Modifided_datasets/disease.csv
The runtime receives a curated copy of key CSVs from Final_project/static/dataset/, including symptoms.csv, disease.csv, and unique_treatments.csv. This forms the boundary between offline dataset preparation/model training and web-time lookup or prediction.
6. Persistence and Schema Evolution
User data and diagnostic/history-related state are stored in a local SQLite database:
• Final_project/instance/meditrain.db
Flask-SQLAlchemy and Flask-Migrate are the intended persistence stack. Migration history and schema evolution are tracked under:
• Final_project/migrations/env.py
• Final_project/migrations/versions/7d25f1a8921a_initial_migration.py
SQLite is file-backed and appropriate for local/small deployment, but requires persistent disk handling when hosted on Render.
7. Infrastructure and Dependencies
The runtime dependency contract is Final_project/requirements.txt, covering Flask, SQLAlchemy/migrations, pandas, fuzzy matching, scikit-learn, and joblib. There are no declared external inference, identity, or managed-database services; model inference and data retrieval occur in-process from repository-packaged files. Render is the documented hosting target, while the application’s stateful SQLite database and large serialized model files are its principal deployment concerns.
Main entry points: app.py Flask application · disease.csv Curated training data · logistic_regression_model.pkl Packaged inference models · meditrain.db MediTrain SQLite
Components 17
Flask web app
- Flask application · Central route, rendering, inference, and persistence composition.
Final_project/app.py - Home and chat UI · Doctor and patient chat surfaces.
Final_project/templates/chat.html - Patient chat UI
Final_project/templates/pchat.html - Home UI
Final_project/templates/home.html - Account and profile UI · Login, registration, profile, and history workflows.
Final_project/templates/profile.html - Disease prediction pages · Diabetes, heart disease, and Alzheimer views.
Final_project/templates/diabetes.html
ML pipeline
- Packaged inference models · Local classifiers and vectorizers loaded in-process.
Final_project/static/model/logistic_regression_model.pkl - Disease-specific models · Diabetes, heart-disease, and Alzheimer prediction assets.
Final_project/static/model/diabetes.pkl - Doctor model experiments · Symptom-to-disease and disease-to-treatment development.
Models/Doctor Model/symptom_disease.ipynb - Patient model experiments · Disease-to-symptom and treatment development.
Models/Patient Model/disease_symptom.ipynb
Data & persistence
- Raw Kaggle datasets · Retained downloaded clinical source data.
Datasets/Actual_downloaded_datasets/dataset.csv - Curated training data
Datasets/Modifided_datasets/disease.csv - Runtime lookup datasets · Curated symptoms, disease, and treatment lookup data.
Final_project/static/dataset/symptoms.csv - MediTrain SQLite · Stores users and diagnostic/history-related state.
Final_project/instance/meditrain.db - Schema migrations · Tracks database schema evolution.
Final_project/migrations/env.py
Deployment
- Runtime dependencies · Flask, SQLAlchemy, pandas, sklearn, joblib, and related packages.
Final_project/requirements.txt - Render hosting · Requires persistent disk for SQLite state.
Connections 19
- Flask application → Home and chat UI: renders
- Flask application → Patient chat UI: renders
- Flask application → Home UI: renders
- Flask application → Account and profile UI: renders
- Flask application → Disease prediction pages: renders
- Flask application → Packaged inference models: loads for chat inference
- Flask application → Disease-specific models: loads for predictions
- Flask application → Runtime lookup datasets: reads lookups
- Flask application → MediTrain SQLite: persists users and history
- Schema migrations → MediTrain SQLite: evolves schema
- Raw Kaggle datasets → Curated training data: prepared into
- Curated training data → Doctor model experiments: training input
- Curated training data → Patient model experiments: training input
- Doctor model experiments → Packaged inference models: produces artifacts
- Patient model experiments → Packaged inference models: produces artifacts
- Curated training data → Runtime lookup datasets: curated copy
- Runtime dependencies → Flask application: defines runtime environment
- Render hosting → Flask application: hosts
- Render hosting → MediTrain SQLite: needs persistent storage