# citromoseper/whiteboard architecture

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

- Interactive diagram: https://gitdiagram.com/citromoseper/whiteboard
- Repository: https://github.com/citromoseper/whiteboard

## Overview

Whiteboard is a browser-based drawing and collaboration app. Users create and edit a board, then save, export, share, or collaborate on it; optional AI actions interpret selected handwriting, while plotting and answer checking run locally. The graph preserves the documented drawing, sheets/PDF, sticker/gallery, localization, offline, and sharing capabilities. Several module-to-module calls were not shown in the excerpts, so those connections are omitted or marked unverified rather than asserted.

Main entry points: [`js/app.js`](https://github.com/citromoseper/whiteboard/blob/main/js/app.js) (Canvas and UI), [`js/plot.js`](https://github.com/citromoseper/whiteboard/blob/main/js/plot.js) (Graph objects), [`js/ai.js`](https://github.com/citromoseper/whiteboard/blob/main/js/ai.js) (AI actions), [`js/gallery.js`](https://github.com/citromoseper/whiteboard/blob/main/js/gallery.js) (Gallery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_board["Board editing"]
  node_app["Canvas and UI<br/>[app.js]"]
  node_geometry["Stroke geometry<br/>[geometry.js]"]
  node_fill["Shape filling<br/>[fill.js]"]
  node_picker["Color picker<br/>[picker.js]"]
end

subgraph group_math["Math and AI"]
  node_plot["Graph objects<br/>[plot.js]"]
  node_math_expr["Math engine<br/>[mathexpr.js]"]
  node_math_type["Math typesetting<br/>[mathtype.js]"]
  node_ai["AI actions<br/>[ai.js]"]
end

subgraph group_files["Files and sharing"]
  node_io["Board formats<br/>[io.js]"]
  node_pdf["PDF import<br/>[pdf.js]"]
  node_gallery["Gallery<br/>[gallery.js]"]
  node_builtins["Built-in stickers<br/>[builtins.js]"]
  node_share["Share links<br/>[share.js]"]
  node_qr["QR sharing<br/>[qr.js]"]
end

subgraph group_collab["Collaboration and runtime"]
  node_live["Live boards<br/>[live.js]"]
  node_p2p["Peer connection<br/>[p2p.js]"]
  node_i18n["Translations<br/>[i18n.js]"]
  node_offline["Offline cache<br/>[sw.js]"]
end

node_user(("Board user"))
node_provider["AI provider"]

node_user -->|"edits board"| node_app
node_app -.->|"draws strokes"| node_geometry
node_app -.->|"fills shapes"| node_fill
node_app -.->|"chooses colors"| node_picker
node_app -.->|"invokes AI actions"| node_ai
node_ai -->|"sends selected image"| node_provider
node_app -.->|"typesets math"| node_math_type
node_app -.->|"creates and explores"| node_plot
node_plot -.->|"evaluates functions"| node_math_expr
node_app -.->|"checks solutions"| node_math_expr
node_app -.->|"imports and exports"| node_io
node_app -.->|"opens PDF sheets"| node_pdf
node_app -.->|"manages boards"| node_gallery
node_gallery -.->|"offers stickers"| node_builtins
node_app -.->|"creates share links"| node_share
node_app -.->|"shows QR codes"| node_qr
node_app -.->|"collaborates live"| node_live
node_live -.->|"uses peer transport"| node_p2p
node_app -.->|"localizes interface"| node_i18n
node_offline -->|"serves cached app"| node_app

click node_app "https://github.com/citromoseper/whiteboard/blob/main/js/app.js"
click node_geometry "https://github.com/citromoseper/whiteboard/blob/main/js/geometry.js"
click node_fill "https://github.com/citromoseper/whiteboard/blob/main/js/fill.js"
click node_picker "https://github.com/citromoseper/whiteboard/blob/main/js/picker.js"
click node_plot "https://github.com/citromoseper/whiteboard/blob/main/js/plot.js"
click node_math_expr "https://github.com/citromoseper/whiteboard/blob/main/js/mathexpr.js"
click node_math_type "https://github.com/citromoseper/whiteboard/blob/main/js/mathtype.js"
click node_ai "https://github.com/citromoseper/whiteboard/blob/main/js/ai.js"
click node_io "https://github.com/citromoseper/whiteboard/blob/main/js/io.js"
click node_pdf "https://github.com/citromoseper/whiteboard/blob/main/js/pdf.js"
click node_gallery "https://github.com/citromoseper/whiteboard/blob/main/js/gallery.js"
click node_builtins "https://github.com/citromoseper/whiteboard/blob/main/js/builtins.js"
click node_share "https://github.com/citromoseper/whiteboard/blob/main/js/share.js"
click node_qr "https://github.com/citromoseper/whiteboard/blob/main/js/qr.js"
click node_live "https://github.com/citromoseper/whiteboard/blob/main/js/live.js"
click node_p2p "https://github.com/citromoseper/whiteboard/blob/main/js/p2p.js"
click node_i18n "https://github.com/citromoseper/whiteboard/blob/main/js/i18n.js"
click node_offline "https://github.com/citromoseper/whiteboard/blob/main/sw.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_app,node_geometry,node_fill,node_picker,node_user toneBlue
class node_plot,node_math_expr,node_math_type,node_ai toneAmber
class node_io,node_pdf,node_gallery,node_builtins,node_share,node_qr toneMint
class node_live,node_p2p,node_i18n,node_offline toneRose
class node_provider toneIndigo
```

## Components

### Board editing

- [Canvas and UI](https://github.com/citromoseper/whiteboard/blob/main/js/app.js): `js/app.js`
- [Stroke geometry](https://github.com/citromoseper/whiteboard/blob/main/js/geometry.js): `js/geometry.js`
- [Shape filling](https://github.com/citromoseper/whiteboard/blob/main/js/fill.js): `js/fill.js`
- [Color picker](https://github.com/citromoseper/whiteboard/blob/main/js/picker.js): `js/picker.js`

### Math and AI

- [Graph objects](https://github.com/citromoseper/whiteboard/blob/main/js/plot.js): `js/plot.js`
- [Math engine](https://github.com/citromoseper/whiteboard/blob/main/js/mathexpr.js): `js/mathexpr.js`
- [Math typesetting](https://github.com/citromoseper/whiteboard/blob/main/js/mathtype.js): `js/mathtype.js`
- [AI actions](https://github.com/citromoseper/whiteboard/blob/main/js/ai.js): `js/ai.js`

### Files and sharing

- [Board formats](https://github.com/citromoseper/whiteboard/blob/main/js/io.js): `js/io.js`
- [PDF import](https://github.com/citromoseper/whiteboard/blob/main/js/pdf.js): `js/pdf.js`
- [Gallery](https://github.com/citromoseper/whiteboard/blob/main/js/gallery.js): `js/gallery.js`
- [Built-in stickers](https://github.com/citromoseper/whiteboard/blob/main/js/builtins.js): `js/builtins.js`
- [Share links](https://github.com/citromoseper/whiteboard/blob/main/js/share.js): `js/share.js`
- [QR sharing](https://github.com/citromoseper/whiteboard/blob/main/js/qr.js): `js/qr.js`

### Collaboration and runtime

- [Live boards](https://github.com/citromoseper/whiteboard/blob/main/js/live.js): `js/live.js`
- [Peer connection](https://github.com/citromoseper/whiteboard/blob/main/js/p2p.js): `js/p2p.js`
- [Translations](https://github.com/citromoseper/whiteboard/blob/main/js/i18n.js): `js/i18n.js`
- [Offline cache](https://github.com/citromoseper/whiteboard/blob/main/sw.js): `sw.js`

### Other components

- **Board user**
- **AI provider**

## Connections

- Board user → Canvas and UI: edits board (evidence: `README.md`)
- Canvas and UI → Stroke geometry: draws strokes
- Canvas and UI → Shape filling: fills shapes
- Canvas and UI → Color picker: chooses colors
- Canvas and UI → AI actions: invokes AI actions
- AI actions → AI provider: sends selected image (evidence: `README.md`)
- Canvas and UI → Math typesetting: typesets math
- Canvas and UI → Graph objects: creates and explores
- Graph objects → Math engine: evaluates functions
- Canvas and UI → Math engine: checks solutions
- Canvas and UI → Board formats: imports and exports
- Canvas and UI → PDF import: opens PDF sheets
- Canvas and UI → Gallery: manages boards
- Gallery → Built-in stickers: offers stickers
- Canvas and UI → Share links: creates share links
- Canvas and UI → QR sharing: shows QR codes
- Canvas and UI → Live boards: collaborates live
- Live boards → Peer connection: uses peer transport
- Canvas and UI → Translations: localizes interface
- Offline cache → Canvas and UI: serves cached app (evidence: `sw.js`)
