# dnek/pietron architecture

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

- Interactive diagram: https://gitdiagram.com/dnek/pietron
- Repository: https://github.com/dnek/pietron

## Overview

Pietron is an Electron IDE for editing and debugging Piet programs represented as colored codel grids. The user draws or imports a grid, edits colors and dimensions, and can save it as PNG/BMP; debugging sends the grid and input to the interpreter, then displays execution state and output in the renderer. The graph includes documented editor, file, palette, and debugging capabilities. Some relationships rely on README documentation or IPC channel evidence; unsampled modules are represented only where the tree or documentation supports them.

Main entry points: [`src/canvas.js`](https://github.com/dnek/pietron/blob/master/src/canvas.js) (Codel canvas), [`src/index.js`](https://github.com/dnek/pietron/blob/master/src/index.js) (IDE renderer), [`src/debug.js`](https://github.com/dnek/pietron/blob/master/src/debug.js) (Piet interpreter), [`src/main.js`](https://github.com/dnek/pietron/blob/master/src/main.js) (Electron window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Electron runtime"]
  node_electron["Electron window<br/>[main.js]"]
  node_renderer["IDE renderer<br/>[index.js]"]
  node_menus["Application menus<br/>[menu.js]"]
  node_theme["Theme settings<br/>[theme.js]"]
  node_title["Window title<br/>[title.js]"]
end

subgraph group_editing["Grid editor"]
  node_canvas["Codel canvas<br/>[canvas.js]"]
  node_history["Undo redo<br/>[canvas-history.js]"]
  node_palette["Color palette<br/>[palette.js]"]
  node_imageio["Image file I/O<br/>[file.js]"]
end

subgraph group_debugging["Piet debugging"]
  node_interpreter["Piet interpreter<br/>[debug.js]"]
end

subgraph group_support["Domain and dialogs"]
  node_commands["Piet commands<br/>[piet-commands.js]"]
  node_colors["Piet colors<br/>[piet-colors.js]"]
  node_blocks["Color blocks<br/>[color-block.js]"]
  node_corners["Block corners<br/>[both-corners.js]"]
  node_points["Grid points<br/>[point.js]"]
  node_sizeinput["Size input dialog"]
  node_numberinput["Number input dialog"]
end

node_user(("IDE user"))

node_user -->|"edits and debugs"| node_renderer
node_electron -->|"configures"| node_menus
node_electron -->|"loads"| node_interpreter
node_electron -->|"loads"| node_theme
node_electron -->|"loads"| node_title
node_renderer -->|"invokes"| node_canvas
node_renderer -->|"requests counts"| node_numberinput
node_renderer -->|"sends debug IPC"| node_interpreter
node_interpreter -->|"sends updates"| node_renderer
node_canvas -->|"records edits"| node_history
node_canvas -->|"uses colors"| node_palette
node_canvas -->|"opens and saves"| node_imageio
node_canvas -->|"requests dimensions"| node_sizeinput
node_palette -->|"shows commands"| node_commands
node_palette -->|"shows colors"| node_colors
node_imageio -->|"requests codel size"| node_numberinput
node_interpreter -->|"decodes commands"| node_commands
node_interpreter -->|"builds and traverses"| node_blocks
node_blocks -->|"uses geometry"| node_corners
node_blocks -->|"tracks codels"| node_points
node_corners -->|"stores coordinates"| node_points

click node_electron "https://github.com/dnek/pietron/blob/master/src/main.js"
click node_renderer "https://github.com/dnek/pietron/blob/master/src/index.js"
click node_menus "https://github.com/dnek/pietron/blob/master/src/menu.js"
click node_theme "https://github.com/dnek/pietron/blob/master/src/theme.js"
click node_title "https://github.com/dnek/pietron/blob/master/src/title.js"
click node_canvas "https://github.com/dnek/pietron/blob/master/src/canvas.js"
click node_history "https://github.com/dnek/pietron/blob/master/src/canvas-history.js"
click node_palette "https://github.com/dnek/pietron/blob/master/src/palette.js"
click node_imageio "https://github.com/dnek/pietron/blob/master/src/file.js"
click node_interpreter "https://github.com/dnek/pietron/blob/master/src/debug.js"
click node_commands "https://github.com/dnek/pietron/blob/master/src/piet-commands.js"
click node_colors "https://github.com/dnek/pietron/blob/master/src/piet-colors.js"
click node_blocks "https://github.com/dnek/pietron/blob/master/src/color-block.js"
click node_corners "https://github.com/dnek/pietron/blob/master/src/both-corners.js"
click node_points "https://github.com/dnek/pietron/blob/master/src/point.js"
click node_sizeinput "https://github.com/dnek/pietron/blob/master/src/size-input-dialog.js"
click node_numberinput "https://github.com/dnek/pietron/blob/master/src/number-input-dialog.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_electron,node_renderer,node_menus,node_theme,node_title,node_user toneBlue
class node_canvas,node_history,node_palette,node_imageio toneAmber
class node_interpreter toneMint
class node_commands,node_colors,node_blocks,node_corners,node_points,node_sizeinput,node_numberinput toneRose
```

## Components

### Electron runtime

- [Electron window](https://github.com/dnek/pietron/blob/master/src/main.js): `src/main.js`
- [IDE renderer](https://github.com/dnek/pietron/blob/master/src/index.js): `src/index.js`
- [Application menus](https://github.com/dnek/pietron/blob/master/src/menu.js): `src/menu.js`
- [Theme settings](https://github.com/dnek/pietron/blob/master/src/theme.js): `src/theme.js`
- [Window title](https://github.com/dnek/pietron/blob/master/src/title.js): `src/title.js`

### Grid editor

- [Codel canvas](https://github.com/dnek/pietron/blob/master/src/canvas.js): `src/canvas.js`
- [Undo redo](https://github.com/dnek/pietron/blob/master/src/canvas-history.js): `src/canvas-history.js`
- [Color palette](https://github.com/dnek/pietron/blob/master/src/palette.js): `src/palette.js`
- [Image file I/O](https://github.com/dnek/pietron/blob/master/src/file.js): `src/file.js`

### Piet debugging

- [Piet interpreter](https://github.com/dnek/pietron/blob/master/src/debug.js): `src/debug.js`

### Domain and dialogs

- [Piet commands](https://github.com/dnek/pietron/blob/master/src/piet-commands.js): `src/piet-commands.js`
- [Piet colors](https://github.com/dnek/pietron/blob/master/src/piet-colors.js): `src/piet-colors.js`
- [Color blocks](https://github.com/dnek/pietron/blob/master/src/color-block.js): `src/color-block.js`
- [Block corners](https://github.com/dnek/pietron/blob/master/src/both-corners.js): `src/both-corners.js`
- [Grid points](https://github.com/dnek/pietron/blob/master/src/point.js): `src/point.js`
- [Size input dialog](https://github.com/dnek/pietron/blob/master/src/size-input-dialog.js): `src/size-input-dialog.js`
- [Number input dialog](https://github.com/dnek/pietron/blob/master/src/number-input-dialog.js): `src/number-input-dialog.js`

### Other components

- **IDE user**

## Connections

- IDE user → IDE renderer: edits and debugs (evidence: `README.md`)
- Electron window → Application menus: configures (evidence: `src/main.js`)
- Electron window → Piet interpreter: loads (evidence: `src/main.js`)
- Electron window → Theme settings: loads (evidence: `src/main.js`)
- Electron window → Window title: loads (evidence: `src/main.js`)
- IDE renderer → Codel canvas: invokes (evidence: `src/index.js`)
- IDE renderer → Number input dialog: requests counts (evidence: `src/index.js`)
- IDE renderer → Piet interpreter: sends debug IPC (evidence: `src/index.js`)
- Piet interpreter → IDE renderer: sends updates (evidence: `src/debug.js`)
- Codel canvas → Undo redo: records edits (evidence: `src/canvas.js`)
- Codel canvas → Color palette: uses colors (evidence: `src/canvas.js`)
- Codel canvas → Image file I/O: opens and saves (evidence: `src/canvas.js`)
- Codel canvas → Size input dialog: requests dimensions (evidence: `src/canvas.js`)
- Color palette → Piet commands: shows commands (evidence: `src/palette.js`)
- Color palette → Piet colors: shows colors (evidence: `src/palette.js`)
- Image file I/O → Number input dialog: requests codel size (evidence: `src/file.js`)
- Piet interpreter → Piet commands: decodes commands (evidence: `src/debug.js`)
- Piet interpreter → Color blocks: builds and traverses (evidence: `src/debug.js`)
- Color blocks → Block corners: uses geometry (evidence: `src/color-block.js`)
- Color blocks → Grid points: tracks codels (evidence: `src/color-block.js`)
- Block corners → Grid points: stores coordinates (evidence: `src/both-corners.js`)
