SmartHeartDiagnosis is a React + Vite web interface for a heart disease risk estimation system. It lets users enter clinical indicators, call the Flask machine learning API, compare model outputs, explore dataset statistics, and export a printable PDF report from the prediction result.
- Estimate heart disease risk as a percentage from 11 clinical indicators.
- Compare results from Decision Tree, Naive Bayes, SVM, and Random Forest.
- Display risk factors and reference recommendations.
- Visualize model metrics, ROC curves, and confusion matrices.
- Explore dataset statistics and correlations.
- Support dark mode and light mode.
- Preview and download the prediction result as a PDF report.
- AI assistant powered by the backend OpenAI API integration.
- Responsive layout with a mobile bottom navigation bar.
- React
- Vite
- JavaScript / JSX
- CSS
- Lucide React
- Flask API backend
- Scikit-learn models served from the backend
- OpenAI API for the AI assistant
- Node.js 20.19+ or 22.12+ recommended
- npm
- Backend API running locally or deployed
Create a .env file inside the frontend folder if you want to override the API URL:
VITE_API_BASE_URL=http://localhost:5000/apiFor production:
VITE_API_BASE_URL=https://your-backend-url.onrender.com/apiIf this variable is not set, the frontend falls back to:
http://localhost:5000/apiThe AI assistant is handled by the backend. Set these variables on the backend server, not in the frontend:
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4.1-mininpm installStart the backend first:
cd ../backend
python app.pyThen start the frontend:
cd ../frontend
npm run devOpen the Vite URL, usually:
http://localhost:5173npm run buildThe production build is generated in:
dist/npm run previewFor Render Static Site:
Root Directory: frontend
Build Command: npm install && npm run build
Publish Directory: frontend/distSet this environment variable:
VITE_API_BASE_URL=https://your-backend-url.onrender.com/apifrontend/
|-- public/
|-- src/
| |-- components/
| | |-- AboutTab.jsx
| | |-- AnalysisTab.jsx
| | |-- ChatAssistant.jsx
| | |-- DiagnosisTab.jsx
| | `-- ExplorerTab.jsx
| |-- utils/
| | `-- api.js
| |-- App.jsx
| |-- index.css
| `-- main.jsx
|-- index.html
|-- package.json
`-- vite.config.js