iso-explainer 1.0.0 → 1.1.0

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 (31) hide show
  1. package/README.md +17 -8
  2. package/README.pt-BR.md +14 -13
  3. package/package.json +1 -1
  4. package/skills/iso-explainer/SKILL.md +24 -17
  5. package/skills/iso-explainer/assets/figure/figure.mjs +93 -0
  6. package/skills/iso-explainer/assets/runtime/ANATOMY-LICENSE.txt +21 -0
  7. package/skills/iso-explainer/assets/runtime/app.js +60 -20
  8. package/skills/iso-explainer/assets/runtime/engine.js +113 -66
  9. package/skills/iso-explainer/assets/runtime/kit.js +676 -0
  10. package/skills/iso-explainer/assets/runtime/looks-core.js +162 -0
  11. package/skills/iso-explainer/assets/runtime/looks.js +508 -0
  12. package/skills/iso-explainer/assets/runtime/styles.css +461 -447
  13. package/skills/iso-explainer/assets/templates/starter.course.json +6 -6
  14. package/skills/iso-explainer/examples/arquitetura-pedidos.docs.json +12 -10
  15. package/skills/iso-explainer/examples/catalogo-looks.course.json +599 -0
  16. package/skills/iso-explainer/examples/engenharia-na-pratica.course.json +11 -6
  17. package/skills/iso-explainer/examples/figures/token-bucket.build.mjs +111 -0
  18. package/skills/iso-explainer/examples/figures/token-bucket.html +959 -95
  19. package/skills/iso-explainer/examples/historia-pedidos.story.json +12 -10
  20. package/skills/iso-explainer/references/engine.md +1 -1
  21. package/skills/iso-explainer/references/entities.md +5 -3
  22. package/skills/iso-explainer/references/figure-craft.md +62 -0
  23. package/skills/iso-explainer/references/inside.md +20 -10
  24. package/skills/iso-explainer/references/layout.md +12 -0
  25. package/skills/iso-explainer/references/looks.md +60 -0
  26. package/skills/iso-explainer/references/story-mode.md +2 -2
  27. package/skills/iso-explainer/scripts/build.mjs +5 -3
  28. package/skills/iso-explainer/scripts/lib/layout.mjs +111 -0
  29. package/skills/iso-explainer/scripts/lib/resolve.mjs +20 -2
  30. package/skills/iso-explainer/scripts/snapshot.mjs +159 -97
  31. package/skills/iso-explainer/scripts/validate.mjs +33 -16
@@ -33,17 +33,17 @@
33
33
  ],
34
34
  "defs": {
35
35
  "entities": {
36
- "user": { "type": "device", "x": -10, "y": 0, "label": "cliente" },
37
- "app": { "type": "block", "x": 0, "y": 0, "color": "blue", "glyph": "workflow", "label": ["Orquestrador"] },
38
- "llm": { "type": "block", "x": 0, "y": 9, "s": 3.6, "color": "gray", "glyph": "brain", "label": ["LLM"] },
39
- "catalog": { "type": "db", "x": 9, "y": 0, "label": "catálogo" },
40
- "ship": { "type": "block", "x": 9, "y": -8, "s": 3.4, "h": 38, "color": "green", "glyph": "truck", "label": ["Frete"], "sub": "API" }
36
+ "user": { "type": "device", "label": "cliente" },
37
+ "app": { "type": "block", "color": "blue", "glyph": "workflow", "label": ["Orquestrador"] },
38
+ "llm": { "type": "block", "s": 3.6, "color": "gray", "glyph": "brain", "label": ["LLM"] },
39
+ "catalog": { "type": "db", "label": "catálogo" },
40
+ "ship": { "type": "block", "s": 3.4, "h": 38, "color": "green", "glyph": "truck", "label": ["Frete"], "sub": "API" }
41
41
  },
42
42
  "links": {
43
43
  "ask": { "from": "user", "to": "app", "label": "quanto custa?" },
44
44
  "think": { "from": "app", "to": "llm", "heads": "both" },
45
45
  "db": { "from": "app", "to": "catalog", "label": "get_price()", "heads": "both" },
46
- "fr": { "from": "app", "to": "ship", "via": "y", "label": "quote()", "heads": "both" }
46
+ "fr": { "from": "app", "to": "ship", "label": "quote()", "heads": "both" }
47
47
  }
48
48
  },
49
49
  "steps": [
@@ -89,14 +89,14 @@
89
89
  "cli": {
90
90
  "type": "device",
91
91
  "form": "phone",
92
- "x": -13,
92
+ "x": -18,
93
93
  "y": 0,
94
94
  "label": "app do cliente",
95
95
  "inside": "app-cliente"
96
96
  },
97
97
  "gw": {
98
98
  "type": "block",
99
- "x": -3,
99
+ "x": -4.5,
100
100
  "y": 0,
101
101
  "s": 3.6,
102
102
  "color": "orange",
@@ -170,7 +170,7 @@
170
170
  },
171
171
  "dlq": {
172
172
  "type": "block",
173
- "x": 16,
173
+ "x": 18.5,
174
174
  "y": 9,
175
175
  "s": 3,
176
176
  "h": 32,
@@ -707,7 +707,7 @@
707
707
  "insides": {
708
708
  "rate-limit": {
709
709
  "title": "Rate limit: token bucket",
710
- "summary": "Cada cliente tem um balde com 10 fichas, reposto a 2 fichas/s. Cada requisição gasta uma ficha; sem ficha, o Gateway responde <code>429</code>. Mexa no tráfego para ver o balde esvaziar.",
710
+ "summary": "Suba o tráfego acima da reposição e veja o tubo esvaziar: daí em diante cada requisição extra vira 429.",
711
711
  "html": "figures/token-bucket.html"
712
712
  },
713
713
  "worker-loop": {
@@ -747,7 +747,7 @@
747
747
  "d": {
748
748
  "type": "db",
749
749
  "x": 0,
750
- "y": -8,
750
+ "y": -10,
751
751
  "label": "pedidos"
752
752
  },
753
753
  "p": {
@@ -980,7 +980,7 @@
980
980
  "st": {
981
981
  "type": "block",
982
982
  "x": 0,
983
- "y": -8,
983
+ "y": -10,
984
984
  "s": 3.4,
985
985
  "h": 40,
986
986
  "color": "yellow",
@@ -1001,7 +1001,8 @@
1001
1001
  "label": [
1002
1002
  "HTTP"
1003
1003
  ],
1004
- "sub": "cliente"
1004
+ "sub": "cliente",
1005
+ "look": "box"
1005
1006
  }
1006
1007
  },
1007
1008
  "links": {
@@ -1347,7 +1348,8 @@
1347
1348
  "glyph": "inbox",
1348
1349
  "label": [
1349
1350
  "waiting"
1350
- ]
1351
+ ],
1352
+ "look": "box"
1351
1353
  },
1352
1354
  "a": {
1353
1355
  "type": "block",
@@ -1650,7 +1652,7 @@
1650
1652
  },
1651
1653
  "op": {
1652
1654
  "type": "device",
1653
- "x": 10,
1655
+ "x": 14,
1654
1656
  "y": 0,
1655
1657
  "label": "plantão"
1656
1658
  }
@@ -1740,4 +1742,4 @@
1740
1742
  ]
1741
1743
  }
1742
1744
  }
1743
- }
1745
+ }
@@ -0,0 +1,599 @@
1
+ {
2
+ "meta": {
3
+ "id": "catalogo-looks",
4
+ "title": "Catálogo de looks",
5
+ "description": "Os 12 objetos que dão forma às caixas: cada um mostra, com movimento, o que aquele componente faz.",
6
+ "locale": "pt-BR",
7
+ "brand": {
8
+ "name": "iso-explainer",
9
+ "highlight": "explainer"
10
+ }
11
+ },
12
+ "metricDefs": {
13
+ "rps": {
14
+ "label": "Vazão",
15
+ "icon": "activity",
16
+ "format": "number",
17
+ "unit": "req/s",
18
+ "higher": true
19
+ },
20
+ "cpu": {
21
+ "label": "CPU da API",
22
+ "icon": "cpu",
23
+ "format": "percent",
24
+ "good": 60,
25
+ "warn": 85
26
+ }
27
+ },
28
+ "modules": [
29
+ {
30
+ "id": "looks",
31
+ "title": "Looks",
32
+ "color": "blue",
33
+ "lessons": [
34
+ "catalogo"
35
+ ]
36
+ }
37
+ ],
38
+ "lessons": [
39
+ {
40
+ "id": "catalogo",
41
+ "title": "Doze objetos, doze papéis",
42
+ "summary": "Cada caixa do palco vira um objeto cujo funcionamento é o próprio papel do componente.",
43
+ "metrics": [
44
+ "rps",
45
+ "cpu"
46
+ ],
47
+ "legend": [
48
+ "req",
49
+ "res",
50
+ "msg",
51
+ "fail"
52
+ ],
53
+ "defs": {
54
+ "entities": {
55
+ "gw": {
56
+ "type": "block",
57
+ "x": -10,
58
+ "y": -15,
59
+ "s": 4,
60
+ "color": "orange",
61
+ "look": "gateway",
62
+ "label": [
63
+ "Gateway"
64
+ ],
65
+ "sub": "gateway"
66
+ },
67
+ "lb": {
68
+ "type": "block",
69
+ "x": -10,
70
+ "y": -5,
71
+ "s": 4,
72
+ "color": "teal",
73
+ "look": "balancer",
74
+ "label": [
75
+ "Balanceador"
76
+ ],
77
+ "sub": "balancer"
78
+ },
79
+ "api": {
80
+ "type": "block",
81
+ "x": -10,
82
+ "y": 5,
83
+ "s": 4,
84
+ "color": "blue",
85
+ "look": "server",
86
+ "label": [
87
+ "API"
88
+ ],
89
+ "sub": "server"
90
+ },
91
+ "pg": {
92
+ "type": "db",
93
+ "x": -10,
94
+ "y": 15,
95
+ "r": 2,
96
+ "color": "purple",
97
+ "label": "Postgres"
98
+ },
99
+ "hook": {
100
+ "type": "block",
101
+ "x": 0,
102
+ "y": -15,
103
+ "s": 4,
104
+ "color": "green",
105
+ "look": "webhook",
106
+ "label": [
107
+ "Webhook"
108
+ ],
109
+ "sub": "webhook"
110
+ },
111
+ "fila": {
112
+ "type": "block",
113
+ "x": 0,
114
+ "y": -5,
115
+ "s": 4,
116
+ "color": "yellow",
117
+ "look": "queue",
118
+ "label": [
119
+ "Fila"
120
+ ],
121
+ "sub": "queue"
122
+ },
123
+ "wk": {
124
+ "type": "block",
125
+ "x": 0,
126
+ "y": 5,
127
+ "s": 4,
128
+ "color": "purple",
129
+ "look": "worker",
130
+ "label": [
131
+ "Worker"
132
+ ],
133
+ "sub": "worker",
134
+ "pills": "below"
135
+ },
136
+ "psp": {
137
+ "type": "block",
138
+ "x": 0,
139
+ "y": 15,
140
+ "s": 4,
141
+ "color": "gray",
142
+ "look": "external",
143
+ "label": [
144
+ "PSP"
145
+ ],
146
+ "sub": "external"
147
+ },
148
+ "cron": {
149
+ "type": "block",
150
+ "x": 10,
151
+ "y": -15,
152
+ "s": 4,
153
+ "color": "rose",
154
+ "look": "scheduler",
155
+ "label": [
156
+ "Agendador"
157
+ ],
158
+ "sub": "scheduler"
159
+ },
160
+ "ia": {
161
+ "type": "block",
162
+ "x": 10,
163
+ "y": -5,
164
+ "s": 4,
165
+ "color": "teal",
166
+ "look": "llm",
167
+ "label": [
168
+ "LLM"
169
+ ],
170
+ "sub": "llm"
171
+ },
172
+ "redis": {
173
+ "type": "block",
174
+ "x": 10,
175
+ "y": 5,
176
+ "s": 4,
177
+ "color": "orange",
178
+ "look": "cache",
179
+ "label": [
180
+ "Cache"
181
+ ],
182
+ "sub": "cache"
183
+ },
184
+ "dlq": {
185
+ "type": "block",
186
+ "x": 10,
187
+ "y": 15,
188
+ "s": 4,
189
+ "color": "rose",
190
+ "look": "dlq",
191
+ "label": [
192
+ "DLQ"
193
+ ],
194
+ "sub": "dlq",
195
+ "items": 3
196
+ }
197
+ },
198
+ "links": {
199
+ "a": {
200
+ "from": "gw",
201
+ "to": "lb"
202
+ },
203
+ "b": {
204
+ "from": "lb",
205
+ "to": "api"
206
+ },
207
+ "c": {
208
+ "from": "api",
209
+ "to": "pg",
210
+ "heads": "both"
211
+ },
212
+ "d": {
213
+ "from": "hook",
214
+ "to": "fila"
215
+ },
216
+ "e": {
217
+ "from": "fila",
218
+ "to": "wk"
219
+ },
220
+ "f": {
221
+ "from": "wk",
222
+ "to": "psp",
223
+ "heads": "both",
224
+ "fail": 0.25
225
+ },
226
+ "g": {
227
+ "from": "cron",
228
+ "to": "fila"
229
+ },
230
+ "h": {
231
+ "from": "wk",
232
+ "to": "redis",
233
+ "heads": "both"
234
+ },
235
+ "i": {
236
+ "from": "wk",
237
+ "to": "ia",
238
+ "heads": "both"
239
+ },
240
+ "j": {
241
+ "from": "wk",
242
+ "to": "dlq",
243
+ "style": "cut"
244
+ }
245
+ }
246
+ },
247
+ "steps": [
248
+ {
249
+ "short": "Todos",
250
+ "chapter": "problem",
251
+ "title": "O catálogo inteiro",
252
+ "body": [
253
+ "Cada caixa é um objeto que <b>faz</b> o papel do componente: a cancela do gateway sobe a cada requisição, a esteira da fila não para, a prensa do worker desce a cada job.",
254
+ "Sem <code>look</code>, a caixa escolhe o objeto pelo <code>glyph</code>. Com <code>\"look\": \"box\"</code>, volta a ser um cubo."
255
+ ],
256
+ "metrics": {
257
+ "rps": 220,
258
+ "cpu": 45
259
+ },
260
+ "scene": {
261
+ "entities": {
262
+ "gw": "gw",
263
+ "lb": "lb",
264
+ "api": "api",
265
+ "pg": "pg",
266
+ "hook": "hook",
267
+ "fila": "fila",
268
+ "wk": "wk",
269
+ "psp": "psp",
270
+ "cron": "cron",
271
+ "ia": "ia",
272
+ "redis": "redis",
273
+ "dlq": "dlq"
274
+ },
275
+ "links": {
276
+ "a": "a",
277
+ "b": "b",
278
+ "c": "c",
279
+ "d": "d",
280
+ "e": "e",
281
+ "f": "f",
282
+ "g": "g",
283
+ "h": "h",
284
+ "i": "i",
285
+ "j": "j"
286
+ },
287
+ "flows": [
288
+ {
289
+ "route": [
290
+ "a",
291
+ "b",
292
+ "c"
293
+ ],
294
+ "rate": 1.2
295
+ },
296
+ {
297
+ "route": [
298
+ "d",
299
+ "e",
300
+ "f"
301
+ ],
302
+ "kind": "msg",
303
+ "rate": 0.9
304
+ },
305
+ {
306
+ "route": [
307
+ "g"
308
+ ],
309
+ "kind": "msg",
310
+ "rate": 0.25
311
+ },
312
+ {
313
+ "routes": [
314
+ {
315
+ "path": [
316
+ "h"
317
+ ]
318
+ },
319
+ {
320
+ "path": [
321
+ "i"
322
+ ]
323
+ }
324
+ ],
325
+ "bounce": true,
326
+ "rate": 0.8
327
+ },
328
+ {
329
+ "route": [
330
+ "j"
331
+ ],
332
+ "kind": "poison",
333
+ "rate": 0.3
334
+ }
335
+ ]
336
+ }
337
+ },
338
+ {
339
+ "short": "Entrada",
340
+ "chapter": "technique",
341
+ "title": "Gateway, balanceador, API, banco",
342
+ "body": [
343
+ "A cancela abre para cada requisição; o ponteiro do balanceador gira para a saída da vez; os LEDs da API piscam mais rápido quando a CPU sobe; o braço do disco varre quando uma escrita chega."
344
+ ],
345
+ "metrics": {
346
+ "cpu": 91
347
+ },
348
+ "scene": {
349
+ "entities": {
350
+ "api": {
351
+ "cpu": 0.91,
352
+ "heat": 0.4
353
+ },
354
+ "pg": {
355
+ "cpu": 0.62
356
+ },
357
+ "hook": {
358
+ "dim": 1
359
+ },
360
+ "fila": {
361
+ "dim": 1
362
+ },
363
+ "wk": {
364
+ "dim": 1
365
+ },
366
+ "psp": {
367
+ "dim": 1
368
+ },
369
+ "cron": {
370
+ "dim": 1
371
+ },
372
+ "ia": {
373
+ "dim": 1
374
+ },
375
+ "redis": {
376
+ "dim": 1
377
+ },
378
+ "dlq": {
379
+ "dim": 1
380
+ }
381
+ },
382
+ "links": {
383
+ "d": {
384
+ "dim": true
385
+ },
386
+ "e": {
387
+ "dim": true
388
+ },
389
+ "f": {
390
+ "dim": true
391
+ },
392
+ "g": {
393
+ "dim": true
394
+ },
395
+ "h": {
396
+ "dim": true
397
+ },
398
+ "i": {
399
+ "dim": true
400
+ },
401
+ "j": {
402
+ "dim": true
403
+ }
404
+ },
405
+ "flows": [
406
+ {
407
+ "route": [
408
+ "a",
409
+ "b",
410
+ "c"
411
+ ],
412
+ "rate": 2.4
413
+ }
414
+ ]
415
+ }
416
+ },
417
+ {
418
+ "short": "Assíncrono",
419
+ "chapter": "technique",
420
+ "title": "Webhook, fila, worker, PSP",
421
+ "body": [
422
+ "A bandeira da caixa de correio sobe quando chega uma entrega; as bandejas andam na esteira; a prensa desce a cada job; o cartão entra no terminal e a luz responde verde ou vermelha."
423
+ ],
424
+ "metrics": {
425
+ "cpu": 45
426
+ },
427
+ "scene": {
428
+ "entities": {
429
+ "api": {
430
+ "cpu": -1,
431
+ "heat": 0,
432
+ "dim": 1
433
+ },
434
+ "pg": {
435
+ "cpu": -1,
436
+ "dim": 1
437
+ },
438
+ "gw": {
439
+ "dim": 1
440
+ },
441
+ "lb": {
442
+ "dim": 1
443
+ },
444
+ "hook": {
445
+ "dim": 0
446
+ },
447
+ "fila": {
448
+ "dim": 0
449
+ },
450
+ "wk": {
451
+ "dim": 0,
452
+ "cpu": 0.7
453
+ },
454
+ "psp": {
455
+ "dim": 0
456
+ }
457
+ },
458
+ "links": {
459
+ "a": {
460
+ "dim": true
461
+ },
462
+ "b": {
463
+ "dim": true
464
+ },
465
+ "c": {
466
+ "dim": true
467
+ },
468
+ "d": {
469
+ "dim": false
470
+ },
471
+ "e": {
472
+ "dim": false
473
+ },
474
+ "f": {
475
+ "dim": false
476
+ }
477
+ },
478
+ "flows": [
479
+ {
480
+ "route": [
481
+ "d",
482
+ "e",
483
+ "f"
484
+ ],
485
+ "kind": "msg",
486
+ "rate": 1.4
487
+ }
488
+ ]
489
+ }
490
+ },
491
+ {
492
+ "short": "Apoio",
493
+ "chapter": "recap",
494
+ "title": "Agendador, LLM, cache, DLQ",
495
+ "body": [
496
+ "O relógio toca quando um job agendado dispara; as células do chip acendem em onda a cada chamada; uma gaveta do arquivo abre em cada acerto de cache; as cartas mortas caem na caçamba."
497
+ ],
498
+ "scene": {
499
+ "entities": {
500
+ "hook": {
501
+ "dim": 1
502
+ },
503
+ "fila": {
504
+ "dim": 0.5
505
+ },
506
+ "psp": {
507
+ "dim": 1
508
+ },
509
+ "cron": {
510
+ "dim": 0
511
+ },
512
+ "ia": {
513
+ "dim": 0
514
+ },
515
+ "redis": {
516
+ "dim": 0
517
+ },
518
+ "dlq": {
519
+ "dim": 0
520
+ }
521
+ },
522
+ "links": {
523
+ "d": {
524
+ "dim": true
525
+ },
526
+ "f": {
527
+ "dim": true
528
+ },
529
+ "g": {
530
+ "dim": false
531
+ },
532
+ "h": {
533
+ "dim": false
534
+ },
535
+ "i": {
536
+ "dim": false
537
+ },
538
+ "j": {
539
+ "dim": false
540
+ }
541
+ },
542
+ "flows": [
543
+ {
544
+ "route": [
545
+ "g"
546
+ ],
547
+ "kind": "msg",
548
+ "rate": 0.6
549
+ },
550
+ {
551
+ "routes": [
552
+ {
553
+ "path": [
554
+ "h"
555
+ ]
556
+ },
557
+ {
558
+ "path": [
559
+ "i"
560
+ ]
561
+ }
562
+ ],
563
+ "bounce": true,
564
+ "rate": 1.4
565
+ },
566
+ {
567
+ "route": [
568
+ "j"
569
+ ],
570
+ "kind": "poison",
571
+ "rate": 0.6
572
+ }
573
+ ]
574
+ }
575
+ }
576
+ ],
577
+ "minutes": 3,
578
+ "level": "beginner",
579
+ "goals": [
580
+ {
581
+ "text": "Cada caixa é um objeto que faz o seu papel",
582
+ "step": 0
583
+ },
584
+ {
585
+ "text": "Entrada: cancela, distribuidor, rack, discos",
586
+ "step": 1
587
+ },
588
+ {
589
+ "text": "Assíncrono: correio, esteira, prensa, terminal",
590
+ "step": 2
591
+ },
592
+ {
593
+ "text": "Apoio: relógio, chip, arquivo, caçamba",
594
+ "step": 3
595
+ }
596
+ ]
597
+ }
598
+ ]
599
+ }