A production‑ready full‑stack mini project that predicts cardiac attack risk using patient vitals and lifestyle factors. The system is powered by Deep Learning, secured with Firebase Authentication, and deployed online for real‑world use.
🚀 Live Backend: https://cardiac-backend-xe0p.onrender.com
This application allows users to sign up, log in, and predict heart attack risk using a trained neural network model. Predictions are returned instantly through a FastAPI backend. The project is designed for college mini‑projects, ML demonstrations, and full‑stack learning.
- Multi‑Layer Perceptron (MLP) Neural Network
- Trained on UCI, synthetic, and lifestyle datasets
- Returns probability‑based cardiac risk score
- Firebase Authentication (Signup / Login)
- JWT‑protected API routes
- Only authenticated users can access predictions
- FastAPI backend with async endpoints
- React frontend with Dark Mode and responsive UI
- Real‑time predictions (no page reloads)
- Backend hosted on Render
- Frontend deployable via Firebase Hosting
- Firebase Admin SDK for secure server‑side access
| Layer | Technology |
|---|---|
| Frontend | React, Vite, Tailwind CSS |
| Backend | FastAPI, Uvicorn |
| ML | Scikit‑Learn (MLPClassifier) |
| Auth | Firebase Authentication |
| Database | SQLite / Firestore |
| Hosting | Render (Backend), Firebase (Frontend) |
cardiac-prediction/
│
├── backend/
│ ├── main.py # FastAPI entry point
│ ├── auth/ # Authentication routes & utils
│ ├── profile_routes.py # Protected user APIs
│ ├── database.py # Firebase / DB initialization
│ ├── models/ # Trained ML models (.pkl)
│ └── requirements.txt
│
├── client/
│ ├── src/
│ │ ├── components/ # Login, Signup, Predictor UI
│ │ ├── context/ # Auth Context
│ │ └── pages/
│ └── package.json
│
├── train_model.py # Model training
├── generate_data.py # Dataset generation
├── cardiac.db # Local SQLite DB
└── README.md
pip install -r backend/requirements.txt
python -m uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000Backend runs at:
http://localhost:8000
cd client
npm install
npm run devFrontend runs at:
http://localhost:5173
- Build Command:
pip install -r backend/requirements.txt- Start Command:
uvicorn backend.main:app --host 0.0.0.0 --port $PORT- Environment Variable:
FIREBASE_CREDENTIALS=<Firebase service account JSON>
npm run build
firebase deployAdd deployed frontend domain to:
Firebase Console → Authentication → Authorized Domains
- User signs up or logs in
- Firebase issues JWT
- JWT sent in API requests
- Backend verifies token
- Prediction endpoint unlocked
- Doctor/Admin dashboard
- Email & SMS alerts
- Model retraining pipeline
- Improved risk explainability
⚠️ Disclaimer: This project is for educational purposes only and should not be used for real medical diagnosis.