# gnhd/student-performance-analytics architecture

> Architecture diagram of the GitHub repository gnhd/student-performance-analytics, 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/gnhd/student-performance-analytics
- Repository: https://github.com/gnhd/student-performance-analytics

## Overview

##### Main Components Identification
- Frontend: Represented by the "Frontend" folder which includes index.html, script.js, and styles.css. This component handles the user interface, takes user input (both CSV uploads and manual input), and displays data visualizations.
- Backend: Represented by the "Backend" folder. Key files include api.py (FastAPI endpoints for handling requests), model.py (machine learning model training and predictions), and CompareModel.py (possibly for comparing multiple models). This component processes data, makes predictions, and serves API responses.
- Machine Learning Models and Assets: Inside the Backend, you have serialized model files (like student_performance_gb.pkl, student_performance_rf.pkl) and scaling objects (scaler_gb.pkl, scaler_rf.pkl) which form the core of the prediction functionality.
- Data Storage: The "Data" directory holds the CSV file with student performance data. This is used for batch predictions and model training.
- Supporting Components: Additional elements like __pycache__ directories indicate compiled Python files and a requirements.txt file for dependency management.

##### Relationships and Interactions
- The Frontend interacts directly with the Backend via two main API endpoints:
- One endpoint for batch predictions (accepting CSV files).
- A second endpoint for real-time/single student predictions.
- When a user submits data via the frontend (either by form input or file upload), the JavaScript (script.js) makes an API call to the FastAPI backend.
- The backend (in api.py) receives the requests, calls the prediction logic in model.py (and potentially CompareModel.py), and then uses the machine learning model(s) to generate predictions.
- The backend then sends a JSON response with the prediction results back to the frontend, which renders the output and visualizations.
- Additionally, visualization libraries (like Matplotlib, as mentioned in the README) may be used to generate graphs showing student performance trends.

##### Architectural Patterns and Design Principles
- Layered Separation: The project cleanly separates the frontend (presentation layer) and backend (business logic/data processing layer).
- API-Driven Communication: The FastAPI backend exposes RESTful endpoints which the frontend consumes.
- Component Modularity: Distinction between model storage, data handling, and prediction logic suggests organized, modularized code.

##### Relevant Technologies & Libraries
- Backend: Python, FastAPI, scikit-learn, Joblib (for model persistence), and potentially Matplotlib for visualization.
- Frontend: Plain HTML, CSS, and JavaScript.
- Data: CSV file for batch predictions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External User
    User["User"]:::user

    %% Frontend Section
    subgraph "Frontend"
        UI["Web Interface (index.html)"]:::frontend
        Script["script.js"]:::frontend
        Styles["styles.css"]:::frontend
    end

    %% Backend Section
    subgraph "Backend"
        API["API Service (FastAPI - api.py)"]:::backend
        subgraph "Prediction Engine"
            ML["Primary Model Logic (model.py)"]:::prediction
            MC["Model Comparison (CompareModel.py)"]:::prediction
        end
        subgraph "ML Models & Assets"
            ModelGB["student_performance_gb.pkl"]:::asset
            ModelRF["student_performance_rf.pkl"]:::asset
            ScalerGB["scaler_gb.pkl"]:::asset
            ScalerRF["scaler_rf.pkl"]:::asset
        end
        DS["Data Storage (student_performance_data.csv)"]:::data
    end

    %% Data Flow Connections
    User -->|"InputData"| UI
    Script -->|"SubmitData"| API
    API -->|"ProcessData"| ML
    DS -->|"BatchTraining"| ML
    ML -->|"Predict"| ModelGB
    API -->|"ReturnPrediction"| Script

    %% Click Events
    click UI "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Frontend/Index.html"
    click Script "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Frontend/script.js"
    click Styles "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Frontend/styles.css"
    click API "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Backend/api.py"
    click ML "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Backend/model.py"
    click MC "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Backend/CompareModel.py"
    click ModelGB "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Backend/student_performance_gb.pkl"
    click ModelRF "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Backend/student_performance_rf.pkl"
    click ScalerGB "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Backend/scaler_gb.pkl"
    click ScalerRF "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Backend/scaler_rf.pkl"
    click DS "https://github.com/gnhd/student-performance-analytics/blob/main/Student Performance Application/Backend/Data/student_performance_data.csv"

    %% Styles
    classDef user fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef prediction fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef asset fill:#FAD7A0,stroke:#333,stroke-width:2px;
    classDef data fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
