# martinjm97/ennui architecture

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

- Interactive diagram: https://gitdiagram.com/martinjm97/ennui
- Repository: https://github.com/martinjm97/ennui

## Overview

##### Project Type and Purpose
- ENNUI is a frontend-only, single-page application (SPA) for designing, training, visualizing, and exporting neural networks directly in the browser.
- Users drag-and-drop layers and activations to build network architectures, run training loops on in-browser data (e.g. MNIST/CIFAR-10), watch live training metrics, and export equivalent code in Python or Julia.

##### File Structure Analysis
- Top-level:
- Configuration and build: webpack.config.js, tsconfig.json, tslint.json, package.json, npm-shrinkwrap.json, build_prod.sh
- Distribution output: dist/
- src/
- src/model/ – “backend” logic in the browser: network construction, graph algorithms, in-browser training loops, parameter management, code generation (Python & Julia skeletons), export and save-state routing.

##### Insights from README
- Clear separation of concerns: UI vs. model logic.
- No server/backend: all computation, storage (URL state), and code generation happen client-side.
- Build steps via npm/webpack; one command bundles TS + SCSS into dist/.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build Pipeline
    subgraph "Build Pipeline" 
        WP[webpack.config.js]:::build
        TS[tsconfig.json]:::build
        TL[tslint.json]:::build
        PK[package.json]:::build
        NS[npm-shrinkwrap.json]:::build
        BL[build_prod.sh]:::build
    end
    subgraph "Distribution Output"
        DIST[dist/]:::build
    end
    WP -->|bundles| DIST
    TS -->|bundles| DIST
    TL -->|bundles| DIST
    PK -->|bundles| DIST
    NS -->|bundles| DIST
    BL -->|bundles| DIST

    %% Browser Runtime
    BR["Browser Runtime<br/>(index.html)"]:::external
    DIST -->|loads| BR

    click WP "https://github.com/martinjm97/ennui/blob/master/webpack.config.js"
    click TS "https://github.com/martinjm97/ennui/blob/master/tsconfig.json"
    click TL "https://github.com/martinjm97/ennui/blob/master/tslint.json"
    click PK "https://github.com/martinjm97/ennui/blob/master/package.json"
    click NS "https://github.com/martinjm97/ennui/blob/master/npm-shrinkwrap.json"
    click BL "https://github.com/martinjm97/ennui/blob/master/build_prod.sh"
    click DIST "https://github.com/martinjm97/ennui/tree/master/dist/"
    click BR "https://github.com/martinjm97/ennui/blob/master/index.html"

    %% UI Module
    subgraph "UI Module" 
        direction TB
        APP[app.ts]:::frontend
        WIN[window.ts]:::frontend
        ERR[error.ts]:::frontend
        MT[model_templates.ts]:::frontend
        UTIL[utils.ts]:::frontend
        STYLE[style.scss]:::frontend
        subgraph "Shapes" 
            direction TB
            ACT[activation.ts]:::frontend
            ALC[activationlayer.ts]:::frontend
            DRG[draggable.ts]:::frontend
            LYR[layer.ts]:::frontend
            SHP[shape.ts]:::frontend
            TBX[textbox.ts]:::frontend
            WIR[wire.ts]:::frontend
            WGD[wireguide.ts]:::frontend
            subgraph "Layer Shapes" 
                direction TB
                ADD[add.ts]:::frontend
                BN[batchnorm.ts]:::frontend
                CONV[convolutional.ts]:::frontend
                DNC[dense.ts]:::frontend
                DPO[dropout.ts]:::frontend
                FLT[flatten.ts]:::frontend
                INP[input.ts]:::frontend
                MPL[maxpooling.ts]:::frontend
                OUT[output.ts]:::frontend
            end
        end
    end

    click APP "https://github.com/martinjm97/ennui/blob/master/src/ui/app.ts"
    click WIN "https://github.com/martinjm97/ennui/blob/master/src/ui/window.ts"
    click ERR "https://github.com/martinjm97/ennui/blob/master/src/ui/error.ts"
    click MT "https://github.com/martinjm97/ennui/blob/master/src/ui/model_templates.ts"
    click UTIL "https://github.com/martinjm97/ennui/blob/master/src/ui/utils.ts"
    click STYLE "https://github.com/martinjm97/ennui/blob/master/src/ui/style.scss"
    click ACT "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/activation.ts"
    click ALC "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/activationlayer.ts"
    click DRG "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/draggable.ts"
    click LYR "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/layer.ts"
    click SHP "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shape.ts"
    click TBX "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/textbox.ts"
    click WIR "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/wire.ts"
    click WGD "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/wireguide.ts"
    click ADD "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/add.ts"
    click BN "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/batchnorm.ts"
    click CONV "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/convolutional.ts"
    click DNC "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/dense.ts"
    click DPO "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/dropout.ts"
    click FLT "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/flatten.ts"
    click INP "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/input.ts"
    click MPL "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/maxpooling.ts"
    click OUT "https://github.com/martinjm97/ennui/blob/master/src/ui/shapes/shapes/layers/output.ts"

    %% Model Module
    subgraph "Model Module" 
        direction TB
        BUILD[build_network.ts]:::model
        GRP[graphs.ts]:::model
        PARAM[params_object.ts]:::model
        MNM[mnist_model.ts]:::model
    end

    click BUILD "https://github.com/martinjm97/ennui/blob/master/src/model/build_network.ts"
    click GRP "https://github.com/martinjm97/ennui/blob/master/src/model/graphs.ts"
    click PARAM "https://github.com/martinjm97/ennui/blob/master/src/model/params_object.ts"
    click MNM "https://github.com/martinjm97/ennui/blob/master/src/model/mnist_model.ts"

    %% Data Loader
    subgraph "Data Loader" 
        direction TB
        DATA[data.ts]:::data
        MNM2[mnist_model.ts]:::data
    end

    click DATA "https://github.com/martinjm97/ennui/blob/master/src/model/data.ts"
    click MNM2 "https://github.com/martinjm97/ennui/blob/master/src/model/mnist_model.ts"

    %% Training & State
    subgraph "Training & State Management"
        direction TB
        SAVE[save_state_url.ts]:::model
        EXPM[export_model.ts]:::model
    end

    click SAVE "https://github.com/martinjm97/ennui/blob/master/src/model/save_state_url.ts"
    click EXPM "https://github.com/martinjm97/ennui/blob/master/src/model/export_model.ts"

    %% Code Generation & Export
    subgraph "Code Generation & Export Service"
        direction TB
        CG[code_generation.ts]:::export
        PY[python_skeleton.ts]:::export
        JUL[julia_skeleton.ts]:::export
        EXP[export_model.ts]:::export
    end

    click CG "https://github.com/martinjm97/ennui/blob/master/src/model/code_generation.ts"
    click PY "https://github.com/martinjm97/ennui/blob/master/src/model/python_skeleton.ts"
    click JUL "https://github.com/martinjm97/ennui/blob/master/src/model/julia_skeleton.ts"
    click EXP "https://github.com/martinjm97/ennui/blob/master/src/model/export_model.ts"

    %% User Download
    DOWNLOAD["Exported Code<br/>(Python/Julia)"]:::artifact

    %% Relationships
    APP -->|"calls"| BUILD
    APP -->|"calls"| GRP
    APP -->|"calls"| PARAM
    APP -->|"calls"| MNM
    BUILD -->|"loads"| DATA
    DATA -->|"provides data"| MNM2
    MNM -->|"trains on data"| DATA
    MNM -->|"emits metrics"| APP
    APP -->|"requests export"| CG
    CG -->|"generates"| PY
    CG -->|"generates"| JUL
    CG -->|"packages"| EXP
    EXP -->|"downloads"| DOWNLOAD
    MNM -->|"saves state"| SAVE
    SAVE -->|"updates URL"| BR

    %% Styles
    classDef frontend fill:#D0E6F5,stroke:#333,stroke-width:1px
    classDef model fill:#D5E8D4,stroke:#333,stroke-width:1px
    classDef build fill:#E8E8E8,stroke:#333,stroke-width:1px
    classDef data fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef export fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef external fill:#CCCCCC,stroke:#333,stroke-width:1px
    classDef artifact fill:#F8CECC,stroke:#333,stroke-width:1px
```
