You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+112-4Lines changed: 112 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,31 +2,139 @@
2
2
3
3
Next.js app for building Eurorack and VCV Rack patch diagrams with PATCH & TWEAK patch symbols.
4
4
5
-
## What is included
5
+
## Current scope
6
6
7
7
-`91` SVG symbol assets loaded directly from [`public/symbols`](/Users/walmik/Github/pnt/public/symbols)
8
-
- A drag-and-drop patch canvas with pan, zoom, fit-to-content, and grid snapping
8
+
- A drag-and-drop patch canvas with pan, zoom, reset view, fit-to-content, and grid snapping
9
+
- Tool modes for selection, cable patching, and inline text annotations
9
10
- Cable drawing with sound, modulation, gate/trigger, clock, and pitch cable colors
10
11
- IndexedDB-backed local patch library plus JSON import/export
11
-
- A sample patch seeded from the visual example you shared
12
+
- SVG and PNG export
13
+
- A bundled sample patch
12
14
13
15
## Commands
14
16
15
17
```bash
16
18
npm install
17
19
npm run dev
20
+
npm run build
18
21
```
19
22
23
+
## Complexity
24
+
25
+
This is still a relatively small application from an architecture perspective, but most of the behavior is concentrated in [`components/PatchEditor.jsx`](/Users/walmik/Github/pnt/components/PatchEditor.jsx). That file is the main complexity hotspot and the place contributors should read first before making editor changes.
26
+
27
+
## Architecture
28
+
29
+
The app is intentionally simple and mostly client-side:
30
+
31
+
-[`app/page.jsx`](/Users/walmik/Github/pnt/app/page.jsx) is the route entry and renders the editor
32
+
-[`app/layout.jsx`](/Users/walmik/Github/pnt/app/layout.jsx) defines metadata, global CSS, and analytics
33
+
-[`components/PatchEditor.jsx`](/Users/walmik/Github/pnt/components/PatchEditor.jsx) contains the editor state machine, canvas interactions, persistence hooks, export logic, and most UI
34
+
-[`components/SymbolIcon.jsx`](/Users/walmik/Github/pnt/components/SymbolIcon.jsx) renders symbol assets from `public/symbols`
35
+
-[`lib/symbols.js`](/Users/walmik/Github/pnt/lib/symbols.js) is the symbol catalog and filename contract for SVG assets
36
+
-[`lib/patchLibrary.js`](/Users/walmik/Github/pnt/lib/patchLibrary.js) wraps IndexedDB for named local patch storage
37
+
-[`public/symbols`](/Users/walmik/Github/pnt/public/symbols) contains the official PATCH & TWEAK SVG assets used by the UI and export pipeline
38
+
39
+
## How The Editor Works
40
+
41
+
The editor is built around a few core state objects:
42
+
43
+
-`nodes`: placed symbols on the stage
44
+
-`connections`: cables between node ids, each with a signal color/type
45
+
-`view`: camera state with `x`, `y`, and `scale`
46
+
47
+
Each node also stores annotation data:
48
+
49
+
-`note`: a freeform note attached to the symbol itself
50
+
-`portNotes`: optional notes attached to `top`, `right`, `bottom`, and `left` patch points
51
+
52
+
The stage is a large fixed virtual canvas:
53
+
54
+
- node positions are stored in world coordinates
55
+
- panning and zooming only change the camera transform
56
+
- drag/drop, cable creation, marquee selection, export, and note placement all resolve through the same world-coordinate model
57
+
58
+
Connections are constrained by signal type:
59
+
60
+
-`sound` runs horizontally from `right -> left`
61
+
-`modulation`, `gate`, `clock`, and `pitch` run vertically from `top -> bottom`
62
+
63
+
Tool modes are explicit:
64
+
65
+
-`Select` is the normal mode for selecting, marquee, and moving nodes
66
+
- cable color tools activate connection creation for that signal type
67
+
-`Text` lets contributors add notes directly to symbols or patch points
68
+
69
+
## Data model
70
+
71
+
Patch files and stored patches share the same basic structure:
72
+
73
+
```json
74
+
{
75
+
"version": 1,
76
+
"name": "Patch name",
77
+
"nodes": [
78
+
{
79
+
"id": "node-id",
80
+
"symbolId": "low-pass-filter",
81
+
"x": 288,
82
+
"y": 64,
83
+
"note": "optional symbol note",
84
+
"portNotes": {
85
+
"top": "",
86
+
"right": "",
87
+
"bottom": "",
88
+
"left": ""
89
+
}
90
+
}
91
+
],
92
+
"connections": [
93
+
{
94
+
"id": "connection-id",
95
+
"from": "node-a",
96
+
"to": "node-b",
97
+
"color": "sound"
98
+
}
99
+
],
100
+
"view": {
101
+
"x": 0,
102
+
"y": 0,
103
+
"scale": 1
104
+
}
105
+
}
106
+
```
107
+
108
+
## Persistence and export
109
+
110
+
- browser autosave uses `localStorage`
111
+
- named patches are stored in IndexedDB through [`lib/patchLibrary.js`](/Users/walmik/Github/pnt/lib/patchLibrary.js)
112
+
- JSON import/export is kept for portability and backup
113
+
- SVG export builds a standalone document from the current patch state
- if you add or rename a symbol, update [`lib/symbols.js`](/Users/walmik/Github/pnt/lib/symbols.js) and keep the filename in [`public/symbols`](/Users/walmik/Github/pnt/public/symbols) aligned with the symbol id
130
+
- most editor behavior currently lives in one file, [`components/PatchEditor.jsx`](/Users/walmik/Github/pnt/components/PatchEditor.jsx), so changes there should be tested across drag, selection, patching, text mode, save/load, and export
131
+
- the project currently favors straightforward state and local helper functions over deeper abstraction; if the editor keeps growing, a sensible next refactor would be to split canvas math, export logic, and persistence concerns into separate modules
132
+
- because this is a static-exported Next.js app, anything that relies on browser APIs must stay in client components or client-only helpers
26
133
27
134
## Reference
28
135
29
-
The app expects PATCH & TWEAK SVG files to live in [`public/symbols`](/Users/walmik/Github/pnt/public/symbols) using the symbol ids from [`lib/symbols.js`](/Users/walmik/Github/pnt/lib/symbols.js) as filenames.
136
+
- the app expects PATCH & TWEAK SVG files to live in [`public/symbols`](/Users/walmik/Github/pnt/public/symbols) using the symbol ids from [`lib/symbols.js`](/Users/walmik/Github/pnt/lib/symbols.js) as filenames
137
+
- deployment is handled through GitHub Pages via [`.github/workflows/deploy-pages.yml`](/Users/walmik/Github/pnt/.github/workflows/deploy-pages.yml)
0 commit comments