# nahbruhh/cantilever-beam-optimization architecture

> Architecture diagram of the GitHub repository nahbruhh/cantilever-beam-optimization, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nahbruhh/cantilever-beam-optimization
- Repository: https://github.com/nahbruhh/cantilever-beam-optimization

## Overview

##### Project type and purpose
- This is a single-page, Streamlit-based Python web application for optimizing cantilever beam designs (minimize weight, deflection, or stress) using ML-based methods.
- The user interacts via the browser (UI), and the app runs all logic in a single Python process.

##### File structure
- Top-level:
- app.py – the Streamlit entry point (UI + control flow)
- page_format.py – helper functions to standardize page layout/widgets
- assets/ – static images or CSS used in the UI
- requirements.txt – Python dependencies (e.g. streamlit, numpy, scikit-learn)
- .streamlit/config.toml – Streamlit configuration (theme, server settings)
- .devcontainer/devcontainer.json – development container config for VS Code devcontainer
- README.md, LICENSE, .gitignore – documentation and metadata
- No separate “backend” or database—everything lives in one process.

##### README for additional insights
- The README confirms Streamlit as the framework and outlines how to install and launch the app.
- No mention of external services or databases—only local ML models and computation.

##### Main components and their interactions
a. Streamlit UI Layer
– Inputs: sliders, text fields, dropdowns for beam parameters
– Outputs: charts, tables, numeric results
b. Optimization & ML Engine
– Core Python functions (in app.py or imported modules) that run optimization routines
– Pre-trained ML models or algorithms that predict deflection/stress
c. Static Assets
d. Configuration & Environment
– Streamlit server settings (.streamlit/config.toml)
– Dev container definition for reproducible setup
e. External Libraries
– streamlit, numpy, pandas, scikit-learn, plotly/matplotlib, etc.

Interaction flow:
User → Streamlit UI (app.py/page_format.py) → calls Optimization/ML functions → returns results → UI renders outputs.

##### Architectural patterns & design principles
- Single-process, event-driven application (Streamlit callback model)
- Clear separation between presentation (page_format.py + Streamlit widgets) and business logic (optimization code within app.py or imported modules)
- Reproducible environment via devcontainer and pinned requirements.txt

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Browser"]:::external
    subgraph "UI Layer"
        UI["Streamlit App (app.py)"]:::frontend
        PF["Page Formatting (page_format.py)"]:::frontend
    end
    subgraph "Business Logic"
        ML["ML & Optimization Logic"]:::logic
    end
    subgraph "Static Assets"
        Assets["assets/"]:::assets
    end
    subgraph "Configuration"
        Config[".streamlit/config.toml"]:::config
    end
    subgraph "Development Environment"
        Dev[".devcontainer/devcontainer.json"]:::dev
    end
    subgraph "Dependencies"
        Req["requirements.txt"]:::deps
    end
    subgraph "Documentation & Metadata"
        Readme["README.md"]:::docs
        License["LICENSE"]:::docs
        GitIgnore[".gitignore"]:::docs
    end

    User -->|"Inputs"| UI
    UI --> PF
    UI -->|"calls Optimization"| ML
    ML -->|"returns Results"| UI
    UI -->|"loads Assets"| Assets
    UI -->|"reads Config"| Config
    Dev -->|"defines Environment"| UI
    Req -->|"installed for Runtime"| UI
    Req -->|"installed for Runtime"| ML

    click UI "https://github.com/nahbruhh/cantilever-beam-optimization/blob/main/app.py"
    click PF "https://github.com/nahbruhh/cantilever-beam-optimization/blob/main/page_format.py"
    click Assets "https://github.com/nahbruhh/cantilever-beam-optimization/tree/main/assets/"
    click Config "https://github.com/nahbruhh/cantilever-beam-optimization/blob/main/.streamlit/config.toml"
    click Dev "https://github.com/nahbruhh/cantilever-beam-optimization/blob/main/.devcontainer/devcontainer.json"
    click Req "https://github.com/nahbruhh/cantilever-beam-optimization/blob/main/requirements.txt"
    click Readme "https://github.com/nahbruhh/cantilever-beam-optimization/blob/main/README.md"
    click License "https://github.com/nahbruhh/cantilever-beam-optimization/tree/main/LICENSE"
    click GitIgnore "https://github.com/nahbruhh/cantilever-beam-optimization/blob/main/.gitignore"

    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef logic fill:#E2F0D9,stroke:#3C763D,color:#3C763D
    classDef assets fill:#FFF4C1,stroke:#FFD324,color:#FFD324
    classDef config fill:#F8D7DA,stroke:#C82333,color:#C82333
    classDef dev fill:#E2E3E5,stroke:#6C757D,color:#6C757D
    classDef deps fill:#FCE8E6,stroke:#D73A49,color:#D73A49
    classDef docs fill:#EAF5FF,stroke:#0366D6,color:#0366D6
    classDef external stroke-dasharray: 5 5,fill:#FFFFFF,stroke:#000000,color:#000000
```
