How daniyalrosli/final-year-project works
Main Components
• Frontend: Located under the “fe” directory, it’s built with Next.js (using the App Router). This component includes pages for login, signup, dashboards, reports, and other views (e.g., “fe/src/app/dashboard/page.tsx”, “fe/src/app/login/page.tsx”). It also contains shared UI and context management (such as AuthContext).
• Backend: There are multiple backend parts.
• Django Application: Found in the “be/heartcare_backend” folder along with “manage.py”. This likely handles core application logic, API routing for user and data management, and integration with the database.
• Flask API: The presence of “app.py” at the project root suggests that a Flask application is used to bridge model integration with the frontend. This is consistent with the README, which mentions using Flask APIs to serve predictions.
• Machine Learning & Data Processing: The project includes “heart_disease_model.pkl”, “scaler.pkl”, and “model.ipynb” along with the CSV dataset. These elements represent the trained predictive model and associated preprocessing pipeline.
• Database: Although not visible as a configuration file, the README states MySQL is used to store patient records and historical data. This should be represented as a separate component interacting with the backend.
• Templates / Static Assets: The “templates” directory (with “index.html” and “result.html”) hints at server-rendered views (or legacy pages) that might be used for quick testing or fallback pages. Vercel configuration files (e.g., “vercel.json”) also suggest deployment details.
Relationships and Interactions
• The Frontend (Next.js) sends requests (via API routes) to the Backend.
• The Django backend manages user sessions, routing, and database CRUD operations (using MySQL).
• The Flask API, likely integrated within or alongside Django, handles requests for predictions by interfacing with the ML model.
• The ML model component (the .pkl and scaler files) is loaded by the Flask API to generate predictions based on patient data.
• User authentication is managed via authentication context and accompanying utility functions (e.g., “utils/auth.ts”) to secure the interactions.
• The data flows from the user (via the web interface) to the backend, triggers the prediction logic, and then returns the risk assessment and insights back to the dashboard for visualization.
Important Architectural Patterns
• Separation of Concerns: Clear separation between the frontend (presentation layer), backend (business logic and API endpoints), and machine learning (model inference).
• API Gateway/Service Layer: Use of Flask as a lightweight API for bridging ML predictions with the general purpose Django backend.
• Modular Design: Organized directory structures indicate that each major component (frontend, backend, ML model) is modular. For example, the “fe/src/app/api” directory shows API route organization for login, signup, etc.
• Data Pipeline: The model training (Jupyter Notebook) and saved artifacts (model and scaler files) represent the offline training phase, while the Flask API represents the online inference stage.
Final Recommendations
• Every component is clearly labeled with a brief description (e.g., “Next.js Frontend – Handles UI/UX”, “Django Backend – Manages API and business logic”, “Flask API – Serves ML predictions”).
• Aim for sufficient detail so that any stakeholder can understand how patient data flows through the system, how predictions are generated, and how data is stored.