# saipavankumar22/aluminiml architecture

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

- Interactive diagram: https://gitdiagram.com/saipavankumar22/aluminiml
- Repository: https://github.com/saipavankumar22/aluminiml

## Overview

##### Project Type and Purpose
- This is a full-stack Python/Flask web application embedding a machine-learning component.
- Purpose: accept casting parameters via a web form, run three pre-trained scikit-learn regression models (UTS, elongation, conductivity), and return predictions in real time.

##### File-Structure Analysis
- Top level:
- `app.py` – Flask application entry point (controllers/routes).
- `AluminiumBilletPropertiesPrediction.ipynb` – Jupyter notebook used to explore data and build/train models.
- `aluminium dataset.xlsx` – raw data for model training.
- `models/` – serialized model objects (`.pkl`).
- `templates/` – Flask Jinja2 HTML views (`alu.html`, login & signup pages).
- `static/` – CSS/JS assets.
- No external database—state is ephemeral, models live on disk.
- MVC-style separation: templates (View), `app.py` routes (Controller), pickled models (Model).

##### Key Insights from README
- Stack: Python, Flask, scikit-learn, HTML/CSS/JS.
- Input parameters: casting temp, cooling temp, casting speed, bar entry temp, emulsion temp/pressure/concentration, quench pressure.
- Output: UTS, elongation, conductivity.

##### Components
a. User Interface Layer
– Web Browser (HTML form in `alu.html`)
– Static Assets (CSS/JS) served from `/static`
b. Application Layer
– Flask App (`app.py`)
- HTTP endpoints:
- GET `/` → render input form
- POST `/predict` → parse form data, call ModelService
– Controller / Router logic
c. Machine-Learning Layer
– ModelService
- Loads `.pkl` files from `models/`
- Uses scikit-learn to run `.predict()`
d. Data & Storage
– Model Files on filesystem (`models/*.pkl`)
– (Offline) Data source: `aluminium dataset.xlsx` + Jupyter notebook pipeline
e. External Dependencies
– scikit-learn library
– Flask framework

##### Relationships & Data Flow
1. User fills form → Browser sends HTTP POST to Flask
2. Flask Route invokes ModelService → loads required `.pkl` model
3. ModelService returns prediction values
4. Flask renders `alu.html` with predictions embedded
5. Browser displays results

##### Architectural Patterns & Principles
- MVC Pattern: clear separation of views (templates), controllers (Flask routes), models (ML artifacts).
- Layered Architecture: UI → Application → ML → Persistence.
- Single-process, lightweight microservice-style Flask app.
- Configuration-as-code: models loaded by path, no external config server.

##### Technologies & Frameworks
- Flask (web server & routing)
- Jinja2 (templating engine)
- scikit-learn (ML inference)
- Python 3.x
- HTML/CSS/JavaScript (frontend)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        Browser["Web Browser (HTML Form)"]:::client
    end

    %% Web Server Layer
    subgraph "Web Server Layer"
        FlaskApp["Flask app.py (Controller/Router)"]:::server
        Templates["View Templates"]:::server
        alu["alu.html (Input Form)"]:::server
        login["wt-LogIn.html"]:::server
        signup["wt-SignUp.html"]:::server
        StaticAssets["Static Assets (CSS/JS)"]:::server
    end

    %% ML Inference Layer
    subgraph "ML Inference Layer"
        ModelService["ModelService (scikit-learn)"]:::ml
    end

    %% Storage Layer
    subgraph "Storage Layer"
        UTS["best_model_uts.pkl"]:::storage
        Elong["best_model_elongation.pkl"]:::storage
        Cond["best_model_conductivity.pkl"]:::storage
    end

    %% Offline Training Pipeline
    subgraph "Offline Training Pipeline"
        Notebook["AluminiumBilletPropertiesPrediction.ipynb"]:::offline
        Dataset["aluminium dataset.xlsx"]:::offline
    end

    %% Data Flows
    Browser -->|"GET /"| FlaskApp
    FlaskApp -->|"renders view"| alu
    FlaskApp -->|"renders view"| login
    FlaskApp -->|"renders view"| signup
    Browser -->|"loads static assets"| StaticAssets
    Browser -->|"POST /predict"| FlaskApp
    FlaskApp -->|"invoke predict()"| ModelService
    ModelService -->|"load .pkl"| UTS
    ModelService -->|"load .pkl"| Elong
    ModelService -->|"load .pkl"| Cond
    ModelService -->|predictions| FlaskApp
    FlaskApp -->|"response with predictions"| Browser

    Notebook -->|"exports models"| UTS
    Notebook -->|"exports models"| Elong
    Notebook -->|"exports models"| Cond
    Dataset -->|"used by notebook"| Notebook

    %% Click Events
    click alu "https://github.com/saipavankumar22/aluminiml/blob/main/templates/alu.html"
    click login "https://github.com/saipavankumar22/aluminiml/blob/main/templates/wt-LogIn.html"
    click signup "https://github.com/saipavankumar22/aluminiml/blob/main/templates/wt-SignUp.html"
    click StaticAssets "https://github.com/saipavankumar22/aluminiml/tree/main/static/"
    click FlaskApp "https://github.com/saipavankumar22/aluminiml/blob/main/app.py"
    click UTS "https://github.com/saipavankumar22/aluminiml/blob/main/models/best_model_uts.pkl"
    click Elong "https://github.com/saipavankumar22/aluminiml/blob/main/models/best_model_elongation.pkl"
    click Cond "https://github.com/saipavankumar22/aluminiml/blob/main/models/best_model_conductivity.pkl"
    click Notebook "https://github.com/saipavankumar22/aluminiml/blob/main/AluminiumBilletPropertiesPrediction.ipynb"
    click Dataset "https://github.com/saipavankumar22/aluminiml/blob/main/aluminium dataset.xlsx"

    %% Styles
    classDef client fill:#D6EFFF,stroke:#1B4F72,color:#1B2631;
    classDef server fill:#D5F5D5,stroke:#145A32,color:#0B5345;
    classDef ml fill:#F9E79F,stroke:#B9770E,color:#7D6608;
    classDef storage fill:#E5E8E8,stroke:#626567,color:#1C2833;
    classDef offline fill:#FADBD8,stroke:#922B21,color:#641E16;
```
