# keepo-dot/skein architecture

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

- Interactive diagram: https://gitdiagram.com/keepo-dot/skein
- Repository: https://github.com/keepo-dot/skein

## Overview

Skein is a native GTK4 knitting-chart editor. Users choose tools and colors or stitch symbols, edit a layered grid with navigation and repeat markers, then save or load .skn patterns; undo/redo tracks edits. The README also documents vector rendering, viewport culling, and contrast-aware symbols. The canvas and file workflows are visible in sampled source; window utilities and other utility behavior are represented from documented responsibilities and declared interfaces, so uncertain call wiring is omitted.

Main entry points: [`src/toolbar.c`](https://github.com/keepo-dot/skein/blob/main/src/toolbar.c) (Tools and palettes), [`src/skein.c`](https://github.com/keepo-dot/skein/blob/main/src/skein.c) (Application startup), [`src/canvas.c`](https://github.com/keepo-dot/skein/blob/main/src/canvas.c) (Grid editing and history), [`include/types.h`](https://github.com/keepo-dot/skein/blob/main/include/types.h) (Chart state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application shell"]
  node_entry["Application startup<br/>[skein.c]"]
  node_window["Window and shortcuts<br/>[skein_window.c]"]
end

subgraph group_editing["Chart editing"]
  node_toolbar["Tools and palettes<br/>[toolbar.c]"]
  node_canvas["Grid editing and history<br/>[canvas.c]"]
  node_pattern["Chart state<br/>[types.h]"]
end

subgraph group_persistence["Pattern files"]
  node_fileio["JSON serialization<br/>[file_io.c]"]
  node_file["SKN pattern file"]
end

subgraph group_shared["Shared presentation"]
  node_resources["Tool and color definitions<br/>[resources.c]"]
  node_utils["Dialogs and drawing helpers<br/>[utils.c]"]
end

node_user(("Desktop user"))
node_gtk["GTK4 desktop UI"]

node_user -->|"uses"| node_gtk
node_gtk -->|"launches"| node_entry
node_entry -->|"creates"| node_toolbar
node_entry -->|"creates"| node_canvas
node_entry -->|"assembles"| node_window
node_entry -->|"initializes"| node_pattern
node_window -->|"builds window"| node_gtk
node_toolbar -->|"reads definitions"| node_resources
node_toolbar -->|"uses helpers"| node_utils
node_toolbar -->|"selects tools"| node_canvas
node_canvas -->|"edits and renders"| node_pattern
node_canvas -->|"draws repeats"| node_utils
node_toolbar -->|"opens file dialogs"| node_utils
node_toolbar -->|"serializes or loads"| node_fileio
node_fileio -->|"reads and writes"| node_pattern
node_fileio -->|"reads or writes"| node_file
node_canvas -->|"tracks undo and redo"| node_pattern

click node_entry "https://github.com/keepo-dot/skein/blob/main/src/skein.c"
click node_window "https://github.com/keepo-dot/skein/blob/main/src/skein_window.c"
click node_toolbar "https://github.com/keepo-dot/skein/blob/main/src/toolbar.c"
click node_canvas "https://github.com/keepo-dot/skein/blob/main/src/canvas.c"
click node_pattern "https://github.com/keepo-dot/skein/blob/main/include/types.h"
click node_resources "https://github.com/keepo-dot/skein/blob/main/src/resources.c"
click node_utils "https://github.com/keepo-dot/skein/blob/main/src/utils.c"
click node_fileio "https://github.com/keepo-dot/skein/blob/main/src/file_io.c"

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_entry,node_window,node_user,node_gtk toneBlue
class node_toolbar,node_canvas,node_pattern toneAmber
class node_fileio,node_file toneMint
class node_resources,node_utils toneRose
```

## Components

### Application shell

- [Application startup](https://github.com/keepo-dot/skein/blob/main/src/skein.c): `src/skein.c`
- [Window and shortcuts](https://github.com/keepo-dot/skein/blob/main/src/skein_window.c): `src/skein_window.c`

### Chart editing

- [Tools and palettes](https://github.com/keepo-dot/skein/blob/main/src/toolbar.c): `src/toolbar.c`
- [Grid editing and history](https://github.com/keepo-dot/skein/blob/main/src/canvas.c): `src/canvas.c`
- [Chart state](https://github.com/keepo-dot/skein/blob/main/include/types.h): `include/types.h`

### Pattern files

- [JSON serialization](https://github.com/keepo-dot/skein/blob/main/src/file_io.c): `src/file_io.c`
- **SKN pattern file**

### Shared presentation

- [Tool and color definitions](https://github.com/keepo-dot/skein/blob/main/src/resources.c): `src/resources.c`
- [Dialogs and drawing helpers](https://github.com/keepo-dot/skein/blob/main/src/utils.c): `src/utils.c`

### Other components

- **Desktop user**
- **GTK4 desktop UI**

## Connections

- Desktop user → GTK4 desktop UI: uses
- GTK4 desktop UI → Application startup: launches
- Application startup → Tools and palettes: creates
- Application startup → Grid editing and history: creates
- Application startup → Window and shortcuts: assembles
- Application startup → Chart state: initializes
- Window and shortcuts → GTK4 desktop UI: builds window
- Tools and palettes → Tool and color definitions: reads definitions
- Tools and palettes → Dialogs and drawing helpers: uses helpers
- Tools and palettes → Grid editing and history: selects tools
- Grid editing and history → Chart state: edits and renders
- Grid editing and history → Dialogs and drawing helpers: draws repeats
- Tools and palettes → Dialogs and drawing helpers: opens file dialogs
- Tools and palettes → JSON serialization: serializes or loads
- JSON serialization → Chart state: reads and writes
- JSON serialization → SKN pattern file: reads or writes
- Grid editing and history → Chart state: tracks undo and redo
