# wanglin2/tiny_whiteboard architecture

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

- Interactive diagram: https://gitdiagram.com/wanglin2/tiny_whiteboard
- Repository: https://github.com/wanglin2/tiny_whiteboard

## Overview

This repository provides a framework-independent canvas whiteboard library and a Vue demo that drives it. The main workflow is to create a whiteboard in a container, translate pointer input into element creation or selection, render the canvas, and export or save its data. The README also documents editing, grouping, grid, history, import/export, and read-only capabilities. Some runtime modules are indexed but not excerpted, so their documented capabilities are included without asserting unverified internal call paths.

Main entry points: [`tiny-whiteboard/src/index.js`](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/index.js) (Whiteboard instance), [`app/src/App.vue`](https://github.com/wanglin2/tiny_whiteboard/blob/main/app/src/App.vue) (Demo interface), [`tiny-whiteboard/src/Elements.js`](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Elements.js) (Element manager), [`tiny-whiteboard/src/Render.js`](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Render.js) (Canvas rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_demo["Vue demo"]
  node_demoapp["Demo interface<br/>[App.vue]"]
  node_context["Context menu<br/>[Contextmenu.vue]"]
end

subgraph group_runtime["Canvas runtime"]
  node_library["Whiteboard instance<br/>[index.js]"]
  node_canvas["Canvas setup<br/>[Canvas.js]"]
  node_events["Pointer events<br/>[Event.js]"]
  node_coordinates["Coordinate mapping<br/>[Coordinate.js]"]
  node_render["Canvas rendering<br/>[Render.js]"]
  node_grid["Grid display<br/>[Grid.js]"]
  node_mode["Edit modes<br/>[Mode.js]"]
  node_hit["Hit testing<br/>[checkHit.js]"]
  node_drawing["Drawing primitives<br/>[draw.js]"]
end

subgraph group_elements["Elements and editing"]
  node_elements["Element manager<br/>[Elements.js]"]
  node_shape["Shape elements<br/>[Rectangle.js]"]
  node_multipoint["Path elements"]
  node_base["Element base<br/>[BaseElement.js]"]
  node_selection["Selection handling<br/>[Selection.js]"]
  node_drag["Transform controls<br/>[DragElement.js]"]
  node_multiselect["Multi-selection"]
  node_grouping["Grouping<br/>[Group.js]"]
  node_textedit["Text editing<br/>[TextEdit.js]"]
  node_imageedit["Image placement<br/>[ImageEdit.js]"]
end

subgraph group_output["State and output"]
  node_history["Undo and redo<br/>[History.js]"]
  node_export["Import and export<br/>[Export.js]"]
  node_background["Background<br/>[Background.js]"]
end

node_user(("Whiteboard user"))

node_user -->|"uses demo"| node_demoapp
node_demoapp -->|"creates instance"| node_library
node_demoapp -->|"renders menu"| node_context
node_context -->|"invokes commands"| node_library
node_library -->|"creates mapper"| node_coordinates
node_library -->|"creates handler"| node_events
node_library -->|"creates renderer"| node_render
node_library -->|"manages elements"| node_elements
node_elements -->|"creates shapes"| node_shape
node_multipoint -->|"extends base"| node_base
node_shape -.->|"extends base"| node_base
node_selection -->|"uses selection proxy"| node_multiselect
node_multiselect -->|"creates controls"| node_drag
node_grouping -->|"groups elements"| node_multiselect
node_elements -.->|"renders elements"| node_render
node_render -->|"uses primitives"| node_drawing
node_selection -->|"tests hits"| node_hit
node_user -.->|"toggles grid"| node_grid
node_user -.->|"switches mode"| node_mode
node_user -.->|"edits text"| node_textedit
node_user -.->|"places images"| node_imageedit
node_library -.->|"supports history"| node_history
node_library -.->|"imports and exports"| node_export
node_library -.->|"supports background"| node_background

click node_demoapp "https://github.com/wanglin2/tiny_whiteboard/blob/main/app/src/App.vue"
click node_context "https://github.com/wanglin2/tiny_whiteboard/blob/main/app/src/components/Contextmenu.vue"
click node_library "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/index.js"
click node_canvas "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Canvas.js"
click node_events "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Event.js"
click node_coordinates "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Coordinate.js"
click node_render "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Render.js"
click node_grid "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Grid.js"
click node_mode "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Mode.js"
click node_elements "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Elements.js"
click node_shape "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/Rectangle.js"
click node_multipoint "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/BaseMultiPointElement.js"
click node_base "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/BaseElement.js"
click node_selection "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Selection.js"
click node_drag "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/DragElement.js"
click node_multiselect "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/MultiSelectElement.js"
click node_grouping "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Group.js"
click node_textedit "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/TextEdit.js"
click node_imageedit "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/ImageEdit.js"
click node_history "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/History.js"
click node_export "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Export.js"
click node_background "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Background.js"
click node_hit "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/utils/checkHit.js"
click node_drawing "https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/utils/draw.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_demoapp,node_context,node_user toneBlue
class node_library,node_canvas,node_events,node_coordinates,node_render,node_grid,node_mode,node_hit,node_drawing toneAmber
class node_elements,node_shape,node_multipoint,node_base,node_selection,node_drag,node_multiselect,node_grouping,node_textedit,node_imageedit toneMint
class node_history,node_export,node_background toneRose
```

## Components

### Vue demo

- [Demo interface](https://github.com/wanglin2/tiny_whiteboard/blob/main/app/src/App.vue): `app/src/App.vue`
- [Context menu](https://github.com/wanglin2/tiny_whiteboard/blob/main/app/src/components/Contextmenu.vue): `app/src/components/Contextmenu.vue`

### Canvas runtime

- [Whiteboard instance](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/index.js): `tiny-whiteboard/src/index.js`
- [Canvas setup](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Canvas.js): `tiny-whiteboard/src/Canvas.js`
- [Pointer events](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Event.js): `tiny-whiteboard/src/Event.js`
- [Coordinate mapping](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Coordinate.js): `tiny-whiteboard/src/Coordinate.js`
- [Canvas rendering](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Render.js): `tiny-whiteboard/src/Render.js`
- [Grid display](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Grid.js): `tiny-whiteboard/src/Grid.js`
- [Edit modes](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Mode.js): `tiny-whiteboard/src/Mode.js`
- [Hit testing](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/utils/checkHit.js): `tiny-whiteboard/src/utils/checkHit.js`
- [Drawing primitives](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/utils/draw.js): `tiny-whiteboard/src/utils/draw.js`

### Elements and editing

- [Element manager](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Elements.js): `tiny-whiteboard/src/Elements.js`
- [Shape elements](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/Rectangle.js): `tiny-whiteboard/src/elements/Rectangle.js`
- [Path elements](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/BaseMultiPointElement.js): `tiny-whiteboard/src/elements/BaseMultiPointElement.js`
- [Element base](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/BaseElement.js): `tiny-whiteboard/src/elements/BaseElement.js`
- [Selection handling](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Selection.js): `tiny-whiteboard/src/Selection.js`
- [Transform controls](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/DragElement.js): `tiny-whiteboard/src/elements/DragElement.js`
- [Multi-selection](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/elements/MultiSelectElement.js): `tiny-whiteboard/src/elements/MultiSelectElement.js`
- [Grouping](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Group.js): `tiny-whiteboard/src/Group.js`
- [Text editing](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/TextEdit.js): `tiny-whiteboard/src/TextEdit.js`
- [Image placement](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/ImageEdit.js): `tiny-whiteboard/src/ImageEdit.js`

### State and output

- [Undo and redo](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/History.js): `tiny-whiteboard/src/History.js`
- [Import and export](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Export.js): `tiny-whiteboard/src/Export.js`
- [Background](https://github.com/wanglin2/tiny_whiteboard/blob/main/tiny-whiteboard/src/Background.js): `tiny-whiteboard/src/Background.js`

### Other components

- **Whiteboard user**

## Connections

- Whiteboard user → Demo interface: uses demo
- Demo interface → Whiteboard instance: creates instance (evidence: `app/src/App.vue`)
- Demo interface → Context menu: renders menu (evidence: `app/src/App.vue`)
- Context menu → Whiteboard instance: invokes commands (evidence: `app/src/components/Contextmenu.vue`)
- Whiteboard instance → Coordinate mapping: creates mapper (evidence: `tiny-whiteboard/src/index.js`)
- Whiteboard instance → Pointer events: creates handler (evidence: `tiny-whiteboard/src/index.js`)
- Whiteboard instance → Canvas rendering: creates renderer (evidence: `tiny-whiteboard/src/index.js`)
- Whiteboard instance → Element manager: manages elements (evidence: `tiny-whiteboard/src/Elements.js`)
- Element manager → Shape elements: creates shapes (evidence: `tiny-whiteboard/src/Elements.js`)
- Path elements → Element base: extends base (evidence: `tiny-whiteboard/src/elements/BaseMultiPointElement.js`)
- Shape elements → Element base: extends base (evidence: `tiny-whiteboard/src/elements/Rectangle.js`)
- Selection handling → Multi-selection: uses selection proxy (evidence: `tiny-whiteboard/src/Selection.js`)
- Multi-selection → Transform controls: creates controls (evidence: `tiny-whiteboard/src/elements/MultiSelectElement.js`)
- Grouping → Multi-selection: groups elements (evidence: `tiny-whiteboard/src/Group.js`)
- Element manager → Canvas rendering: renders elements
- Canvas rendering → Drawing primitives: uses primitives (evidence: `tiny-whiteboard/src/Render.js`)
- Selection handling → Hit testing: tests hits (evidence: `tiny-whiteboard/src/Selection.js`)
- Whiteboard user → Grid display: toggles grid
- Whiteboard user → Edit modes: switches mode
- Whiteboard user → Text editing: edits text
- Whiteboard user → Image placement: places images
- Whiteboard instance → Undo and redo: supports history (evidence: `tiny-whiteboard/src/index.js`)
- Whiteboard instance → Import and export: imports and exports (evidence: `tiny-whiteboard/src/index.js`)
- Whiteboard instance → Background: supports background (evidence: `tiny-whiteboard/src/index.js`)
