# butlerx/invbeertory architecture

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

- Interactive diagram: https://gitdiagram.com/butlerx/invbeertory
- Repository: https://github.com/butlerx/invbeertory

## Overview

##### Main Components

a) Frontend Layer (Browser):
- WASM module as the core component
- Static assets (HTML, CSS, WebManifest)
- JavaScript interop (xkcd.js)

b) Application Core:
- Components Module
- Pages Module
- Storage Module
- Formatting Module

##### Component Relationships

a) Data Flow:
- CSV Data → Storage Module → Components
- User Interactions → Pages → Components → Charts
- Formatting Module → Components (for styling and presentation)

b) Key Architectural Elements:
- Use a hexagonal architecture representation showing:
- Frontend (Browser/WASM) as the primary interface
- Core business logic (Storage, Components)
- Data source (CSV file)

##### Specific Implementation Details

a) Chart Components:
- Chart types (Bar, Line, Pie, Radar, Stacked Bar, XY)
- Their relationship with the bindings.rs interface

b) Page Structure:
- Routing system connecting:
- Home
- Beer
- Graphs
- History
- Stock
- Not Found

##### Technical Stack Highlights

A stack section showing:
- Rust/WASM as the primary technology
- Trunk for building and serving
- Yew framework for UI components
- WebAssembly binding layer

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Browser
        WASM[WASM Module]:::wasm
        StaticAssets["Static Assets"]:::static
        JS["JavaScript Interop"]:::js
    end

    subgraph Core["Application Core"]
        direction TB
        Components["Components Module"]:::core
        Pages["Pages Module"]:::core
        Storage["Storage Module"]:::core
        Formatting["Formatting Module"]:::core
    end

    subgraph Charts["Chart Components"]
        direction TB
        Bindings["Chart Bindings"]:::chart
        Bar["Bar Chart"]:::chart
        Line["Line Chart"]:::chart
        Pie["Pie Chart"]:::chart
        Radar["Radar Chart"]:::chart
        StackedBar["Stacked Bar"]:::chart
        XY["XY Chart"]:::chart
    end

    subgraph Pages["Page Structure"]
        direction TB
        Home["Home"]:::page
        Beer["Beer"]:::page
        Graphs["Graphs"]:::page
        History["History"]:::page
        Stock["Stock"]:::page
        NotFound["Not Found"]:::page
    end

    subgraph Data
        CSV["CSV Data"]:::data
    end

    %% Relationships
    CSV --> Storage
    Storage --> Components
    Components --> Charts
    Formatting --> Components
    JS --> Charts
    WASM --> Components
    Components --> Pages

    %% Legend
    classDef wasm fill:#4299e1,stroke:#2b6cb0,stroke-width:2px
    classDef static fill:#48bb78,stroke:#2f855a,stroke-width:2px
    classDef js fill:#ecc94b,stroke:#d69e2e,stroke-width:2px
    classDef core fill:#4299e1,stroke:#2b6cb0,stroke-width:2px
    classDef chart fill:#9f7aea,stroke:#6b46c1,stroke-width:2px
    classDef page fill:#ed64a6,stroke:#d53f8c,stroke-width:2px
    classDef data fill:#f6ad55,stroke:#dd6b20,stroke-width:2px

    %% Click Events
    click CSV "https://github.com/butlerx/invbeertory/blob/main/inventory.csv"
    click JS "https://github.com/butlerx/invbeertory/blob/main/src/components/charts/xkcd.js"
    click Components "https://github.com/butlerx/invbeertory/blob/main/src/components/mod.rs"
    click Bindings "https://github.com/butlerx/invbeertory/blob/main/src/components/charts/bindings.rs"
    click Bar "https://github.com/butlerx/invbeertory/blob/main/src/components/charts/bar.rs"
    click Line "https://github.com/butlerx/invbeertory/blob/main/src/components/charts/line.rs"
    click Pie "https://github.com/butlerx/invbeertory/blob/main/src/components/charts/pie.rs"
    click Radar "https://github.com/butlerx/invbeertory/blob/main/src/components/charts/radar.rs"
    click StackedBar "https://github.com/butlerx/invbeertory/blob/main/src/components/charts/stacked_bar.rs"
    click XY "https://github.com/butlerx/invbeertory/blob/main/src/components/charts/xy.rs"
    click Home "https://github.com/butlerx/invbeertory/blob/main/src/pages/home.rs"
    click Beer "https://github.com/butlerx/invbeertory/blob/main/src/pages/beer.rs"
    click Graphs "https://github.com/butlerx/invbeertory/blob/main/src/pages/graphs.rs"
    click History "https://github.com/butlerx/invbeertory/blob/main/src/pages/history.rs"
    click Stock "https://github.com/butlerx/invbeertory/blob/main/src/pages/stock.rs"
    click NotFound "https://github.com/butlerx/invbeertory/blob/main/src/pages/not_found.rs"
    click Storage "https://github.com/butlerx/invbeertory/blob/main/src/storage/mod.rs"
    click Formatting "https://github.com/butlerx/invbeertory/blob/main/src/formatting/mod.rs"
    click StaticAssets "https://github.com/butlerx/invbeertory/tree/main/styles"
    click WASM "https://github.com/butlerx/invbeertory/blob/main/src/main.rs"
```
