# bbrizly/inventory_system architecture

> Architecture diagram of the GitHub repository bbrizly/inventory_system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bbrizly/inventory_system
- Repository: https://github.com/bbrizly/inventory_system

## Overview

##### Project type & purpose (from README + tree)
This is a **desktop GUI application**: a **Java + JavaFX** “Functional Inventory manager” with **saving features** and **error checks**. It’s built with **Maven** and uses **FXML** for the UI layout.

- **UI layer (JavaFX/FXML)**
- **Controller layer (event handling, validation/error checks)**
- **Domain/model layer (inventory + items)**

##### User
- Interacts with the UI (mouse/keyboard)

##### JavaFX Runtime / Application
- Represents the platform runtime (Stage/Scene event loop)

##### InventorySystem (App Entry Point)
- Starts the app, loads FXML, initializes primary stage

##### FXML View: `inventoryScreen.fxml`
- UI layout: forms, buttons, table/list, etc.

##### Controller: `InventoryScreenController`
- Handles events, binds UI state, triggers operations

##### Domain Model
- `Inventory` (collection/operations: add/remove/update/search)
- `Item` (data structure: id/name/qty/etc.)

##### Persistence / Saving subsystem
- e.g., **File Storage** (CSV/JSON/serialized) or **Local DB** (if used)
- “Load on startup” and “Save on change/on exit” flows

##### Error Checking / Validation
- A labeled responsibility in the controller/model, or
- A separate “Validation” component if code shows clear separation

Since you want “as many components as possible” without overthinking, split further if it reflects reality:
- **UI Widgets**: TableView/ListView, forms, dialogs/alerts (as subcomponents inside View)
- **JavaFX Binding/Observable layer**: ObservableList / property bindings (common in JavaFX)
- **Serialization format**: “Inventory File (JSON/CSV/…)” as its own artifact node
- **Configuration/module boundary**: `module-info.java` as “Module boundaries / exports” note

##### Controller → initializes UI bindings and data model
5. Controller → Persistence → **loads saved inventory** → returns `Inventory/Items` → Controller updates UI

##### Runtime user operations
- User → View (button click / text input)
- View → Controller (event handler method)
- Controller → Validation/Error Checks (validate user input)
- If valid:
- Controller → `Inventory` (add/remove/update/search)
- `Inventory` → `Item` (creates/updates)
- Controller → View (refresh TableView / show updated list)
- Controller → Persistence (save changes)
- If invalid:
- Controller → View (show Alert/Dialog with error)

##### Save/load flow
- Controller ↔ Persistence ↔ File (or storage artifact)
- “serialize inventory”
- “deserialize inventory”
- “write file”
- “read file”

Call these out as notes or stereotypes on components:

- **MVC/MVVM-ish JavaFX**: FXML View + Controller + Model
- **Separation of concerns**:
- UI layout in FXML
- Event logic in Controller
- Domain operations in Inventory/Item
- **Local-first persistence**: saving to local storage (assumed from README)
- **Module system** (`module-info.java`): ensures JavaFX modules are required and packages exported/opened for FXML reflection

##### Technology labels (important
Small tags on components:
- “Java 17+ (or project’s Java version)” (check `pom.xml` when drawing final)
- “JavaFX”
- “FXML”
- “Maven build”
- “Java Module System”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External actors/artifacts
    User["User"]:::external
    LocalFS[("Local File System")]:::external
    SaveFile["Inventory Save File\n(JSON/CSV/Serialized)"]:::storage

    %% Build/Config (non-runtime but important)
    subgraph "Build & Module Configuration"
        Pom["Maven Build (pom.xml)"]:::build
        ModuleInfo["Java Module Declaration (module-info.java)\nrequires javafx.* / opens for FXML"]:::build
    end

    %% Runtime container
    subgraph "JavaFX Desktop Application (Single-Node)"
        JFX["JavaFX Runtime\n(Stage/Scene Event Loop)"]:::runtime

        subgraph "Bootstrap / Composition Root"
            App["InventorySystem\n(JavaFX Application Entry Point)\nBootstraps Stage + loads FXML"]:::bootstrap
        end

        subgraph "UI Layer (FXML / JavaFX)"
            FXML["inventoryScreen.fxml\n(View Layout: forms/buttons/table)"]:::view
            Widgets["UI Widgets\n(TableView/ListView, Inputs, Alerts)"]:::view
        end

        subgraph "Controller Layer"
            Controller["InventoryScreenController\n(Event Handlers + UI Updates)"]:::controller
            Validation["Validation & Error Checks\n(input validation, constraints)"]:::controller
            Alerts["Alert/Dialog Presenter\n(user-facing errors)"]:::controller
        end

        subgraph "Domain Model Layer"
            Inventory["Inventory\n(collection + CRUD/search operations)"]:::model
            Item["Item\n(data fields: id/name/qty/...)"]:::model
        end

        subgraph "Persistence / Saving Subsystem"
            Persistence["Persistence Adapter\n(serialize/deserialize inventory)"]:::persistence
        end
    end

    %% Context interactions
    User -->|"mouse/keyboard input"| JFX
    JFX -->|"dispatch UI events"| Controller

    %% Startup flow
    App -->|"load FXML (FXMLLoader)"| FXML
    FXML -->|"instantiate/wire controller"| Controller
    Controller -->|"initialize UI + bindings"| Widgets
    Controller -->|"load on startup"| Persistence
    Persistence -->|"read file"| LocalFS
    LocalFS -->|"open"| SaveFile
    SaveFile -->|"deserialize inventory/items"| Persistence
    Persistence -->|"return Inventory data"| Controller
    Controller -->|"populate table/list"| Widgets

    %% Runtime CRUD flow
    User -->|"click/type"| Widgets
    Widgets -->|"action event"| Controller
    Controller -->|"validate input"| Validation
    Validation -->|"invalid -> error details"| Alerts
    Alerts -->|"show alert/dialog"| Widgets

    Validation -->|"valid"| Controller
    Controller -->|"add/remove/update/search"| Inventory
    Inventory -->|"create/update"| Item
    Controller -.->|"refresh/bind UI state"| Widgets

    %% Save flow
    Controller -->|"save on change/on exit"| Persistence
    Persistence -->|"serialize inventory"| SaveFile
    SaveFile -->|"write file"| LocalFS

    %% Build/module relationships (conceptual)
    Pom -->|"builds/packages"| App
    ModuleInfo -->|"enables JavaFX modules + FXML reflection"| App
    ModuleInfo -->|"opens/exports for FXML controller access"| Controller

    %% Click events (mapped components)
    click App "https://github.com/bbrizly/inventory_system/blob/master/src/main/java/com/example/inventorybonus/InventorySystem.java"
    click FXML "https://github.com/bbrizly/inventory_system/blob/master/src/main/resources/com/example/inventorybonus/inventoryScreen.fxml"
    click Controller "https://github.com/bbrizly/inventory_system/blob/master/src/main/java/com/example/inventorybonus/InventoryScreenController.java"
    click Inventory "https://github.com/bbrizly/inventory_system/blob/master/src/main/java/com/example/inventorybonus/Inventory.java"
    click Item "https://github.com/bbrizly/inventory_system/blob/master/src/main/java/com/example/inventorybonus/Item.java"
    click ModuleInfo "https://github.com/bbrizly/inventory_system/blob/master/src/main/java/module-info.java"
    click Pom "https://github.com/bbrizly/inventory_system/blob/master/pom.xml"

    %% Styles
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#263238,stroke-width:1px
    classDef storage fill:#EDE7F6,stroke:#5E35B1,color:#311B92,stroke-width:1px
    classDef build fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C,stroke-width:1px
    classDef runtime fill:#E0E0E0,stroke:#424242,color:#212121,stroke-width:1px
    classDef bootstrap fill:#E1F5FE,stroke:#0277BD,color:#01579B,stroke-width:1px
    classDef view fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1,stroke-width:1px
    classDef controller fill:#FFE0B2,stroke:#FB8C00,color:#E65100,stroke-width:1px
    classDef model fill:#C8E6C9,stroke:#43A047,color:#1B5E20,stroke-width:1px
    classDef persistence fill:#D1C4E9,stroke:#673AB7,color:#311B92,stroke-width:1px
```
