# gustavwilliam/arrow-canvas architecture

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

- Interactive diagram: https://gitdiagram.com/gustavwilliam/arrow-canvas
- Repository: https://github.com/gustavwilliam/arrow-canvas

## Overview

##### Project type and purpose
- This is a single-page, front-end web application built with Vue 3 and Vite.

##### File structure
- Top-level files:
- index.html, main.js, App.vue → entrypoint of the SPA
- package.json, vite.config.js, postcss.config.js, tailwind.config.js → build/config files
- src/
- components/ → UI building blocks (CanvasSquare, TheCanvas, ToolPicker, Dropdown, Menu, TheTilesetDisplay)
- stores/ → Pinia state management (selection.js, state.js)
- public/tilesets/… → static SVG assets used at runtime
- readme-images/ → documentation images

##### Extract insights from the README
- Uses Vue’s reactivity + Pinia for state (selected tool, current canvas selection).
- Built & served by Vite.

##### Main components and interactions (to include
a. User (Browser)
→ interacts with UI components (ToolPicker, Dropdowns, Canvas squares).
b. Vue 3 Application Core
- App.vue / main.js: bootstrap Vue + mount root component.
- Component Tree:
– ToolPicker & Toolbar components
– TheCanvas & CanvasSquare components
– TheTilesetDisplay
– Menu/Dropdown for settings (light/dark)
c. State Layer (Pinia stores)
- selection.js: tracks which canvas square(s) are selected.
- state.js: current tool, mode (light/dark), tileset choice.
d. Utility Layer
e. Static Assets
- public/tilesets: SVG files named by direction pattern.
f. Build/Serve Pipeline
- Vite Dev Server or built static files served by any HTTP server.

Interactions:
1. Browser loads index.html → runs main.js → Vue app initialized.
2. User selects a tool via ToolPicker → Pinia store update.
3. User clicks on CanvasSquare → Pinia store updates selection.
5. TheTilesetDisplay picks the matching SVG from public/tilesets and renders.

##### Architectural patterns & design principles
- Component-based UI (Vue Single File Components).
- Unidirectional data flow: store ← UI events; UI ← store.
- Separation of concerns: UI (components), state (stores), logic (utils), assets (public).
- Build tool/plugin system (Vite + PostCSS + TailwindCSS).

##### Detailed component breakdown (optional sub-components)
- ToolPicker Group → buttons → emits “selectTool”
- Dropdown & Menu → configure mode/tileset
- CanvasSquare → onClick → updates selection store
- TheCanvas → iterates squares, passes geometry data to TheTilesetDisplay
- TheTilesetDisplay → constructs filename using utils, loads SVG

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User (Browser)"]:::external

    subgraph "Build & Serve Pipeline"
        direction TB
        Index["index.html"]:::pipeline
        Main["src/main.js"]:::pipeline
        App["src/App.vue"]:::pipeline
        Vite["vite.config.js"]:::pipeline
        PostCSS["postcss.config.js"]:::pipeline
        Tailwind["tailwind.config.js"]:::pipeline
        Package["package.json"]:::pipeline
    end

    subgraph "Presentation Layer (UI Components)"
        direction TB
        TP["ToolPicker.vue"]:::ui
        TPB["ToolPickerButton.vue"]:::ui
        TPG["ToolPickerGroup.vue"]:::ui
        TPI["ToolPickerItem.vue"]:::ui
        DD["TheDropdown.vue"]:::ui
        DDC["DropdownContent.vue"]:::ui
        DDI["DropdownItem.vue"]:::ui
        TM["TheMenu.vue"]:::ui
        MB["MenuButton.vue"]:::ui
        MG["MenuGroup.vue"]:::ui
        MS["MenuSection.vue"]:::ui
        TC["TheCanvas.vue"]:::ui
        CS["CanvasSquare.vue"]:::ui
        TDSP["TheTilesetDisplay.vue"]:::ui
    end

    subgraph "State Layer (Pinia Stores)"
        direction TB
        Selection["selection.js"]:::state
        AppState["state.js"]:::state
    end

    subgraph "Utility Layer (Geometry Helpers)"
        direction TB
        Point["point.js"]:::util
        Line["line.js"]:::util
        Shape["shape.js"]:::util
        Square["square.js"]:::util
    end

    subgraph "Static Assets (SVG Tilesets)"
        direction TB
        Arrows["public/tilesets/arrows"]:::asset
        Lemoji["public/tilesets/lemoji"]:::asset
        PiniaAssets["public/tilesets/pinia"]:::asset
    end

    User -->|"interacts with"| TP
    User -->|"interacts with"| DD
    User -->|"interacts with"| TM
    User -->|"interacts with"| CS

    Index -->|"runs"| Main
    Main -->|"mounts root"| App
    App -->|"renders"| TP
    App -->|"renders"| DD
    App -->|"renders"| TM
    App -->|"renders"| TC

    TP -->|"selectTool event"| AppState
    CS -->|"click updates"| Selection

    Selection -->|"state change"| TC
    AppState -->|"state change"| TP

    TC -->|"calls geometry"| Point
    TC -->|"calls geometry"| Line
    TC -->|"calls geometry"| Shape
    TC -->|"calls geometry"| Square

    Point -->|"computes code"| TDSP
    Line -->|"computes code"| TDSP
    Shape -->|"computes code"| TDSP
    Square -->|"computes code"| TDSP

    TDSP -->|"loads SVG"| Arrows
    TDSP -->|"loads SVG"| Lemoji
    TDSP -->|"loads SVG"| PiniaAssets

    click Index "https://github.com/gustavwilliam/arrow-canvas/blob/main/index.html"
    click Main "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/main.js"
    click App "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/App.vue"
    click TP "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/ToolPicker/ToolPicker.vue"
    click TPB "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/ToolPicker/ToolPickerButton.vue"
    click TPG "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/ToolPicker/ToolPickerGroup.vue"
    click TPI "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/ToolPicker/ToolPickerItem.vue"
    click DD "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/Dropdown/TheDropdown.vue"
    click DDC "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/Dropdown/DropdownContent.vue"
    click DDI "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/Dropdown/DropdownItem.vue"
    click TM "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/Menu/TheMenu.vue"
    click MB "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/Menu/MenuButton.vue"
    click MG "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/Menu/MenuGroup.vue"
    click MS "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/Menu/MenuSection.vue"
    click TC "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/TheCanvas.vue"
    click CS "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/CanvasSquare.vue"
    click TDSP "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/components/TheTilesetDisplay.vue"
    click Selection "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/stores/selection.js"
    click AppState "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/stores/state.js"
    click Point "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/utils/point.js"
    click Line "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/utils/line.js"
    click Shape "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/utils/shape.js"
    click Square "https://github.com/gustavwilliam/arrow-canvas/blob/main/src/utils/square.js"
    click Arrows "https://github.com/gustavwilliam/arrow-canvas/tree/main/public/tilesets/arrows"
    click Lemoji "https://github.com/gustavwilliam/arrow-canvas/tree/main/public/tilesets/lemoji"
    click PiniaAssets "https://github.com/gustavwilliam/arrow-canvas/tree/main/public/tilesets/pinia"
    click Vite "https://github.com/gustavwilliam/arrow-canvas/blob/main/vite.config.js"
    click PostCSS "https://github.com/gustavwilliam/arrow-canvas/blob/main/postcss.config.js"
    click Tailwind "https://github.com/gustavwilliam/arrow-canvas/blob/main/tailwind.config.js"
    click Package "https://github.com/gustavwilliam/arrow-canvas/blob/main/package.json"

    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef state fill:#DFFFE0,stroke:#2a8f2a,color:#2a8f2a
    classDef util fill:#FFF3BF,stroke:#e09f3e,color:#e09f3e
    classDef asset fill:#F0F0F0,stroke:#888888,color:#444444
    classDef pipeline fill:#FFE4C4,stroke:#c14902,color:#c14902
    classDef external fill:#FFFFFF,stroke:#000000,color:#000000
```
