@vpxa/aikit 0.1.57 → 0.1.59

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.
@@ -0,0 +1,337 @@
1
+ # HTML/SVG Architecture Diagram Design System
2
+
3
+ This file is the centralized design system for HTML and SVG architecture diagrams.
4
+
5
+ It is the single source of truth for visual tokens, component categories, layout rules, and `present` tool composition guidance used by the `c4-architecture` skill and the `present` skill. Update component types, colors, layout rules, and icon slots here only.
6
+
7
+ ## Purpose
8
+
9
+ - Define a reusable visual language for C4-style architecture diagrams rendered as HTML and inline SVG.
10
+ - Keep category styling extensible through a registry instead of hardcoded component types.
11
+ - Standardize diagram composition for both skill-authored documentation and `present` output.
12
+
13
+ ## Core Design Tokens
14
+
15
+ ### Typography
16
+
17
+ - Font family: `"JetBrains Mono", monospace`
18
+ - Font source: Google Fonts (`https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700;800&display=swap`)
19
+ - Component names: `12px`
20
+ - Sublabels: `9px`
21
+ - Annotations: `8px`
22
+ - Tiny labels: `7px`
23
+ - Legend: `10px`
24
+ - Icon area labels: `11px`
25
+
26
+ ### Background
27
+
28
+ - Page background: `#020617` (`slate-950`)
29
+ - Background pattern: inline SVG grid pattern over the page background
30
+ - Recommended grid line colors:
31
+ - Major grid: `rgba(148, 163, 184, 0.08)`
32
+ - Minor grid: `rgba(148, 163, 184, 0.04)`
33
+
34
+ ### Component Box Defaults
35
+
36
+ - Shape: rounded rectangle
37
+ - Border radius: `rx="6"`
38
+ - Stroke width: `1.5px`
39
+ - Fill: category-specific semi-transparent RGBA fill
40
+ - Stroke: category-specific hex stroke
41
+ - Label stack:
42
+ - Line 1: C4 label such as `<<Container>>`
43
+ - Line 2: component name
44
+ - Line 3: subtype or technology summary
45
+
46
+ ## Category Registry
47
+
48
+ The registry is hierarchical: categories define shared tokens and C4 intent, while sub-types inherit the category styling and reserve an icon slot for future SVG glyphs.
49
+
50
+ | Category | Stroke Color | Fill Color | C4 Mapping | Sub-types |
51
+ |---|---|---|---|---|
52
+ | Frontend | `#22d3ee` | `rgba(8, 51, 68, 0.4)` | Container (SPA, web) | SPA, Mobile App, Static Site, Micro-frontend, PWA, Desktop App |
53
+ | Backend | `#34d399` | `rgba(6, 78, 59, 0.4)` | Container (service) | API Service, Worker/Job, BFF, Microservice, Serverless Function, gRPC Service |
54
+ | Data | `#a78bfa` | `rgba(76, 29, 149, 0.4)` | ContainerDb | Relational DB, Document DB, Key-Value Store, Cache, Search Engine, Data Warehouse, Graph DB, Time-Series DB |
55
+ | Infrastructure | `#fbbf24` | `rgba(120, 53, 15, 0.3)` | Deployment_Node | CDN, Load Balancer, DNS, Object Storage, Container Registry, Reverse Proxy, Service Mesh |
56
+ | Messaging | `#fb923c` | `rgba(251, 146, 60, 0.3)` | ContainerQueue | Message Queue, Event Bus, Stream, Pub/Sub, Webhook |
57
+ | Security | `#fb7185` | `rgba(136, 19, 55, 0.4)` | System_Ext / boundary | Auth Provider, API Gateway, WAF, Secret Manager, Certificate Manager, Identity Provider |
58
+ | External | `#94a3b8` | `rgba(30, 41, 59, 0.5)` | System_Ext | Third-party API, SaaS, Legacy System, Partner Service, Payment Provider |
59
+ | Monitoring | `#38bdf8` | `rgba(12, 74, 110, 0.4)` | Container | Logging, Metrics, Tracing, Alerting, APM |
60
+
61
+ ## Sub-type Registry
62
+
63
+ Each sub-type inherits its category tokens and keeps a placeholder slot for an inline SVG icon.
64
+
65
+ | Category | Sub-type | C4 Label | Icon Slot |
66
+ |---|---|---|---|
67
+ | Frontend | SPA | `<<Container>>` | `icon-spa` |
68
+ | Frontend | Mobile App | `<<Container>>` | `icon-mobile-app` |
69
+ | Frontend | Static Site | `<<Container>>` | `icon-static-site` |
70
+ | Frontend | Micro-frontend | `<<Container>>` | `icon-micro-frontend` |
71
+ | Frontend | PWA | `<<Container>>` | `icon-pwa` |
72
+ | Frontend | Desktop App | `<<Container>>` | `icon-desktop-app` |
73
+ | Backend | API Service | `<<Container>>` | `icon-api-service` |
74
+ | Backend | Worker/Job | `<<Container>>` | `icon-worker-job` |
75
+ | Backend | BFF | `<<Container>>` | `icon-bff` |
76
+ | Backend | Microservice | `<<Container>>` | `icon-microservice` |
77
+ | Backend | Serverless Function | `<<Container>>` | `icon-serverless-function` |
78
+ | Backend | gRPC Service | `<<Container>>` | `icon-grpc-service` |
79
+ | Data | Relational DB | `<<ContainerDb>>` | `icon-relational-db` |
80
+ | Data | Document DB | `<<ContainerDb>>` | `icon-document-db` |
81
+ | Data | Key-Value Store | `<<ContainerDb>>` | `icon-key-value-store` |
82
+ | Data | Cache | `<<ContainerDb>>` | `icon-cache` |
83
+ | Data | Search Engine | `<<ContainerDb>>` | `icon-search-engine` |
84
+ | Data | Data Warehouse | `<<ContainerDb>>` | `icon-data-warehouse` |
85
+ | Data | Graph DB | `<<ContainerDb>>` | `icon-graph-db` |
86
+ | Data | Time-Series DB | `<<ContainerDb>>` | `icon-time-series-db` |
87
+ | Infrastructure | CDN | `<<Deployment_Node>>` | `icon-cdn` |
88
+ | Infrastructure | Load Balancer | `<<Deployment_Node>>` | `icon-load-balancer` |
89
+ | Infrastructure | DNS | `<<Deployment_Node>>` | `icon-dns` |
90
+ | Infrastructure | Object Storage | `<<Deployment_Node>>` | `icon-object-storage` |
91
+ | Infrastructure | Container Registry | `<<Deployment_Node>>` | `icon-container-registry` |
92
+ | Infrastructure | Reverse Proxy | `<<Deployment_Node>>` | `icon-reverse-proxy` |
93
+ | Infrastructure | Service Mesh | `<<Deployment_Node>>` | `icon-service-mesh` |
94
+ | Messaging | Message Queue | `<<ContainerQueue>>` | `icon-message-queue` |
95
+ | Messaging | Event Bus | `<<ContainerQueue>>` | `icon-event-bus` |
96
+ | Messaging | Stream | `<<ContainerQueue>>` | `icon-stream` |
97
+ | Messaging | Pub/Sub | `<<ContainerQueue>>` | `icon-pub-sub` |
98
+ | Messaging | Webhook | `<<ContainerQueue>>` | `icon-webhook` |
99
+ | Security | Auth Provider | `<<System_Ext>>` | `icon-auth-provider` |
100
+ | Security | API Gateway | `<<System_Ext>>` | `icon-api-gateway` |
101
+ | Security | WAF | `<<System_Ext>>` | `icon-waf` |
102
+ | Security | Secret Manager | `<<System_Ext>>` | `icon-secret-manager` |
103
+ | Security | Certificate Manager | `<<System_Ext>>` | `icon-certificate-manager` |
104
+ | Security | Identity Provider | `<<System_Ext>>` | `icon-identity-provider` |
105
+ | External | Third-party API | `<<System_Ext>>` | `icon-third-party-api` |
106
+ | External | SaaS | `<<System_Ext>>` | `icon-saas` |
107
+ | External | Legacy System | `<<System_Ext>>` | `icon-legacy-system` |
108
+ | External | Partner Service | `<<System_Ext>>` | `icon-partner-service` |
109
+ | External | Payment Provider | `<<System_Ext>>` | `icon-payment-provider` |
110
+ | Monitoring | Logging | `<<Container>>` | `icon-logging` |
111
+ | Monitoring | Metrics | `<<Container>>` | `icon-metrics` |
112
+ | Monitoring | Tracing | `<<Container>>` | `icon-tracing` |
113
+ | Monitoring | Alerting | `<<Container>>` | `icon-alerting` |
114
+ | Monitoring | APM | `<<Container>>` | `icon-apm` |
115
+
116
+ ## Icon Registry
117
+
118
+ Icons are inline SVG `<symbol>` elements with a 16x16 viewBox, rendered via `<use>` at `(x+W-22, y+4)` inside the component box. They use `currentColor` to inherit the category stroke color.
119
+
120
+ ### Category-Level Icons (active)
121
+
122
+ Each category has a shared icon defined in `html-template.html` `<defs>`. All sub-types within a category use their category icon by default. Sub-type-specific icons can override these in the future.
123
+
124
+ | Category | Symbol ID | Shape | Status |
125
+ |---|---|---|---|
126
+ | Frontend | `icon-frontend` | Monitor with stand | **active** |
127
+ | Backend | `icon-backend` | Server rack (3 units) | **active** |
128
+ | Data | `icon-data` | Database cylinder | **active** |
129
+ | Infrastructure | `icon-infrastructure` | Cloud | **active** |
130
+ | Messaging | `icon-messaging` | Envelope | **active** |
131
+ | Security | `icon-security` | Shield with checkmark | **active** |
132
+ | External | `icon-external` | Globe with meridians | **active** |
133
+ | Monitoring | `icon-monitoring` | Line chart with axes | **active** |
134
+
135
+ Usage pattern:
136
+ ```svg
137
+ <use href="#icon-frontend" class="icon-use" x="448" y="154" width="16" height="16"/>
138
+ ```
139
+
140
+ ### Sub-type Icons (planned)
141
+
142
+ When a sub-type icon is added, it overrides the category icon for that specific component. Until implemented, all sub-types use their category icon.
143
+
144
+ | Sub-type | Icon | Status |
145
+ |---|---|---|
146
+ | SPA | `icon-spa` | planned |
147
+ | Mobile App | `icon-mobile-app` | planned |
148
+ | Static Site | `icon-static-site` | planned |
149
+ | Micro-frontend | `icon-micro-frontend` | planned |
150
+ | PWA | `icon-pwa` | planned |
151
+ | Desktop App | `icon-desktop-app` | planned |
152
+ | API Service | `icon-api-service` | planned |
153
+ | Worker/Job | `icon-worker-job` | planned |
154
+ | BFF | `icon-bff` | planned |
155
+ | Microservice | `icon-microservice` | planned |
156
+ | Serverless Function | `icon-serverless-function` | planned |
157
+ | gRPC Service | `icon-grpc-service` | planned |
158
+ | Relational DB | `icon-relational-db` | planned |
159
+ | Document DB | `icon-document-db` | planned |
160
+ | Key-Value Store | `icon-key-value-store` | planned |
161
+ | Cache | `icon-cache` | planned |
162
+ | Search Engine | `icon-search-engine` | planned |
163
+ | Data Warehouse | `icon-data-warehouse` | planned |
164
+ | Graph DB | `icon-graph-db` | planned |
165
+ | Time-Series DB | `icon-time-series-db` | planned |
166
+ | CDN | `icon-cdn` | planned |
167
+ | Load Balancer | `icon-load-balancer` | planned |
168
+ | DNS | `icon-dns` | planned |
169
+ | Object Storage | `icon-object-storage` | planned |
170
+ | Container Registry | `icon-container-registry` | planned |
171
+ | Reverse Proxy | `icon-reverse-proxy` | planned |
172
+ | Service Mesh | `icon-service-mesh` | planned |
173
+ | Message Queue | `icon-message-queue` | planned |
174
+ | Event Bus | `icon-event-bus` | planned |
175
+ | Stream | `icon-stream` | planned |
176
+ | Pub/Sub | `icon-pub-sub` | planned |
177
+ | Webhook | `icon-webhook` | planned |
178
+ | Auth Provider | `icon-auth-provider` | planned |
179
+ | API Gateway | `icon-api-gateway` | planned |
180
+ | WAF | `icon-waf` | planned |
181
+ | Secret Manager | `icon-secret-manager` | planned |
182
+ | Certificate Manager | `icon-certificate-manager` | planned |
183
+ | Identity Provider | `icon-identity-provider` | planned |
184
+ | Third-party API | `icon-third-party-api` | planned |
185
+ | SaaS | `icon-saas` | planned |
186
+ | Legacy System | `icon-legacy-system` | planned |
187
+ | Partner Service | `icon-partner-service` | planned |
188
+ | Payment Provider | `icon-payment-provider` | planned |
189
+ | Logging | `icon-logging` | planned |
190
+ | Metrics | `icon-metrics` | planned |
191
+ | Tracing | `icon-tracing` | planned |
192
+ | Alerting | `icon-alerting` | planned |
193
+ | APM | `icon-apm` | planned |
194
+
195
+ ## Visual Elements
196
+
197
+ ### Component Box Pattern
198
+
199
+ Use a rounded component box with semi-transparent fill and category stroke.
200
+
201
+ ```svg
202
+ <g class="node backend">
203
+ <rect x="280" y="210" width="190" height="60" rx="6" />
204
+ <text class="c4-tag" x="294" y="226">&lt;&lt;Container&gt;&gt;</text>
205
+ <text class="node-title" x="294" y="243">API Service</text>
206
+ <text class="node-subtitle" x="294" y="257">Backend / HTTPS JSON</text>
207
+ </g>
208
+ ```
209
+
210
+ ### Arrow Masking Technique
211
+
212
+ Use an opaque background rectangle below the box content to visually hide arrows beneath components without breaking the component fill style.
213
+
214
+ ```svg
215
+ <g class="node-mask-layer">
216
+ <rect x="280" y="210" width="190" height="60" rx="6" fill="#020617" />
217
+ <rect x="280" y="210" width="190" height="60" rx="6"
218
+ fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5" />
219
+ </g>
220
+ ```
221
+
222
+ ### Security Group Boundary
223
+
224
+ - Purpose: show auth, gateway, WAF, or identity zones
225
+ - Stroke color: rose (`#fb7185`)
226
+ - Pattern: `stroke-dasharray="4,4"`
227
+ - Suggested label: `Security Boundary`
228
+
229
+ ```svg
230
+ <rect x="700" y="140" width="220" height="180" rx="12"
231
+ fill="transparent" stroke="#fb7185" stroke-width="1.5"
232
+ stroke-dasharray="4,4" />
233
+ ```
234
+
235
+ ### Region Boundary
236
+
237
+ - Purpose: group a deployment region, platform segment, or domain slice
238
+ - Stroke color: amber (`#fbbf24`)
239
+ - Pattern: `stroke-dasharray="8,4"`
240
+ - Radius: `rx="12"`
241
+
242
+ ```svg
243
+ <rect x="70" y="120" width="600" height="430" rx="12"
244
+ fill="transparent" stroke="#fbbf24" stroke-width="1.5"
245
+ stroke-dasharray="8,4" />
246
+ ```
247
+
248
+ ### Arrow Marker SVG Definition
249
+
250
+ ```svg
251
+ <defs>
252
+ <marker id="arrowhead" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto">
253
+ <path d="M0,0 L8,4 L0,8 Z" fill="#cbd5e1" />
254
+ </marker>
255
+ </defs>
256
+ ```
257
+
258
+ ### Arrow Z-order Rule
259
+
260
+ Draw arrows early in the SVG so component boxes and masking layers paint over them. This keeps connectors readable in dense diagrams and avoids arrow overlap across component interiors.
261
+
262
+ ## Spacing Rules
263
+
264
+ - Standard component height: `60px`
265
+ - Minimum vertical gap between stacked components: `40px`
266
+ - Inline connectors should route through gaps rather than through component interiors
267
+ - Keep labels inside the top `28px` of the box and the subtype line inside the lower third
268
+ - Place legends outside boundaries to prevent classification noise inside the diagram area
269
+
270
+ ## Layout Structure
271
+
272
+ The canonical page composition is:
273
+
274
+ 1. Header: title, pulse dot, subtitle
275
+ 2. Main SVG diagram: embedded inside a rounded border card
276
+ 3. Summary cards: grid of 3 cards beneath the diagram
277
+ 4. Footer metadata: generator, scope, rendering notes, last-updated stamp
278
+
279
+ ## Present Tool Integration
280
+
281
+ Compose architecture diagrams with the `present` tool by embedding the full HTML/SVG diagram in a markdown block and pairing it with metrics or cards blocks as needed.
282
+
283
+ ### `format: "html"`
284
+
285
+ Use a `markdown` block with embedded `<div>`, inline SVG, and a `<style>` tag containing the full CSS. The `present` html format renders raw HTML in markdown blocks.
286
+
287
+ ### `format: "browser"`
288
+
289
+ Use the same composition: a `markdown` block containing the full HTML structure. Summary content can also be added with `cards` and `metrics` blocks alongside the SVG diagram block.
290
+
291
+ ### Example `present` Call Structure
292
+
293
+ ```js
294
+ present({
295
+ format: "html", // or "browser"
296
+ title: "System Architecture",
297
+ content: [
298
+ {
299
+ type: "metrics",
300
+ title: "Overview",
301
+ value: [
302
+ { label: "Services", value: "6" },
303
+ { label: "Data Stores", value: "2" },
304
+ { label: "External Systems", value: "3" }
305
+ ]
306
+ },
307
+ {
308
+ type: "markdown",
309
+ title: "Architecture Diagram",
310
+ value: "<div class='arch-diagram'>...(inline SVG)...</div><style>...(design system CSS)...</style>"
311
+ },
312
+ {
313
+ type: "cards",
314
+ title: "Summary",
315
+ value: [
316
+ { title: "Frontend", body: "React SPA..." },
317
+ { title: "Backend", body: "API + async workers..." },
318
+ { title: "Security", body: "Gateway + IdP..." }
319
+ ]
320
+ }
321
+ ]
322
+ })
323
+ ```
324
+
325
+ This design system is the single source of truth. The `c4-architecture` skill and `present` skill both reference this file. Update component types, colors, or layout rules here only.
326
+
327
+ ## Adding New Categories
328
+
329
+ 1. Add a new row to the Category Registry with the category name, colors, C4 mapping, and initial subtype set.
330
+ 2. Add the new sub-types to the Sub-type Registry with a C4 label and icon slot name.
331
+ 3. Add icon placeholders to the Icon Registry.
332
+ 4. Update [html-template.html](html-template.html) legend content so the new category appears in the rendered template.
333
+ 5. Update summary card accent colors in [html-template.html](html-template.html) if the new category needs a dedicated card treatment.
334
+
335
+ ## Template Pairing
336
+
337
+ See [html-template.html](html-template.html) for the complete self-contained reference implementation of this design system.