@itsthecsguy/linework 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +11 -0
  3. package/README.md +206 -2
  4. package/assets/drawio/LICENSE +201 -0
  5. package/assets/drawio/VERSION +1 -0
  6. package/assets/drawio/favicon.ico +0 -0
  7. package/assets/drawio/images/1x1.png +0 -0
  8. package/assets/drawio/images/2x2.png +0 -0
  9. package/assets/drawio/images/3x3.png +0 -0
  10. package/assets/drawio/images/ajax-loader.gif +0 -0
  11. package/assets/drawio/images/android-chrome-512x512.png +0 -0
  12. package/assets/drawio/images/apple-touch-icon.png +0 -0
  13. package/assets/drawio/images/aui-wait.gif +0 -0
  14. package/assets/drawio/images/broken.png +0 -0
  15. package/assets/drawio/images/browserconfig.xml +9 -0
  16. package/assets/drawio/images/close.png +0 -0
  17. package/assets/drawio/images/cloud-connector-atlas.png +0 -0
  18. package/assets/drawio/images/collapsed.gif +0 -0
  19. package/assets/drawio/images/delete.png +0 -0
  20. package/assets/drawio/images/document-google-drive-icon-80.png +0 -0
  21. package/assets/drawio/images/draw-search.png +0 -0
  22. package/assets/drawio/images/drawio.svg +19 -0
  23. package/assets/drawio/images/drawlogo-color.svg +50 -0
  24. package/assets/drawio/images/drawlogo-gray.svg +18 -0
  25. package/assets/drawio/images/drawlogo-text-bottom.svg +75 -0
  26. package/assets/drawio/images/drawlogo.svg +18 -0
  27. package/assets/drawio/images/drawlogo128.png +0 -0
  28. package/assets/drawio/images/drawlogo144.png +0 -0
  29. package/assets/drawio/images/drawlogo256.png +0 -0
  30. package/assets/drawio/images/drawlogo48-gray.png +0 -0
  31. package/assets/drawio/images/drawlogo48.png +0 -0
  32. package/assets/drawio/images/drawlogo80.png +0 -0
  33. package/assets/drawio/images/droptarget.png +0 -0
  34. package/assets/drawio/images/edit.gif +0 -0
  35. package/assets/drawio/images/edit16.png +0 -0
  36. package/assets/drawio/images/edit32.png +0 -0
  37. package/assets/drawio/images/edit80.png +0 -0
  38. package/assets/drawio/images/embed-icon.png +0 -0
  39. package/assets/drawio/images/expanded.gif +0 -0
  40. package/assets/drawio/images/facebook.png +0 -0
  41. package/assets/drawio/images/favicon-16x16.png +0 -0
  42. package/assets/drawio/images/favicon-32x32.png +0 -0
  43. package/assets/drawio/images/file.png +0 -0
  44. package/assets/drawio/images/folder.png +0 -0
  45. package/assets/drawio/images/gadget-screenshot.png +0 -0
  46. package/assets/drawio/images/gadget-thumb.png +0 -0
  47. package/assets/drawio/images/github-logo-white.svg +6 -0
  48. package/assets/drawio/images/github-logo.svg +17 -0
  49. package/assets/drawio/images/gitlab-logo-white.svg +1 -0
  50. package/assets/drawio/images/gitlab-logo.svg +1 -0
  51. package/assets/drawio/images/glyphicons_blogger.png +0 -0
  52. package/assets/drawio/images/glyphicons_facebook.png +0 -0
  53. package/assets/drawio/images/glyphicons_github.png +0 -0
  54. package/assets/drawio/images/glyphicons_google.png +0 -0
  55. package/assets/drawio/images/glyphicons_star.png +0 -0
  56. package/assets/drawio/images/glyphicons_twitter.png +0 -0
  57. package/assets/drawio/images/glyphicons_youtube.png +0 -0
  58. package/assets/drawio/images/google-drive-connector-atlas.png +0 -0
  59. package/assets/drawio/images/google-drive-connector-atlas.svg +121 -0
  60. package/assets/drawio/images/google-drive-logo-white.svg +9 -0
  61. package/assets/drawio/images/google-drive-logo.svg +17 -0
  62. package/assets/drawio/images/google-share.png +0 -0
  63. package/assets/drawio/images/icon-192-maskable.png +0 -0
  64. package/assets/drawio/images/icon-192.png +0 -0
  65. package/assets/drawio/images/icon-512-maskable.png +0 -0
  66. package/assets/drawio/images/icon-512.png +0 -0
  67. package/assets/drawio/images/icon-search.svg +21 -0
  68. package/assets/drawio/images/img-hi-res.png +0 -0
  69. package/assets/drawio/images/img-lo-res.png +0 -0
  70. package/assets/drawio/images/list.svg +16 -0
  71. package/assets/drawio/images/locked.png +0 -0
  72. package/assets/drawio/images/log.png +0 -0
  73. package/assets/drawio/images/logo-confluence.png +0 -0
  74. package/assets/drawio/images/logo-flat-small.png +0 -0
  75. package/assets/drawio/images/logo-flat.png +0 -0
  76. package/assets/drawio/images/logo-jira.png +0 -0
  77. package/assets/drawio/images/logo-small.gif +0 -0
  78. package/assets/drawio/images/logo-white.png +0 -0
  79. package/assets/drawio/images/logo.png +0 -0
  80. package/assets/drawio/images/manifest.json +25 -0
  81. package/assets/drawio/images/move.png +0 -0
  82. package/assets/drawio/images/notion-logo-white.svg +1 -0
  83. package/assets/drawio/images/notion-logo.svg +1 -0
  84. package/assets/drawio/images/onedrive-connector-atlas.png +0 -0
  85. package/assets/drawio/images/onedrive-connector-atlas.svg +248 -0
  86. package/assets/drawio/images/onedrive-logo-white.svg +29 -0
  87. package/assets/drawio/images/onedrive-logo.svg +29 -0
  88. package/assets/drawio/images/osa_database.png +0 -0
  89. package/assets/drawio/images/osa_drive-harddisk.png +0 -0
  90. package/assets/drawio/images/plant-uml-atlas.png +0 -0
  91. package/assets/drawio/images/samepage-icon-color.svg +37 -0
  92. package/assets/drawio/images/save.png +0 -0
  93. package/assets/drawio/images/sidebar-android.png +0 -0
  94. package/assets/drawio/images/sidebar-archimate.png +0 -0
  95. package/assets/drawio/images/sidebar-arrows.png +0 -0
  96. package/assets/drawio/images/sidebar-arrows2.png +0 -0
  97. package/assets/drawio/images/sidebar-basic.png +0 -0
  98. package/assets/drawio/images/sidebar-c4.png +0 -0
  99. package/assets/drawio/images/sidebar-cabinets.png +0 -0
  100. package/assets/drawio/images/sidebar-cumulus.png +0 -0
  101. package/assets/drawio/images/sidebar-dfd.png +0 -0
  102. package/assets/drawio/images/sidebar-dynamics365.png +0 -0
  103. package/assets/drawio/images/sidebar-eip.png +0 -0
  104. package/assets/drawio/images/sidebar-er.png +0 -0
  105. package/assets/drawio/images/sidebar-floorplans.png +0 -0
  106. package/assets/drawio/images/sidebar-flowchart.png +0 -0
  107. package/assets/drawio/images/sidebar-gcp3.png +0 -0
  108. package/assets/drawio/images/sidebar-general.png +0 -0
  109. package/assets/drawio/images/sidebar-kubernetes.png +0 -0
  110. package/assets/drawio/images/sidebar-leanmapping.png +0 -0
  111. package/assets/drawio/images/sidebar-mockups.png +0 -0
  112. package/assets/drawio/images/sidebar-network.png +0 -0
  113. package/assets/drawio/images/sidebar-network2.png +0 -0
  114. package/assets/drawio/images/sidebar-openstack.png +0 -0
  115. package/assets/drawio/images/sidebar-sitemap.png +0 -0
  116. package/assets/drawio/images/sidebar-threatmodeling.png +0 -0
  117. package/assets/drawio/images/sidebar-uml.png +0 -0
  118. package/assets/drawio/images/sketch-logo128.png +0 -0
  119. package/assets/drawio/images/spin.gif +0 -0
  120. package/assets/drawio/images/sprites.png +0 -0
  121. package/assets/drawio/images/stop-flat-icon-80.png +0 -0
  122. package/assets/drawio/images/submenu.gif +0 -0
  123. package/assets/drawio/images/touch-submenu.png +0 -0
  124. package/assets/drawio/images/transparent.gif +0 -0
  125. package/assets/drawio/images/trello-logo-white-orange.svg +6 -0
  126. package/assets/drawio/images/trello-logo-white.svg +6 -0
  127. package/assets/drawio/images/trello-logo.svg +1 -0
  128. package/assets/drawio/images/tweet.png +0 -0
  129. package/assets/drawio/images/update16.png +0 -0
  130. package/assets/drawio/images/update32.png +0 -0
  131. package/assets/drawio/images/update80.png +0 -0
  132. package/assets/drawio/images/youtube.png +0 -0
  133. package/assets/drawio/img/clipart/Battery_0_128x128.png +0 -0
  134. package/assets/drawio/img/clipart/Battery_100_128x128.png +0 -0
  135. package/assets/drawio/img/clipart/Battery_50_128x128.png +0 -0
  136. package/assets/drawio/img/clipart/Battery_75_128x128.png +0 -0
  137. package/assets/drawio/img/clipart/Battery_allstates_128x128.png +0 -0
  138. package/assets/drawio/img/clipart/Bluetooth_128x128.png +0 -0
  139. package/assets/drawio/img/clipart/Earth_globe_128x128.png +0 -0
  140. package/assets/drawio/img/clipart/Empty_Folder_128x128.png +0 -0
  141. package/assets/drawio/img/clipart/Full_Folder_128x128.png +0 -0
  142. package/assets/drawio/img/clipart/Gear_128x128.png +0 -0
  143. package/assets/drawio/img/clipart/Keys_128x128.png +0 -0
  144. package/assets/drawio/img/clipart/Lock_128x128.png +0 -0
  145. package/assets/drawio/img/clipart/Mouse_Pointer_128x128.png +0 -0
  146. package/assets/drawio/img/clipart/Plug_128x128.png +0 -0
  147. package/assets/drawio/img/clipart/Ships_Wheel_128x128.png +0 -0
  148. package/assets/drawio/img/clipart/Star_128x128.png +0 -0
  149. package/assets/drawio/img/clipart/Tire_128x128.png +0 -0
  150. package/assets/drawio/index.html +92 -0
  151. package/assets/drawio/js/PostConfig.js +7 -0
  152. package/assets/drawio/js/PreConfig.js +13 -0
  153. package/assets/drawio/js/app.min.js +18466 -0
  154. package/assets/drawio/js/bootstrap.js +428 -0
  155. package/assets/drawio/js/diagramly/LibavoidRouting.js +4459 -0
  156. package/assets/drawio/js/export-init.js +21 -0
  157. package/assets/drawio/js/extensions.min.js +10478 -0
  158. package/assets/drawio/js/libavoid-js/LICENSE +505 -0
  159. package/assets/drawio/js/libavoid-js/libavoid-routing.js +1633 -0
  160. package/assets/drawio/js/libavoid-js/libavoid.min.js +59 -0
  161. package/assets/drawio/js/main.js +22 -0
  162. package/assets/drawio/js/rough/rough.min.js +1 -0
  163. package/assets/drawio/js/shapes-14-6-5.min.js +3457 -0
  164. package/assets/drawio/js/stencils.min.js +447 -0
  165. package/assets/drawio/mxgraph/css/common.css +147 -0
  166. package/assets/drawio/resources/dia.txt +2901 -0
  167. package/assets/drawio/styles/dark-default.xml +109 -0
  168. package/assets/drawio/styles/default-old.xml +109 -0
  169. package/assets/drawio/styles/default.xml +203 -0
  170. package/assets/drawio/styles/fonts/ArchitectsDaughter-Regular.ttf +0 -0
  171. package/assets/drawio/styles/grapheditor.css +4501 -0
  172. package/assets/drawio/styles/high-contrast.css +128 -0
  173. package/assets/drawio/styles/thumb_horz.png +0 -0
  174. package/assets/drawio/styles/thumb_vertical.png +0 -0
  175. package/assets/fonts/ibm-plex-mono-LICENSE.txt +93 -0
  176. package/assets/fonts/ibm-plex-sans-LICENSE.txt +93 -0
  177. package/assets/fonts/kalam-400.woff2 +0 -0
  178. package/assets/fonts/kalam-700.woff2 +0 -0
  179. package/assets/fonts/kalam-LICENSE.txt +93 -0
  180. package/assets/fonts/plex-mono-400.woff2 +0 -0
  181. package/assets/fonts/plex-mono-600.woff2 +0 -0
  182. package/assets/fonts/plex-sans-400.woff2 +0 -0
  183. package/assets/fonts/plex-sans-600.woff2 +0 -0
  184. package/dist/api.js +218 -0
  185. package/dist/cli.js +275 -0
  186. package/dist/drawio/icons.js +121 -0
  187. package/dist/drawio/merge.js +309 -0
  188. package/dist/drawio/read.js +180 -0
  189. package/dist/drawio/show.js +501 -0
  190. package/dist/drawio/theme.js +425 -0
  191. package/dist/drawio/write.js +300 -0
  192. package/dist/edit/server.js +212 -0
  193. package/dist/git.js +46 -0
  194. package/dist/import/mermaid.js +569 -0
  195. package/dist/layout/layout.js +212 -0
  196. package/dist/layout/sequence.js +333 -0
  197. package/dist/layout/text.js +73 -0
  198. package/dist/lint/check.js +188 -0
  199. package/dist/lint/fixlabels.js +128 -0
  200. package/dist/mcp/server.js +239 -0
  201. package/dist/publish.js +121 -0
  202. package/dist/render/browser.js +236 -0
  203. package/dist/render/fonts.js +66 -0
  204. package/dist/report.js +36 -0
  205. package/dist/spec/model.js +53 -0
  206. package/dist/spec/parse.js +497 -0
  207. package/package.json +71 -4
  208. package/skills/linework/SKILL.md +233 -0
  209. package/skills/linework/examples/billing-er.yaml +31 -0
  210. package/skills/linework/examples/checkout.yaml +28 -0
  211. package/skills/linework/examples/pay-sequence.yaml +28 -0
  212. package/skills/linework/examples/payment-state.yaml +22 -0
  213. package/skills/linework/examples/refund-flow.yaml +29 -0
  214. package/skills/linework/examples/serverless-aws.yaml +23 -0
  215. package/skills/linework/references/google-docs.md +46 -0
  216. package/skills/linework/references/spec.md +312 -0
  217. package/skills/linework/references/style-guide.md +53 -0
@@ -0,0 +1,312 @@
1
+ # Linework spec reference
2
+
3
+ `linework schema` prints the full JSON Schema.
4
+
5
+ ## Top level
6
+
7
+ | key | required | notes |
8
+ |---|---|---|
9
+ | `type` | yes | `architecture`, `flow`, `state`, `sequence` or `er` |
10
+ | `title` | no | stored in the file and used as the page name in draw.io |
11
+ | `direction` | no | `auto` (default), `TB`, `LR`, `BT` or `RL`. Not for sequence. |
12
+ | `theme` | no | the style: `clean` (default), `soft`, `dark`, `sketch`, `blueprint` or `c4` |
13
+ | `groups` | no | map of id to `{ label, in, color, highlight }`, or to a label string |
14
+ | `nodes` | yes | map of id to `{ label, kind, tech, in, icon, color, highlight }`, or to a label string |
15
+ | `edges` | no | list of edge strings, or `{ from, to, label, style, color, highlight }` objects |
16
+ | `participants` | sequence only | ordered map of id to `{ label, kind, tech }` |
17
+ | `messages` | sequence only | list of messages, notes and frames |
18
+
19
+ Unknown keys are errors, so typos surface right away.
20
+
21
+ ## Nodes
22
+
23
+ ```yaml
24
+ nodes:
25
+ api: { label: Checkout API, kind: service, tech: Go, in: vpc }
26
+ db: Orders # shorthand: just a label
27
+ cache: {} # label "Cache", default kind
28
+ ```
29
+
30
+ - `label` defaults to the id with `_`/`-` turned into spaces and the first letter capitalized.
31
+ - `kind` defaults to `service`, `step` or `state`, depending on the type.
32
+ - `in` names the group the node sits in.
33
+ - `highlight: true` draws the node in the style's accent color, solid. Use it for the one thing the doc is about.
34
+ - `color` tints it: `blue`, `violet`, `pink`, `red`, `orange`, `amber`, `green`, `teal` or `gray`. With `highlight`, it picks the highlight's color.
35
+
36
+ ## Styles
37
+
38
+ | style | looks like | font |
39
+ |---|---|---|
40
+ | `clean` | white boxes with hairline borders, groups drawn as gray grounds, cobalt accent. Nodes are neutral unless the kind means something (error, success). | IBM Plex Sans |
41
+ | `soft` | borderless pastel cards, each kind its own tint | IBM Plex Sans |
42
+ | `dark` | `clean` in GitHub's dark colors, so it sits flush on a dark README | IBM Plex Sans |
43
+ | `sketch` | hand-drawn strokes, pastel fills, red accent | Kalam (handwriting) |
44
+ | `blueprint` | light lines on deep blue, yellow accent, drafting capitals for group titles | IBM Plex Mono |
45
+ | `c4` | C4-PlantUML colors; each box says its element type | IBM Plex Sans |
46
+
47
+ The "drawn as" columns below describe `soft`. In `clean`, `dark` and `blueprint`, kinds differ by shape and dash only, and color comes from `highlight`, `color` and the error/success kinds.
48
+
49
+ Linework embeds the font, subset to the characters the diagram uses (about 10 to 15KB), so the SVG looks the same on GitHub, in a browser and in docs.
50
+
51
+ ### Architecture kinds
52
+
53
+ | kind | drawn as | use for |
54
+ |---|---|---|
55
+ | `service` | violet box | your own service, API or app server |
56
+ | `person` | pink box | a human user or role |
57
+ | `client` | blue box | browser app, mobile app, CLI |
58
+ | `function` | dashed violet box | serverless function, cron job, worker |
59
+ | `database` | green cylinder | relational or document database |
60
+ | `cache` | green box | Redis, Memcached, CDN |
61
+ | `storage` | green cylinder | object storage, file store, data lake |
62
+ | `queue` | amber pill | queue, topic, event stream |
63
+ | `external` | dashed grey box | a system you don't own |
64
+
65
+ ### Flow kinds
66
+
67
+ | kind | drawn as | use for |
68
+ |---|---|---|
69
+ | `step` | grey box | an action |
70
+ | `decision` | amber diamond | a branch; label every outgoing edge |
71
+ | `terminal` | grey pill | start or end |
72
+ | `data` | blue parallelogram | input or output data |
73
+ | `error` | red box | rejection or failure path |
74
+
75
+ ### State kinds
76
+
77
+ | kind | drawn as | use for |
78
+ |---|---|---|
79
+ | `state` | violet box | a state |
80
+ | `success` | green box | a good terminal state |
81
+ | `error` | red box | a failure state |
82
+
83
+ Write the initial and final pseudo-states as `[*]` in edges, as in Mermaid. Each `x -> [*]` gets its own end marker next to `x`.
84
+
85
+ ## Groups
86
+
87
+ ```yaml
88
+ groups:
89
+ vpc: { label: Production VPC }
90
+ data: { label: Data tier, in: vpc } # nested
91
+ ```
92
+
93
+ Edges connect nodes, not groups. To show "the API talks to the data tier", connect to the specific store.
94
+
95
+ ## Edges
96
+
97
+ ```yaml
98
+ edges:
99
+ - a -> b # call / flow
100
+ - a -> b: HTTPS # with label
101
+ - a ==> b: HTTPS # highlighted (accent color, thicker)
102
+ - a -.-> b: OrderPlaced # async or event (dashed)
103
+ - a <-> b: sync # two-way
104
+ - a -- b # association, no arrowhead
105
+ - "[*] -> pending" # state pseudo-state; quote lines starting with [
106
+ - "a -> b: label: with colon"
107
+ ```
108
+
109
+ For a colored edge, or a highlighted one that isn't a plain call, use the object form:
110
+
111
+ ```yaml
112
+ - { from: api, to: dlq, label: on failure, style: async, color: red }
113
+ - { from: a, to: b, style: bidir, highlight: true }
114
+ ```
115
+
116
+ The arrow needs a space on each side. Repeated edges between the same two nodes are allowed and get separate ids.
117
+
118
+ ## Full examples
119
+
120
+ ### Architecture
121
+
122
+ ```yaml
123
+ type: architecture
124
+ title: Checkout
125
+ groups:
126
+ vpc: { label: Production VPC }
127
+ data: { label: Data tier, in: vpc }
128
+ nodes:
129
+ user: { label: Shopper, kind: person }
130
+ web: { label: Web app, kind: client, tech: Next.js }
131
+ gw: { label: API gateway, tech: Envoy, in: vpc }
132
+ api: { label: Checkout API, tech: Go, in: vpc }
133
+ worker: { label: Fulfillment worker, tech: Go, in: vpc }
134
+ queue: { label: order-events, kind: queue, tech: Kafka, in: vpc }
135
+ db: { label: Orders, kind: database, tech: Postgres, in: data }
136
+ cache: { label: Session cache, kind: cache, tech: Redis, in: data }
137
+ stripe: { kind: external, tech: Payments API }
138
+ email: { label: SendGrid, kind: external, tech: Email }
139
+ edges:
140
+ - user -> web: browses
141
+ - web -> gw: HTTPS
142
+ - gw -> api: gRPC
143
+ - api -> cache: read session
144
+ - api -> db: SQL
145
+ - api -> stripe: charge
146
+ - api -.-> queue: OrderPlaced
147
+ - queue -.-> worker: consume
148
+ - worker -> db: update status
149
+ - worker -> email: receipt
150
+ ```
151
+
152
+ ### Flow
153
+
154
+ ```yaml
155
+ type: flow
156
+ title: Refund request
157
+ nodes:
158
+ start: { label: Refund requested, kind: terminal }
159
+ lookup: { label: Look up order }
160
+ window: { label: Within 30 days?, kind: decision }
161
+ amount: { label: Over $500?, kind: decision }
162
+ auto: { label: Auto-approve }
163
+ review: { label: Queue for manual review }
164
+ approved: { label: Approved?, kind: decision }
165
+ refund: { label: Issue refund via Stripe }
166
+ notify: { label: Email customer }
167
+ deny: { label: Deny with reason, kind: error }
168
+ done: { label: Done, kind: terminal }
169
+ edges:
170
+ - start -> lookup
171
+ - lookup -> window
172
+ - window -> amount: "yes"
173
+ - window -> deny: "no"
174
+ - amount -> auto: "no"
175
+ - amount -> review: "yes"
176
+ - review -> approved
177
+ - approved -> refund: "yes"
178
+ - approved -> deny: "no"
179
+ - auto -> refund
180
+ - refund -> notify
181
+ - deny -> notify
182
+ - notify -> done
183
+ ```
184
+
185
+ ### State
186
+
187
+ ```yaml
188
+ type: state
189
+ title: Payment lifecycle
190
+ nodes:
191
+ created: {}
192
+ authorizing: {}
193
+ authorized: {}
194
+ captured: { kind: success }
195
+ failed: { kind: error }
196
+ voided: {}
197
+ refunded: {}
198
+ edges:
199
+ - "[*] -> created"
200
+ - created -> authorizing: submit
201
+ - authorizing -> authorized: approved
202
+ - authorizing -> failed: declined
203
+ - authorized -> captured: capture
204
+ - authorized -> voided: void
205
+ - captured -> refunded: refund
206
+ - failed -> created: retry
207
+ - "captured -> [*]"
208
+ - "voided -> [*]"
209
+ - "refunded -> [*]"
210
+ ```
211
+
212
+ ## Icons (architecture)
213
+
214
+ ```yaml
215
+ nodes:
216
+ fn: { label: Resizer, kind: function, icon: aws.lambda }
217
+ run: { label: API, icon: gcp.cloud_run }
218
+ pod: { label: Worker pods, icon: k8s.deploy }
219
+ ```
220
+
221
+ `linework icons aws` lists every AWS name (about 1,000); add a filter word to search. Common short names work too: `aws.s3`, `aws.sqs`, `aws.kms`, `aws.msk`, `gcp.pubsub`, `gcp.gke`, `k8s.service`, `k8s.ingress`. An unknown name is a warning, and the node is drawn without an icon.
222
+
223
+ ## Sequence
224
+
225
+ ```yaml
226
+ type: sequence
227
+ title: Card payment
228
+ participants:
229
+ user: { label: Shopper, kind: person }
230
+ web: { label: Web app, kind: client }
231
+ api: { label: Checkout API }
232
+ stripe: { kind: external }
233
+ db: { label: Orders DB, kind: database }
234
+ messages:
235
+ - user -> web: Click "Pay"
236
+ - web -> api: POST /checkout
237
+ - api -> db: insert order (pending)
238
+ - db --> api: order id
239
+ - api -> stripe: create PaymentIntent
240
+ - stripe --> api: client_secret
241
+ - api --> web: client_secret
242
+ - web -> stripe: confirmCardPayment
243
+ - alt:
244
+ - when: succeeded
245
+ do:
246
+ - stripe -.-> api: webhook payment_succeeded
247
+ - api -> db: mark paid
248
+ - note over api, db: idempotent on event id
249
+ - when: declined
250
+ do:
251
+ - stripe --> web: card_declined
252
+ - web -> web: show error
253
+ - web --> user: result page
254
+ ```
255
+
256
+ | item | form |
257
+ |---|---|
258
+ | call | `a -> b: text` |
259
+ | highlighted call | `a ==> b: text` (accent color) |
260
+ | reply | `b --> a: text` (dashed, open arrow) |
261
+ | async | `a -.-> b: text` (open arrow) |
262
+ | self call | `a -> a: text` |
263
+ | note | `note over a: text`, `note over a, b: text`, `note left of a: text`, `note right of a: text` |
264
+ | branches | `- alt:` or `- par:` with a list of `{ when: condition, do: [items] }` |
265
+ | block | `- loop: label`, `- opt: label`, `- critical: label` or `- break: label`, each with `do: [items]` |
266
+
267
+ Frames nest. Keep it to 6 participants or fewer, so it fits a page.
268
+
269
+ ## ER
270
+
271
+ ```yaml
272
+ type: er
273
+ title: Billing schema
274
+ nodes:
275
+ orgs:
276
+ label: organizations
277
+ fields:
278
+ - id: uuid pk
279
+ - name: text
280
+ users:
281
+ fields:
282
+ - id: uuid pk
283
+ - org_id: uuid fk
284
+ - email: text unique
285
+ invoices:
286
+ fields:
287
+ - id: uuid pk
288
+ - org_id: uuid fk
289
+ - paid_at: timestamptz null
290
+ edges:
291
+ - users }o--|| orgs: belongs to
292
+ - invoices }o--|| orgs: billed to
293
+ ```
294
+
295
+ A field is `name: type flags`, a plain string `"name type flags"`, or `{ name, type, flags: [...] }`. Flags: `pk`, `fk`, `unique`, `null`. Kinds: `entity` (default), `view` (dashed) and `external` (a table another system owns).
296
+
297
+ Relationships use Mermaid's crow's-foot notation:
298
+
299
+ | left end | right end | means |
300
+ |---|---|---|
301
+ | `\|\|` | `\|\|` | exactly one |
302
+ | `\|o` | `o\|` | zero or one |
303
+ | `}o` | `o{` | zero or more |
304
+ | `}\|` | `\|{` | one or more |
305
+
306
+ The middle is `--` for an identifying relationship (solid line) or `..` for a non-identifying one (dashed).
307
+
308
+ ## Importing Mermaid
309
+
310
+ `linework import file.mmd` prints an linework spec. `-o out.drawio.svg` builds it straight away. A Markdown file works too; use `--block N` when it has several Mermaid blocks. Supported: `flowchart`/`graph`, `stateDiagram`, `sequenceDiagram`, `erDiagram`.
311
+
312
+ A flowchart with diamonds becomes a `flow`. One with subgraphs or cylinders becomes an `architecture` diagram. In that case a `<br>` second line becomes `tech`, and kinds are guessed from shapes and names: a cylinder becomes a database, "Kafka" becomes a queue, "Stripe" becomes external. Mermaid styling (`classDef`, `style`, `click`) is dropped. Review the printed spec before building, and fix any kinds it guessed wrong.
@@ -0,0 +1,53 @@
1
+ # What makes a good design-doc diagram
2
+
3
+ Linework handles the layout and the look. These rules are about content, which is the part only you can get right.
4
+
5
+ ## Scope
6
+
7
+ - **One diagram makes one point.** "How a checkout request flows" is a diagram. "Everything in the payments org" is a wiki page. When you need both the overview and the detail, draw two diagrams.
8
+ - **Aim for 12 nodes or fewer.** Past about 15, readers stop following edges. `build` warns at 20.
9
+ - **Pick a level of zoom and stay there.** Don't put "Kubernetes cluster" next to "parseOrder()" in the same diagram.
10
+ - **Leave out what the reader doesn't need.** Logging, metrics and auth sidecars can usually go unless the doc is about them.
11
+
12
+ ## Naming
13
+
14
+ - Label nodes with the same words the doc text uses. If the prose says "Checkout API", don't label the node "checkout-svc".
15
+ - Use `tech` for the technology (`Postgres`, `Kafka`, `Go`), not for a description.
16
+ - Keep labels to about 3 words. A label that wraps to a third line means the node is doing too much.
17
+
18
+ ## Edges
19
+
20
+ - **Label edges in architecture diagrams with the protocol or the verb**: `HTTPS`, `gRPC`, `SQL`, `publishes OrderPlaced`, `reads session`. An unlabeled arrow makes the reader guess.
21
+ - **Use `-.->` for async**: events, queues, webhooks, fire-and-forget. Readers rely on the solid/dashed distinction to see where latency and failure modes change.
22
+ - **Point the arrow the way the request goes**, not the way data comes back. Only show a return edge when the reply is interesting.
23
+ - **Label every edge out of a decision** in a flow (`yes`/`no`, or the condition).
24
+ - In state diagrams, label transitions with the event that triggers them (`payment_succeeded`), not the resulting state.
25
+
26
+ ## Groups
27
+
28
+ - **Draw groups along a real boundary**: a network (VPC), a trust boundary, a deployment unit or an owning team. Say which in the label, e.g. "Production VPC" or "Payments team".
29
+ - **Don't group just to tidy up.** Every box reads as a claim about how the system is structured.
30
+ - Keep external systems (`kind: external`) outside your groups.
31
+
32
+ ## Color and emphasis
33
+
34
+ - **Start neutral.** The default style draws every node the same, so whatever you color stands out. Add color only when it tells the reader something.
35
+ - **Highlight one thing.** Put `highlight: true` on the component the section is about and `==>` on the 2 or 3 edges that make up its path. A reader's eye goes there first. If everything is highlighted, nothing is.
36
+ - **Color marks a category, and the doc says which.** Red for failure paths, green for what this proposal adds, gray for what's being removed. Write one sentence under the diagram that explains it, e.g. "New components are green."
37
+ - **Use at most 2 or 3 colors** besides the highlight. More turns color back into noise.
38
+ - **Keep error and success kinds for real errors and successes.** They're red and green in every style.
39
+ - **Pick the style for the medium**: `clean` for docs and READMEs, `dark` for dark-mode pages, `soft` for slides, `sketch` for early drafts, `blueprint` for technical deep dives. Use one style across all the diagrams in a doc.
40
+
41
+ ## Direction
42
+
43
+ - Leave out `direction` on the first build. `auto` tries both and keeps the one that fits a doc page, which is about 800px wide.
44
+ - Set it only after looking at the result, and only if it reads wrong. A short linear pipeline of 5 or fewer steps can read better as LR.
45
+ - Don't force LR on a diagram with more than about 6 nodes in a row. It comes out 1,500px or more wide, and embedded in a doc its text shrinks to unreadable. `check` warns about this as `too-wide`.
46
+
47
+ ## Checking your result
48
+
49
+ Look at the PNG and ask:
50
+ 1. Could someone who hasn't read the doc say what this diagram shows in one sentence?
51
+ 2. Does every node appear in the doc text, or matter to the point?
52
+ 3. Does every edge say what goes across it?
53
+ 4. Is anything here only because "it exists", not because it matters to the point?