# nemoxus/sushruta architecture

> Architecture diagram of the GitHub repository nemoxus/sushruta, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nemoxus/sushruta
- Repository: https://github.com/nemoxus/sushruta

## Overview

##### Main Components
- Frontend (User Interface)
- Built with React (files like App.jsx, CheckUpBtn.jsx, InputDataPage.jsx, etc.) and configured using Vite (vite.config.js) with package.json and index.html.
- Utilizes supporting assets (in src/assets), utility libraries (src/lib/utils.js), and styling (e.g., CSS files, index.css).
- Communicates with the backend via API calls.
- Includes Firebase configuration (src/firebaseConfig.js) which hints at user authentication/data management or real-time updates.

- Backend (AI/ML Service)
- Encapsulated in the sushruta-backend folder.
- Contains the main server file (ai_server.py) which likely exposes endpoints for predictions.
- Holds machine learning model files (rf_model.pkl, stacking_model.pkl) and a Procfile (suggesting deployment on a platform like Heroku).
- Manages ML tasks using Python libraries such as Scikit-Learn, XGBoost, TensorFlow/Keras, etc., as detailed in the README.

##### Understand the Relationships and Interactions
- User inputs (patient data) submitted from the frontend to the backend.
- Response containing prediction results coming back from the backend.
- The backend while processing may use:
- Pre-trained models (Random Forest, Stacking ensemble, ANN) to compute predictions.
- Data transformation and feature selection techniques (e.g., RFE, PCA) before prediction.
- Firebase might serve as a user/session management system (or other real-time service), so include its interactions if it plays a role in authentication or data persistence.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The clear split between frontend and backend components ensures that UI/UX logic is decoupled from business logic, which in this case is ML-driven predictive analytics.
- Modular Design: Each React component (e.g., CheckUpBtn, Predict, SignInBtn) handles individual UI pieces, and the backend is organized to encapsulate ML models and prediction business logic.
- API Communication: Illustrate the RESTful API interactions (or similar protocol) between the frontend and backend.
- Deployment and Build Tools: Mention Vite (for frontend development), Procfile (for backend deployment), and configuration files like vercel.json and eslint.config.js that support CI/CD and linting.

##### Specific Elements to Incorporate
- From User → Frontend → Backend → ML Models → Backend → Frontend → Display to User.
- Concise annotations for each part:
- Frontend: “Built with React & Vite; handles user interactions & API requests.”
- Backend: “Python service that processes patient data, selects features (using RFE/PCA), and utilizes ensemble & ANN models to predict heart disease.”
- Firebase: “Manages authentication and/or real-time data services.”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    UI["User Interface"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["React Frontend"]:::frontend
        VITE["Vite Build & Configuration"]:::frontend
        FIREBASE["Firebase Config"]:::firebase
        UTIL["Utility Library"]:::utility
    end

    %% Backend Layer
    subgraph "Backend Layer"
        AI["Python AI Server"]:::backend
        RF["ML Model - Random Forest"]:::ml
        STACK["ML Model - Stacking Ensemble"]:::ml
        PROC["Deployment Config (Procfile)"]:::deployment
    end

    %% Data Flow
    UI -->|"sends patient data"| FE
    FE -->|"API request"| AI
    AI -->|"uses"| RF
    AI -->|"uses"| STACK
    AI -->|"launched with"| PROC
    AI -->|"returns prediction"| FE
    FE -->|"displays prediction"| UI
    FE -->|"utilizes"| UTIL
    FE -->|"configured by"| VITE
    FE -->|"authenticates via"| FIREBASE

    %% Click Events
    click FE "https://github.com/nemoxus/sushruta/tree/main/src/"
    click VITE "https://github.com/nemoxus/sushruta/blob/main/vite.config.js"
    click FIREBASE "https://github.com/nemoxus/sushruta/blob/main/src/firebaseConfig.js"
    click UTIL "https://github.com/nemoxus/sushruta/blob/main/src/lib/utils.js"
    click AI "https://github.com/nemoxus/sushruta/blob/main/src/sushruta-backend/ai_server.py"
    click RF "https://github.com/nemoxus/sushruta/blob/main/src/sushruta-backend/rf_model.pkl"
    click STACK "https://github.com/nemoxus/sushruta/blob/main/src/sushruta-backend/stacking_model.pkl"
    click PROC "https://github.com/nemoxus/sushruta/tree/main/src/sushruta-backend/Procfile"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef ml fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef firebase fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef utility fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef deployment fill:#F7DC6F,stroke:#F1C40F,stroke-width:2px;
    classDef user fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
```
