iso-explainer 0.0.0-stage → 1.0.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 (38) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +110 -2
  3. package/README.pt-BR.md +88 -0
  4. package/bin/iso-explainer.mjs +75 -0
  5. package/package.json +37 -4
  6. package/skills/iso-explainer/SKILL.md +92 -0
  7. package/skills/iso-explainer/assets/fonts/OFL.txt +93 -0
  8. package/skills/iso-explainer/assets/fonts/jetbrains-mono-latin-400-normal.woff2 +0 -0
  9. package/skills/iso-explainer/assets/fonts/jetbrains-mono-latin-500-normal.woff2 +0 -0
  10. package/skills/iso-explainer/assets/fonts/jetbrains-mono-latin-600-normal.woff2 +0 -0
  11. package/skills/iso-explainer/assets/fonts/jetbrains-mono-latin-700-normal.woff2 +0 -0
  12. package/skills/iso-explainer/assets/fonts/jetbrains-mono-latin-800-normal.woff2 +0 -0
  13. package/skills/iso-explainer/assets/runtime/LUCIDE-LICENSE.txt +43 -0
  14. package/skills/iso-explainer/assets/runtime/app.js +687 -0
  15. package/skills/iso-explainer/assets/runtime/engine.js +1177 -0
  16. package/skills/iso-explainer/assets/runtime/icons.js +205 -0
  17. package/skills/iso-explainer/assets/runtime/styles.css +447 -0
  18. package/skills/iso-explainer/assets/runtime/template.html +29 -0
  19. package/skills/iso-explainer/assets/templates/starter.course.json +134 -0
  20. package/skills/iso-explainer/examples/arquitetura-pedidos.docs.json +1743 -0
  21. package/skills/iso-explainer/examples/engenharia-na-pratica.course.json +2074 -0
  22. package/skills/iso-explainer/examples/figures/token-bucket.html +98 -0
  23. package/skills/iso-explainer/examples/historia-pedidos.story.json +1872 -0
  24. package/skills/iso-explainer/references/architecture-mode.md +82 -0
  25. package/skills/iso-explainer/references/design-system.md +58 -0
  26. package/skills/iso-explainer/references/engine.md +64 -0
  27. package/skills/iso-explainer/references/entities.md +70 -0
  28. package/skills/iso-explainer/references/flows.md +67 -0
  29. package/skills/iso-explainer/references/inside.md +64 -0
  30. package/skills/iso-explainer/references/layout.md +122 -0
  31. package/skills/iso-explainer/references/schema.md +157 -0
  32. package/skills/iso-explainer/references/story-mode.md +72 -0
  33. package/skills/iso-explainer/references/storytelling.md +56 -0
  34. package/skills/iso-explainer/scripts/build.mjs +80 -0
  35. package/skills/iso-explainer/scripts/harvest.mjs +240 -0
  36. package/skills/iso-explainer/scripts/lib/resolve.mjs +251 -0
  37. package/skills/iso-explainer/scripts/snapshot.mjs +97 -0
  38. package/skills/iso-explainer/scripts/validate.mjs +41 -0
@@ -0,0 +1,1743 @@
1
+ {
2
+ "meta": {
3
+ "id": "arquitetura-pedidos",
4
+ "mode": "docs",
5
+ "title": "Plataforma de Pedidos — Arquitetura",
6
+ "description": "Tour interativo pela arquitetura da plataforma de pedidos: componentes, fluxos, dados e modos de falha.",
7
+ "locale": "pt-BR",
8
+ "brand": {
9
+ "name": "Plataforma de Pedidos",
10
+ "highlight": "Pedidos"
11
+ },
12
+ "credit": {
13
+ "small": "arquitetura v2 ·",
14
+ "label": "time de plataforma",
15
+ "icon": "users",
16
+ "url": "#"
17
+ }
18
+ },
19
+ "glossary": {
20
+ "DLQ": "Dead-letter queue: fila onde ficam as mensagens que falharam depois de todas as tentativas.",
21
+ "PSP": "Provedor de serviços de pagamento (quem efetivamente processa o cartão/Pix).",
22
+ "idempotency key": "Chave única enviada ao PSP para que uma cobrança repetida não seja cobrada duas vezes."
23
+ },
24
+ "modules": [
25
+ {
26
+ "id": "visoes",
27
+ "title": "Plataforma de Pedidos",
28
+ "color": "blue",
29
+ "lessons": [
30
+ "fluxo-pedido",
31
+ {
32
+ "id": "deploy",
33
+ "title": "Deploy e ambientes"
34
+ }
35
+ ]
36
+ }
37
+ ],
38
+ "lessons": [
39
+ {
40
+ "id": "fluxo-pedido",
41
+ "title": "Como um pedido é processado",
42
+ "summary": "Do toque no app até a cobrança confirmada — quem faz o quê, onde os dados ficam e o que acontece quando algo falha.",
43
+ "badge": {
44
+ "text": "estado atual · nov/2026",
45
+ "icon": "calendar"
46
+ },
47
+ "metrics": [
48
+ "latency",
49
+ "throughput",
50
+ "errors"
51
+ ],
52
+ "legend": [
53
+ "req",
54
+ "res",
55
+ "write",
56
+ "msg",
57
+ "retry",
58
+ "poison",
59
+ "fail"
60
+ ],
61
+ "goals": [
62
+ {
63
+ "text": "Gateway autentica; a API não guarda estado",
64
+ "step": 1
65
+ },
66
+ {
67
+ "text": "Postgres é a fonte da verdade do pedido",
68
+ "step": 2
69
+ },
70
+ {
71
+ "text": "Cobrança é assíncrona, via fila",
72
+ "step": 3
73
+ },
74
+ {
75
+ "text": "Falhas do PSP viram retries e depois DLQ",
76
+ "step": 5
77
+ }
78
+ ],
79
+ "defs": {
80
+ "entities": {
81
+ "vpc": {
82
+ "type": "zone",
83
+ "x0": -6,
84
+ "x1": 9.5,
85
+ "y0": -13,
86
+ "y1": 21.5,
87
+ "label": "VPC · produção"
88
+ },
89
+ "cli": {
90
+ "type": "device",
91
+ "form": "phone",
92
+ "x": -13,
93
+ "y": 0,
94
+ "label": "app do cliente",
95
+ "inside": "app-cliente"
96
+ },
97
+ "gw": {
98
+ "type": "block",
99
+ "x": -3,
100
+ "y": 0,
101
+ "s": 3.6,
102
+ "color": "orange",
103
+ "glyph": "shield",
104
+ "label": [
105
+ "Gateway"
106
+ ],
107
+ "sub": "auth · limites",
108
+ "inside": "rate-limit"
109
+ },
110
+ "api": {
111
+ "type": "block",
112
+ "x": 6,
113
+ "y": 0,
114
+ "color": "blue",
115
+ "glyph": "server",
116
+ "label": [
117
+ "API"
118
+ ],
119
+ "sub": "NestJS · 3 pods",
120
+ "inside": "api-camadas"
121
+ },
122
+ "db": {
123
+ "type": "db",
124
+ "x": 6,
125
+ "y": -9,
126
+ "label": "postgres",
127
+ "inside": "postgres-dados"
128
+ },
129
+ "broker": {
130
+ "type": "block",
131
+ "x": 6,
132
+ "y": 9,
133
+ "s": 3.4,
134
+ "h": 34,
135
+ "color": "yellow",
136
+ "glyph": "inbox",
137
+ "label": [
138
+ "Fila"
139
+ ],
140
+ "sub": "BullMQ",
141
+ "inside": "fila-bullmq"
142
+ },
143
+ "worker": {
144
+ "type": "block",
145
+ "x": 6,
146
+ "y": 18,
147
+ "s": 3.4,
148
+ "h": 40,
149
+ "color": "purple",
150
+ "glyph": "bot",
151
+ "label": [
152
+ "Worker"
153
+ ],
154
+ "sub": "cobrança",
155
+ "inside": "worker-loop"
156
+ },
157
+ "pay": {
158
+ "type": "block",
159
+ "x": 16,
160
+ "y": 18,
161
+ "s": 3.4,
162
+ "h": 40,
163
+ "color": "gray",
164
+ "glyph": "credit-card",
165
+ "label": [
166
+ "PSP"
167
+ ],
168
+ "sub": "externo",
169
+ "inside": "psp-externo"
170
+ },
171
+ "dlq": {
172
+ "type": "block",
173
+ "x": 16,
174
+ "y": 9,
175
+ "s": 3,
176
+ "h": 32,
177
+ "color": "rose",
178
+ "glyph": "archive",
179
+ "label": [
180
+ "DLQ"
181
+ ],
182
+ "inside": "dlq-operacao"
183
+ }
184
+ },
185
+ "links": {
186
+ "c": {
187
+ "from": "cli",
188
+ "to": "gw",
189
+ "label": "HTTPS"
190
+ },
191
+ "g": {
192
+ "from": "gw",
193
+ "to": "api",
194
+ "label": "JWT validado"
195
+ },
196
+ "w": {
197
+ "from": "api",
198
+ "to": "db",
199
+ "label": "INSERT pedido",
200
+ "heads": "both"
201
+ },
202
+ "e": {
203
+ "from": "api",
204
+ "to": "broker",
205
+ "label": "pedido.criado"
206
+ },
207
+ "k": {
208
+ "from": "broker",
209
+ "to": "worker"
210
+ },
211
+ "p": {
212
+ "from": "worker",
213
+ "to": "pay",
214
+ "label": "cobrar()",
215
+ "heads": "both"
216
+ },
217
+ "u": {
218
+ "from": "worker",
219
+ "to": "db",
220
+ "pts": [
221
+ "worker",
222
+ [
223
+ 2,
224
+ 18
225
+ ],
226
+ [
227
+ 2,
228
+ -9
229
+ ],
230
+ "db"
231
+ ],
232
+ "label": "status = pago",
233
+ "style": "dashed"
234
+ },
235
+ "d": {
236
+ "from": "broker",
237
+ "to": "dlq",
238
+ "label": "após 5 falhas",
239
+ "labelTone": "red",
240
+ "style": "dashed"
241
+ }
242
+ }
243
+ },
244
+ "steps": [
245
+ {
246
+ "short": "Visão geral",
247
+ "chapter": "overview",
248
+ "title": "A arquitetura em uma tela",
249
+ "body": [
250
+ "O app fala só com o <b>Gateway</b>. Atrás dele, dentro da VPC, uma <b>API</b> sem estado grava no <code>postgres</code> e publica eventos numa <b>fila</b>.",
251
+ "Um <b>worker</b> consome a fila e fala com o <span class=\"term\">PSP</span> externo. O que falha demais vai para a <span class=\"term\">DLQ</span>."
252
+ ],
253
+ "callout": {
254
+ "kind": "insight",
255
+ "text": "Regra da casa: nada externo e lento é chamado dentro de uma requisição HTTP."
256
+ },
257
+ "metrics": {
258
+ "latency": 180,
259
+ "throughput": 220,
260
+ "errors": 0.2
261
+ },
262
+ "scene": {
263
+ "entities": {
264
+ "vpc": "vpc",
265
+ "cli": "cli",
266
+ "gw": "gw",
267
+ "api": "api",
268
+ "db": "db",
269
+ "broker": "broker",
270
+ "worker": "worker",
271
+ "pay": "pay",
272
+ "dlq": "dlq"
273
+ },
274
+ "links": {
275
+ "c": "c",
276
+ "g": "g",
277
+ "w": "w",
278
+ "e": "e",
279
+ "k": "k",
280
+ "p": "p",
281
+ "u": "u",
282
+ "d": "d"
283
+ },
284
+ "flows": [
285
+ {
286
+ "route": [
287
+ "c",
288
+ "g",
289
+ "w"
290
+ ],
291
+ "bounce": true,
292
+ "rate": 1.2
293
+ },
294
+ {
295
+ "route": [
296
+ "e",
297
+ "k",
298
+ "p"
299
+ ],
300
+ "kind": "msg",
301
+ "bounce": true,
302
+ "hold": 0.6,
303
+ "rate": 0.8
304
+ }
305
+ ]
306
+ }
307
+ },
308
+ {
309
+ "short": "Entrada",
310
+ "chapter": "flow",
311
+ "title": "Entrada: gateway → API",
312
+ "body": [
313
+ "Toda requisição passa pelo Gateway, que valida o JWT e aplica rate limit por cliente. A API recebe só tráfego autenticado.",
314
+ "A API não guarda sessão: qualquer um dos 3 pods atende qualquer requisição, então escalar é só subir réplicas."
315
+ ],
316
+ "changes": [
317
+ "~ Gateway: autenticação e rate limit",
318
+ "~ API: 3 pods, sem estado"
319
+ ],
320
+ "scene": {
321
+ "entities": {
322
+ "db": {
323
+ "dim": 1
324
+ },
325
+ "broker": {
326
+ "dim": 1
327
+ },
328
+ "worker": {
329
+ "dim": 1
330
+ },
331
+ "pay": {
332
+ "dim": 1
333
+ },
334
+ "dlq": {
335
+ "dim": 1
336
+ }
337
+ },
338
+ "links": {
339
+ "w": {
340
+ "dim": true
341
+ },
342
+ "e": {
343
+ "dim": true
344
+ },
345
+ "k": {
346
+ "dim": true
347
+ },
348
+ "p": {
349
+ "dim": true
350
+ },
351
+ "u": {
352
+ "dim": true
353
+ },
354
+ "d": {
355
+ "dim": true
356
+ }
357
+ },
358
+ "flows": [
359
+ {
360
+ "route": [
361
+ "c",
362
+ "g"
363
+ ],
364
+ "bounce": true,
365
+ "rate": 1.6
366
+ }
367
+ ]
368
+ }
369
+ },
370
+ {
371
+ "short": "Dados",
372
+ "chapter": "data",
373
+ "title": "O pedido é gravado antes de tudo",
374
+ "body": [
375
+ "A primeira coisa que a API faz é gravar o pedido com status <code>pendente</code> no postgres, numa transação.",
376
+ "Só depois do commit ela responde <code>201</code> ao app. Se qualquer coisa depois falhar, o pedido já existe e pode ser retomado."
377
+ ],
378
+ "callout": {
379
+ "kind": "tip",
380
+ "text": "O postgres é a fonte da verdade do pedido; fila e worker só fazem o pedido avançar de status."
381
+ },
382
+ "changes": [
383
+ "+ INSERT pedido (status pendente)",
384
+ "~ Resposta 201 após o commit"
385
+ ],
386
+ "scene": {
387
+ "entities": {
388
+ "db": {
389
+ "dim": 0
390
+ },
391
+ "gw": {
392
+ "dim": 0.6
393
+ },
394
+ "cli": {
395
+ "dim": 0.6
396
+ }
397
+ },
398
+ "links": {
399
+ "w": {
400
+ "dim": false
401
+ },
402
+ "c": {
403
+ "dim": true
404
+ }
405
+ },
406
+ "flows": [
407
+ {
408
+ "route": [
409
+ "g",
410
+ "w"
411
+ ],
412
+ "kind": "write",
413
+ "bounce": true,
414
+ "rate": 1.4
415
+ }
416
+ ]
417
+ }
418
+ },
419
+ {
420
+ "short": "Evento",
421
+ "chapter": "flow",
422
+ "title": "Cobrança vai para a fila",
423
+ "body": [
424
+ "Com o pedido salvo, a API publica <code>pedido.criado</code> na fila e encerra a requisição. Quem cobra é o worker, no ritmo dele.",
425
+ "Picos de pedidos viram fila maior, não timeouts para o cliente."
426
+ ],
427
+ "changes": [
428
+ "+ Evento pedido.criado",
429
+ "~ Worker consome no próprio ritmo"
430
+ ],
431
+ "scene": {
432
+ "entities": {
433
+ "db": {
434
+ "dim": 0.6
435
+ },
436
+ "broker": {
437
+ "dim": 0
438
+ },
439
+ "worker": {
440
+ "dim": 0
441
+ },
442
+ "api": {
443
+ "dim": 0
444
+ }
445
+ },
446
+ "links": {
447
+ "w": {
448
+ "dim": true
449
+ },
450
+ "e": {
451
+ "dim": false
452
+ },
453
+ "k": {
454
+ "dim": false
455
+ }
456
+ },
457
+ "flows": [
458
+ {
459
+ "route": [
460
+ "e",
461
+ "k"
462
+ ],
463
+ "kind": "msg",
464
+ "rate": 1.4
465
+ }
466
+ ]
467
+ }
468
+ },
469
+ {
470
+ "short": "PSP",
471
+ "chapter": "integration",
472
+ "title": "O worker cobra no PSP",
473
+ "body": [
474
+ "O worker chama o PSP com uma <span class=\"term\">idempotency key</span> igual ao id do pedido, espera a confirmação (~1–2 s) e marca o pedido como <code>pago</code>.",
475
+ "Se a mesma mensagem for processada duas vezes, o PSP devolve a cobrança original em vez de cobrar de novo."
476
+ ],
477
+ "changes": [
478
+ "+ Chamada cobrar() com idempotency key",
479
+ "~ status = pago no postgres"
480
+ ],
481
+ "scene": {
482
+ "entities": {
483
+ "pay": {
484
+ "dim": 0
485
+ },
486
+ "db": {
487
+ "dim": 0
488
+ },
489
+ "api": {
490
+ "dim": 0.6
491
+ },
492
+ "broker": {
493
+ "dim": 0.6
494
+ }
495
+ },
496
+ "links": {
497
+ "p": {
498
+ "dim": false
499
+ },
500
+ "u": {
501
+ "dim": false
502
+ },
503
+ "e": {
504
+ "dim": true
505
+ },
506
+ "k": {
507
+ "dim": true
508
+ }
509
+ },
510
+ "flows": [
511
+ {
512
+ "route": [
513
+ "p"
514
+ ],
515
+ "kind": "msg",
516
+ "bounce": true,
517
+ "hold": 1.2,
518
+ "rate": 0.9
519
+ },
520
+ {
521
+ "route": [
522
+ "u"
523
+ ],
524
+ "kind": "write",
525
+ "rate": 0.9
526
+ }
527
+ ]
528
+ }
529
+ },
530
+ {
531
+ "short": "Falha",
532
+ "chapter": "failure",
533
+ "title": "Quando o PSP fica fora",
534
+ "body": [
535
+ "Se o PSP não responde, o worker devolve a mensagem para a fila com backoff exponencial: 5 s, 30 s, 2 min, 10 min, 1 h.",
536
+ "Depois da 5ª falha, a mensagem vai para a <b>DLQ</b> e dispara um alerta. O pedido continua <code>pendente</code>, visível no painel de operações."
537
+ ],
538
+ "callout": {
539
+ "kind": "warn",
540
+ "text": "A DLQ precisa de dono: hoje o plantão revisa e reprocessa manualmente."
541
+ },
542
+ "changes": [
543
+ "- PSP indisponível",
544
+ "+ Retries com backoff",
545
+ "+ DLQ após 5 falhas"
546
+ ],
547
+ "metrics": {
548
+ "errors": 1.8
549
+ },
550
+ "scene": {
551
+ "entities": {
552
+ "pay": {
553
+ "dead": 1,
554
+ "tags": [
555
+ {
556
+ "text": "timeout",
557
+ "tone": "red",
558
+ "icon": "alert"
559
+ }
560
+ ]
561
+ },
562
+ "broker": {
563
+ "dim": 0
564
+ },
565
+ "dlq": {
566
+ "dim": 0
567
+ },
568
+ "db": {
569
+ "dim": 0.6
570
+ }
571
+ },
572
+ "links": {
573
+ "p": {
574
+ "fail": 1
575
+ },
576
+ "k": {
577
+ "dim": false
578
+ },
579
+ "d": {
580
+ "dim": false
581
+ },
582
+ "u": {
583
+ "dim": true
584
+ }
585
+ },
586
+ "flows": [
587
+ {
588
+ "route": [
589
+ "k",
590
+ "p"
591
+ ],
592
+ "kind": "retry",
593
+ "rate": 1.2
594
+ },
595
+ {
596
+ "route": [
597
+ "d"
598
+ ],
599
+ "kind": "poison",
600
+ "rate": 0.35
601
+ }
602
+ ]
603
+ }
604
+ },
605
+ {
606
+ "short": "Decisões",
607
+ "chapter": "decision",
608
+ "title": "Decisões e próximos passos",
609
+ "body": [
610
+ "O desenho prioriza nunca perder um pedido e nunca cobrar duas vezes, aceitando que a confirmação de pagamento seja assíncrona.",
611
+ "Os pontos em aberto estão no cartão ao lado."
612
+ ],
613
+ "scene": {
614
+ "entities": {
615
+ "pay": {
616
+ "dead": 0,
617
+ "tags": []
618
+ },
619
+ "gw": {
620
+ "dim": 0
621
+ },
622
+ "cli": {
623
+ "dim": 0
624
+ },
625
+ "api": {
626
+ "dim": 0
627
+ },
628
+ "db": {
629
+ "dim": 0
630
+ },
631
+ "broker": {
632
+ "dim": 0
633
+ },
634
+ "worker": {
635
+ "dim": 0
636
+ },
637
+ "dlq": {
638
+ "dim": 0
639
+ },
640
+ "card": {
641
+ "type": "panel",
642
+ "title": "Decisões",
643
+ "icon": "scale",
644
+ "lines": [
645
+ "= API sem estado → escala horizontal",
646
+ "= cobrança assíncrona via fila",
647
+ "= idempotency key no PSP",
648
+ "! DLQ ainda sem reprocessamento automático",
649
+ "# próximo: réplica de leitura p/ relatórios"
650
+ ]
651
+ }
652
+ },
653
+ "links": {
654
+ "c": {
655
+ "dim": false
656
+ },
657
+ "g": {
658
+ "dim": false
659
+ },
660
+ "w": {
661
+ "dim": false
662
+ },
663
+ "e": {
664
+ "dim": false
665
+ },
666
+ "k": {
667
+ "dim": false
668
+ },
669
+ "p": {
670
+ "dim": false,
671
+ "fail": 0
672
+ },
673
+ "u": {
674
+ "dim": false
675
+ },
676
+ "d": {
677
+ "dim": false
678
+ }
679
+ },
680
+ "flows": [
681
+ {
682
+ "route": [
683
+ "c",
684
+ "g",
685
+ "w"
686
+ ],
687
+ "bounce": true,
688
+ "rate": 1.2
689
+ },
690
+ {
691
+ "route": [
692
+ "e",
693
+ "k",
694
+ "p"
695
+ ],
696
+ "kind": "msg",
697
+ "bounce": true,
698
+ "hold": 0.6,
699
+ "rate": 0.8
700
+ }
701
+ ]
702
+ }
703
+ }
704
+ ]
705
+ }
706
+ ],
707
+ "insides": {
708
+ "rate-limit": {
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.",
711
+ "html": "figures/token-bucket.html"
712
+ },
713
+ "worker-loop": {
714
+ "title": "O loop do worker de cobrança",
715
+ "summary": "Um job por vez, do topo da fila até o ack.",
716
+ "legend": [
717
+ "msg",
718
+ "res",
719
+ "write",
720
+ "retry"
721
+ ],
722
+ "defs": {
723
+ "entities": {
724
+ "q": {
725
+ "type": "block",
726
+ "x": -9,
727
+ "y": 0,
728
+ "s": 3.4,
729
+ "h": 34,
730
+ "color": "yellow",
731
+ "glyph": "inbox",
732
+ "label": [
733
+ "Fila"
734
+ ]
735
+ },
736
+ "h": {
737
+ "type": "block",
738
+ "x": 0,
739
+ "y": 0,
740
+ "s": 3.6,
741
+ "color": "purple",
742
+ "glyph": "bot",
743
+ "label": [
744
+ "handler"
745
+ ]
746
+ },
747
+ "d": {
748
+ "type": "db",
749
+ "x": 0,
750
+ "y": -8,
751
+ "label": "pedidos"
752
+ },
753
+ "p": {
754
+ "type": "block",
755
+ "x": 9,
756
+ "y": 0,
757
+ "s": 3.4,
758
+ "h": 40,
759
+ "color": "gray",
760
+ "glyph": "credit-card",
761
+ "label": [
762
+ "PSP"
763
+ ]
764
+ }
765
+ },
766
+ "links": {
767
+ "qh": {
768
+ "from": "q",
769
+ "to": "h",
770
+ "label": "próximo job"
771
+ },
772
+ "hd": {
773
+ "from": "h",
774
+ "to": "d",
775
+ "label": "UPDATE status",
776
+ "heads": "both"
777
+ },
778
+ "hp": {
779
+ "from": "h",
780
+ "to": "p",
781
+ "label": "Idempotency-Key",
782
+ "heads": "both"
783
+ },
784
+ "back": {
785
+ "from": "h",
786
+ "to": "q",
787
+ "pts": [
788
+ "h",
789
+ [
790
+ "h",
791
+ "q+2.5"
792
+ ],
793
+ [
794
+ "q",
795
+ "q+2.5"
796
+ ],
797
+ "q"
798
+ ],
799
+ "label": "ack / retry",
800
+ "style": "dashed"
801
+ }
802
+ }
803
+ },
804
+ "steps": [
805
+ {
806
+ "short": "Job",
807
+ "chapter": "component",
808
+ "title": "Puxa o próximo job",
809
+ "body": [
810
+ "O worker pede à fila o próximo job e o marca como ativo. Enquanto estiver ativo, nenhum outro worker o recebe.",
811
+ "Se o worker morrer, o job volta para a fila após o prazo de bloqueio."
812
+ ],
813
+ "scene": {
814
+ "entities": {
815
+ "q": "q",
816
+ "h": "h"
817
+ },
818
+ "links": {
819
+ "qh": "qh"
820
+ },
821
+ "flows": [
822
+ {
823
+ "route": [
824
+ "qh"
825
+ ],
826
+ "kind": "msg",
827
+ "rate": 1
828
+ }
829
+ ]
830
+ }
831
+ },
832
+ {
833
+ "short": "Trava",
834
+ "chapter": "data",
835
+ "title": "Marca o pedido como em processamento",
836
+ "body": [
837
+ "Antes de cobrar, o handler muda o pedido para <code>processando</code> numa transação. Se já estiver <code>pago</code>, ele só confirma o job e sai."
838
+ ],
839
+ "changes": [
840
+ "+ UPDATE pedidos SET status = processando"
841
+ ],
842
+ "scene": {
843
+ "entities": {
844
+ "d": "d"
845
+ },
846
+ "links": {
847
+ "hd": "hd"
848
+ },
849
+ "flows": [
850
+ {
851
+ "route": [
852
+ "qh"
853
+ ],
854
+ "kind": "msg",
855
+ "rate": 1
856
+ },
857
+ {
858
+ "route": [
859
+ "hd"
860
+ ],
861
+ "kind": "write",
862
+ "bounce": true,
863
+ "rate": 1
864
+ }
865
+ ]
866
+ }
867
+ },
868
+ {
869
+ "short": "Cobra",
870
+ "chapter": "integration",
871
+ "title": "Cobra com a chave do pedido",
872
+ "body": [
873
+ "A chamada ao PSP leva <code>Idempotency-Key: pedido.id</code>. Repetir a mesma chave devolve a cobrança original — nunca uma nova."
874
+ ],
875
+ "changes": [
876
+ "+ cobrar() com idempotency key"
877
+ ],
878
+ "scene": {
879
+ "entities": {
880
+ "p": "p"
881
+ },
882
+ "links": {
883
+ "hp": "hp"
884
+ },
885
+ "flows": [
886
+ {
887
+ "route": [
888
+ "qh"
889
+ ],
890
+ "kind": "msg",
891
+ "rate": 0.8
892
+ },
893
+ {
894
+ "route": [
895
+ "hp"
896
+ ],
897
+ "kind": "msg",
898
+ "bounce": true,
899
+ "hold": 1,
900
+ "rate": 0.8
901
+ }
902
+ ]
903
+ }
904
+ },
905
+ {
906
+ "short": "Ack",
907
+ "chapter": "failure",
908
+ "title": "Ack ou retry",
909
+ "body": [
910
+ "Deu certo: <code>status = pago</code> e o job é confirmado (ack). Falhou: o job volta para a fila com backoff — 5 s, 30 s, 2 min… — até 5 tentativas."
911
+ ],
912
+ "changes": [
913
+ "+ ack no sucesso",
914
+ "+ retry com backoff na falha"
915
+ ],
916
+ "scene": {
917
+ "entities": {
918
+ "q": {
919
+ "tags": [
920
+ {
921
+ "text": "retry em 30 s",
922
+ "tone": "amber",
923
+ "icon": "clock"
924
+ }
925
+ ]
926
+ }
927
+ },
928
+ "links": {
929
+ "back": "back"
930
+ },
931
+ "flows": [
932
+ {
933
+ "route": [
934
+ "hp"
935
+ ],
936
+ "kind": "msg",
937
+ "bounce": true,
938
+ "hold": 0.8,
939
+ "rate": 0.8
940
+ },
941
+ {
942
+ "route": [
943
+ "back"
944
+ ],
945
+ "pattern": [
946
+ "res",
947
+ "res",
948
+ "retry"
949
+ ],
950
+ "rate": 1
951
+ }
952
+ ]
953
+ }
954
+ }
955
+ ]
956
+ },
957
+ "app-cliente": {
958
+ "title": "O app por dentro",
959
+ "summary": "Como o app monta o pedido e por que um reenvio não duplica nada.",
960
+ "legend": [
961
+ "req",
962
+ "res",
963
+ "write",
964
+ "retry"
965
+ ],
966
+ "defs": {
967
+ "entities": {
968
+ "ui": {
969
+ "type": "block",
970
+ "x": -10,
971
+ "y": 0,
972
+ "s": 3.4,
973
+ "h": 40,
974
+ "color": "blue",
975
+ "glyph": "smartphone",
976
+ "label": [
977
+ "Tela"
978
+ ]
979
+ },
980
+ "st": {
981
+ "type": "block",
982
+ "x": 0,
983
+ "y": -8,
984
+ "s": 3.4,
985
+ "h": 40,
986
+ "color": "yellow",
987
+ "glyph": "hard-drive",
988
+ "label": [
989
+ "Estado"
990
+ ],
991
+ "sub": "local"
992
+ },
993
+ "http": {
994
+ "type": "block",
995
+ "x": 0,
996
+ "y": 0,
997
+ "s": 3.4,
998
+ "h": 40,
999
+ "color": "orange",
1000
+ "glyph": "send",
1001
+ "label": [
1002
+ "HTTP"
1003
+ ],
1004
+ "sub": "cliente"
1005
+ }
1006
+ },
1007
+ "links": {
1008
+ "a": {
1009
+ "from": "ui",
1010
+ "to": "http",
1011
+ "label": "POST /pedidos"
1012
+ },
1013
+ "b": {
1014
+ "from": "http",
1015
+ "to": "st",
1016
+ "label": "pedido_id",
1017
+ "heads": "both"
1018
+ }
1019
+ }
1020
+ },
1021
+ "steps": [
1022
+ {
1023
+ "short": "Toque",
1024
+ "chapter": "component",
1025
+ "title": "O toque vira uma requisição",
1026
+ "body": [
1027
+ "O botão Comprar monta o pedido e o cliente HTTP envia <code>POST /pedidos</code> com o token do usuário."
1028
+ ],
1029
+ "scene": {
1030
+ "entities": {
1031
+ "ui": "ui",
1032
+ "http": "http"
1033
+ },
1034
+ "links": {
1035
+ "a": "a"
1036
+ },
1037
+ "flows": [
1038
+ {
1039
+ "route": [
1040
+ "a"
1041
+ ],
1042
+ "bounce": true,
1043
+ "rate": 1
1044
+ }
1045
+ ]
1046
+ }
1047
+ },
1048
+ {
1049
+ "short": "Id local",
1050
+ "chapter": "data",
1051
+ "title": "O id do pedido nasce no aparelho",
1052
+ "body": [
1053
+ "Antes de enviar, o app gera um <code>pedido_id</code> e guarda no estado local. Se a rede cair e o app reenviar, a API reconhece o mesmo id e não cria outro pedido."
1054
+ ],
1055
+ "scene": {
1056
+ "entities": {
1057
+ "st": "st",
1058
+ "http": {
1059
+ "tags": [
1060
+ {
1061
+ "text": "retry com o mesmo id",
1062
+ "tone": "amber",
1063
+ "icon": "repeat"
1064
+ }
1065
+ ]
1066
+ }
1067
+ },
1068
+ "links": {
1069
+ "b": "b"
1070
+ },
1071
+ "flows": [
1072
+ {
1073
+ "route": [
1074
+ "a"
1075
+ ],
1076
+ "kind": "retry",
1077
+ "bounce": true,
1078
+ "rate": 1.2
1079
+ },
1080
+ {
1081
+ "route": [
1082
+ "b"
1083
+ ],
1084
+ "kind": "write",
1085
+ "rate": 0.6
1086
+ }
1087
+ ]
1088
+ }
1089
+ }
1090
+ ]
1091
+ },
1092
+ "api-camadas": {
1093
+ "title": "A API por dentro",
1094
+ "summary": "Controller, serviço, repositório e publicação do evento — numa transação.",
1095
+ "legend": [
1096
+ "req",
1097
+ "res",
1098
+ "write",
1099
+ "msg"
1100
+ ],
1101
+ "defs": {
1102
+ "entities": {
1103
+ "c": {
1104
+ "type": "block",
1105
+ "x": -10,
1106
+ "y": 0,
1107
+ "s": 3.4,
1108
+ "h": 40,
1109
+ "color": "blue",
1110
+ "glyph": "code",
1111
+ "label": [
1112
+ "Controller"
1113
+ ]
1114
+ },
1115
+ "s": {
1116
+ "type": "block",
1117
+ "x": 0,
1118
+ "y": 0,
1119
+ "s": 3.4,
1120
+ "h": 40,
1121
+ "color": "purple",
1122
+ "glyph": "workflow",
1123
+ "label": [
1124
+ "Service"
1125
+ ]
1126
+ },
1127
+ "r": {
1128
+ "type": "db",
1129
+ "x": 10,
1130
+ "y": 0,
1131
+ "label": "repo"
1132
+ },
1133
+ "o": {
1134
+ "type": "block",
1135
+ "x": 0,
1136
+ "y": 9,
1137
+ "s": 3.4,
1138
+ "h": 40,
1139
+ "color": "yellow",
1140
+ "glyph": "send",
1141
+ "label": [
1142
+ "Outbox"
1143
+ ]
1144
+ }
1145
+ },
1146
+ "links": {
1147
+ "cs": {
1148
+ "from": "c",
1149
+ "to": "s",
1150
+ "label": "DTO válido"
1151
+ },
1152
+ "sr": {
1153
+ "from": "s",
1154
+ "to": "r",
1155
+ "label": "INSERT",
1156
+ "heads": "both"
1157
+ },
1158
+ "so": {
1159
+ "from": "s",
1160
+ "to": "o",
1161
+ "label": "pedido.criado"
1162
+ }
1163
+ }
1164
+ },
1165
+ "steps": [
1166
+ {
1167
+ "short": "Controller",
1168
+ "chapter": "component",
1169
+ "title": "O controller só valida",
1170
+ "body": [
1171
+ "Recebe o JSON, valida o DTO (campos, valores, usuário do JWT) e chama o serviço. Nenhuma regra de negócio mora aqui."
1172
+ ],
1173
+ "scene": {
1174
+ "entities": {
1175
+ "c": "c",
1176
+ "s": "s"
1177
+ },
1178
+ "links": {
1179
+ "cs": "cs"
1180
+ },
1181
+ "flows": [
1182
+ {
1183
+ "route": [
1184
+ "cs"
1185
+ ],
1186
+ "bounce": true,
1187
+ "rate": 1
1188
+ }
1189
+ ]
1190
+ }
1191
+ },
1192
+ {
1193
+ "short": "Transação",
1194
+ "chapter": "data",
1195
+ "title": "Grava o pedido numa transação",
1196
+ "body": [
1197
+ "O serviço abre uma transação, grava o pedido como <code>pendente</code> e, na mesma transação, registra o evento numa tabela <b>outbox</b>."
1198
+ ],
1199
+ "scene": {
1200
+ "entities": {
1201
+ "r": "r",
1202
+ "o": "o"
1203
+ },
1204
+ "links": {
1205
+ "sr": "sr",
1206
+ "so": "so"
1207
+ },
1208
+ "flows": [
1209
+ {
1210
+ "route": [
1211
+ "cs",
1212
+ "sr"
1213
+ ],
1214
+ "kind": "write",
1215
+ "bounce": true,
1216
+ "rate": 1
1217
+ }
1218
+ ]
1219
+ }
1220
+ },
1221
+ {
1222
+ "short": "Outbox",
1223
+ "chapter": "flow",
1224
+ "title": "O evento sai depois do commit",
1225
+ "body": [
1226
+ "Um publicador lê a outbox e envia <code>pedido.criado</code> para a fila só depois do commit. Assim nunca existe evento de um pedido que não foi gravado."
1227
+ ],
1228
+ "scene": {
1229
+ "entities": {
1230
+ "o": {
1231
+ "tags": [
1232
+ {
1233
+ "text": "após o commit",
1234
+ "tone": "green",
1235
+ "icon": "check"
1236
+ }
1237
+ ]
1238
+ }
1239
+ },
1240
+ "flows": [
1241
+ {
1242
+ "route": [
1243
+ "so"
1244
+ ],
1245
+ "kind": "msg",
1246
+ "rate": 1
1247
+ }
1248
+ ]
1249
+ },
1250
+ "callout": {
1251
+ "kind": "insight",
1252
+ "text": "Banco e fila não participam da mesma transação; a outbox é a ponte segura entre os dois."
1253
+ }
1254
+ }
1255
+ ]
1256
+ },
1257
+ "postgres-dados": {
1258
+ "title": "O postgres por dentro",
1259
+ "summary": "A tabela de pedidos e a máquina de estados que o sistema inteiro respeita.",
1260
+ "defs": {
1261
+ "entities": {
1262
+ "t": {
1263
+ "type": "db",
1264
+ "x": 0,
1265
+ "y": 0,
1266
+ "label": "pedidos",
1267
+ "r": 2,
1268
+ "h": 44
1269
+ },
1270
+ "rep": {
1271
+ "type": "ghost",
1272
+ "x": 9,
1273
+ "y": 0,
1274
+ "s": 4,
1275
+ "h": 46,
1276
+ "label": "réplica · planejada"
1277
+ }
1278
+ },
1279
+ "links": {}
1280
+ },
1281
+ "steps": [
1282
+ {
1283
+ "short": "Estados",
1284
+ "chapter": "data",
1285
+ "title": "Um pedido só anda para a frente",
1286
+ "body": [
1287
+ "O campo <code>status</code> segue uma máquina de estados. Toda escrita confere o estado atual com <code>UPDATE … WHERE status = …</code>, então duas escritas concorrentes não passam."
1288
+ ],
1289
+ "scene": {
1290
+ "entities": {
1291
+ "t": "t",
1292
+ "card": {
1293
+ "type": "panel",
1294
+ "title": "status do pedido",
1295
+ "icon": "workflow",
1296
+ "lines": [
1297
+ "pendente → processando",
1298
+ "processando → pago",
1299
+ "processando → falhou",
1300
+ "# nunca volta para trás"
1301
+ ]
1302
+ }
1303
+ }
1304
+ }
1305
+ },
1306
+ {
1307
+ "short": "Réplica",
1308
+ "chapter": "proposal",
1309
+ "title": "Próximo passo: réplica de leitura",
1310
+ "body": [
1311
+ "Relatórios pesados ainda leem do primário. A proposta é uma réplica só para leitura — ainda não implementada."
1312
+ ],
1313
+ "scene": {
1314
+ "entities": {
1315
+ "rep": "rep",
1316
+ "card": {
1317
+ "type": "panel",
1318
+ "title": "leituras hoje",
1319
+ "icon": "activity",
1320
+ "lines": [
1321
+ "checkout primário",
1322
+ "relatórios primário",
1323
+ "! relatórios disputam com escrita"
1324
+ ]
1325
+ }
1326
+ }
1327
+ }
1328
+ }
1329
+ ]
1330
+ },
1331
+ "fila-bullmq": {
1332
+ "title": "A fila por dentro",
1333
+ "summary": "Os estados de um job no BullMQ (Redis).",
1334
+ "legend": [
1335
+ "msg",
1336
+ "retry"
1337
+ ],
1338
+ "defs": {
1339
+ "entities": {
1340
+ "w": {
1341
+ "type": "block",
1342
+ "x": -12,
1343
+ "y": 0,
1344
+ "s": 3.2,
1345
+ "h": 34,
1346
+ "color": "yellow",
1347
+ "glyph": "inbox",
1348
+ "label": [
1349
+ "waiting"
1350
+ ]
1351
+ },
1352
+ "a": {
1353
+ "type": "block",
1354
+ "x": -3,
1355
+ "y": 0,
1356
+ "s": 3.2,
1357
+ "h": 34,
1358
+ "color": "orange",
1359
+ "glyph": "zap",
1360
+ "label": [
1361
+ "active"
1362
+ ]
1363
+ },
1364
+ "d": {
1365
+ "type": "block",
1366
+ "x": 6,
1367
+ "y": 0,
1368
+ "s": 3.4,
1369
+ "h": 34,
1370
+ "color": "green",
1371
+ "glyph": "check",
1372
+ "label": [
1373
+ "completed"
1374
+ ]
1375
+ },
1376
+ "dl": {
1377
+ "type": "block",
1378
+ "x": -3,
1379
+ "y": -9,
1380
+ "s": 3.2,
1381
+ "h": 34,
1382
+ "color": "gray",
1383
+ "glyph": "clock",
1384
+ "label": [
1385
+ "delayed"
1386
+ ]
1387
+ }
1388
+ },
1389
+ "links": {
1390
+ "wa": {
1391
+ "from": "w",
1392
+ "to": "a",
1393
+ "label": "worker pega"
1394
+ },
1395
+ "ad": {
1396
+ "from": "a",
1397
+ "to": "d",
1398
+ "label": "ack"
1399
+ },
1400
+ "adl": {
1401
+ "from": "a",
1402
+ "to": "dl",
1403
+ "label": "falhou",
1404
+ "style": "dashed"
1405
+ },
1406
+ "dlw": {
1407
+ "from": "dl",
1408
+ "to": "w",
1409
+ "label": "backoff venceu",
1410
+ "pts": [
1411
+ "dl",
1412
+ [
1413
+ "w",
1414
+ "dl"
1415
+ ],
1416
+ "w"
1417
+ ],
1418
+ "style": "dashed"
1419
+ }
1420
+ }
1421
+ },
1422
+ "steps": [
1423
+ {
1424
+ "short": "Estados",
1425
+ "chapter": "component",
1426
+ "title": "waiting → active → completed",
1427
+ "body": [
1428
+ "Cada job espera na lista <code>waiting</code>; um worker o move para <code>active</code> e, no ack, para <code>completed</code>."
1429
+ ],
1430
+ "scene": {
1431
+ "entities": {
1432
+ "w": "w",
1433
+ "a": "a",
1434
+ "d": "d"
1435
+ },
1436
+ "links": {
1437
+ "wa": "wa",
1438
+ "ad": "ad"
1439
+ },
1440
+ "flows": [
1441
+ {
1442
+ "route": [
1443
+ "wa",
1444
+ "ad"
1445
+ ],
1446
+ "kind": "msg",
1447
+ "rate": 1
1448
+ }
1449
+ ]
1450
+ }
1451
+ },
1452
+ {
1453
+ "short": "Retry",
1454
+ "chapter": "failure",
1455
+ "title": "Falhou? Espera e volta",
1456
+ "body": [
1457
+ "Se o worker lança erro, o job vai para <code>delayed</code> com o tempo de backoff e volta para <code>waiting</code> quando ele vence."
1458
+ ],
1459
+ "scene": {
1460
+ "entities": {
1461
+ "dl": "dl"
1462
+ },
1463
+ "links": {
1464
+ "adl": "adl",
1465
+ "dlw": "dlw"
1466
+ },
1467
+ "flows": [
1468
+ {
1469
+ "route": [
1470
+ "wa",
1471
+ "ad"
1472
+ ],
1473
+ "kind": "msg",
1474
+ "rate": 0.8
1475
+ },
1476
+ {
1477
+ "route": [
1478
+ "adl",
1479
+ "dlw"
1480
+ ],
1481
+ "kind": "retry",
1482
+ "rate": 0.5
1483
+ }
1484
+ ]
1485
+ }
1486
+ }
1487
+ ]
1488
+ },
1489
+ "psp-externo": {
1490
+ "title": "A integração com o PSP",
1491
+ "summary": "O que controlamos do nosso lado da fronteira.",
1492
+ "legend": [
1493
+ "req",
1494
+ "res",
1495
+ "event"
1496
+ ],
1497
+ "defs": {
1498
+ "entities": {
1499
+ "cl": {
1500
+ "type": "block",
1501
+ "x": -10,
1502
+ "y": 0,
1503
+ "s": 3.4,
1504
+ "h": 40,
1505
+ "color": "purple",
1506
+ "glyph": "credit-card",
1507
+ "label": [
1508
+ "cliente"
1509
+ ],
1510
+ "sub": "PSP"
1511
+ },
1512
+ "p": {
1513
+ "type": "block",
1514
+ "x": 0,
1515
+ "y": 0,
1516
+ "s": 3.4,
1517
+ "h": 40,
1518
+ "color": "gray",
1519
+ "glyph": "landmark",
1520
+ "label": [
1521
+ "PSP"
1522
+ ],
1523
+ "sub": "externo"
1524
+ },
1525
+ "wh": {
1526
+ "type": "block",
1527
+ "x": 0,
1528
+ "y": 9,
1529
+ "s": 3.4,
1530
+ "h": 40,
1531
+ "color": "blue",
1532
+ "glyph": "webhook",
1533
+ "label": [
1534
+ "Webhook"
1535
+ ],
1536
+ "sub": "/psp"
1537
+ }
1538
+ },
1539
+ "links": {
1540
+ "cp": {
1541
+ "from": "cl",
1542
+ "to": "p",
1543
+ "label": "cobrar()",
1544
+ "heads": "both"
1545
+ },
1546
+ "pw": {
1547
+ "from": "p",
1548
+ "to": "wh",
1549
+ "label": "pagamento.confirmado"
1550
+ }
1551
+ }
1552
+ },
1553
+ "steps": [
1554
+ {
1555
+ "short": "Chamada",
1556
+ "chapter": "integration",
1557
+ "title": "Chamada com chave e timeout",
1558
+ "body": [
1559
+ "Toda cobrança leva <code>Idempotency-Key</code> e timeout de 10 s. Timeout não significa falha: significa <b>não sabemos</b> — por isso o retry usa a mesma chave."
1560
+ ],
1561
+ "scene": {
1562
+ "entities": {
1563
+ "cl": {
1564
+ "use": "cl",
1565
+ "tags": [
1566
+ {
1567
+ "text": "timeout 10 s",
1568
+ "tone": "amber",
1569
+ "icon": "timer"
1570
+ }
1571
+ ]
1572
+ },
1573
+ "p": "p"
1574
+ },
1575
+ "links": {
1576
+ "cp": "cp"
1577
+ },
1578
+ "flows": [
1579
+ {
1580
+ "route": [
1581
+ "cp"
1582
+ ],
1583
+ "bounce": true,
1584
+ "hold": 1,
1585
+ "rate": 0.9
1586
+ }
1587
+ ]
1588
+ }
1589
+ },
1590
+ {
1591
+ "short": "Webhook",
1592
+ "chapter": "integration",
1593
+ "title": "A confirmação chega por webhook",
1594
+ "body": [
1595
+ "Pix e alguns cartões confirmam depois. O PSP chama nosso <code>/psp</code>, que valida a assinatura e atualiza o pedido."
1596
+ ],
1597
+ "scene": {
1598
+ "entities": {
1599
+ "wh": "wh"
1600
+ },
1601
+ "links": {
1602
+ "pw": "pw"
1603
+ },
1604
+ "flows": [
1605
+ {
1606
+ "route": [
1607
+ "pw"
1608
+ ],
1609
+ "kind": "event",
1610
+ "rate": 0.8
1611
+ }
1612
+ ]
1613
+ }
1614
+ }
1615
+ ]
1616
+ },
1617
+ "dlq-operacao": {
1618
+ "title": "A DLQ na operação",
1619
+ "summary": "O que acontece com uma mensagem que esgotou as tentativas.",
1620
+ "legend": [
1621
+ "poison",
1622
+ "req"
1623
+ ],
1624
+ "defs": {
1625
+ "entities": {
1626
+ "q": {
1627
+ "type": "block",
1628
+ "x": -10,
1629
+ "y": 0,
1630
+ "s": 3.2,
1631
+ "h": 34,
1632
+ "color": "rose",
1633
+ "glyph": "archive",
1634
+ "label": [
1635
+ "DLQ"
1636
+ ]
1637
+ },
1638
+ "al": {
1639
+ "type": "block",
1640
+ "x": 0,
1641
+ "y": 0,
1642
+ "s": 3.4,
1643
+ "h": 40,
1644
+ "color": "rose",
1645
+ "glyph": "bell",
1646
+ "label": [
1647
+ "Alerta"
1648
+ ],
1649
+ "sub": "#plantao"
1650
+ },
1651
+ "op": {
1652
+ "type": "device",
1653
+ "x": 10,
1654
+ "y": 0,
1655
+ "label": "plantão"
1656
+ }
1657
+ },
1658
+ "links": {
1659
+ "qa": {
1660
+ "from": "q",
1661
+ "to": "al",
1662
+ "label": "5 falhas"
1663
+ },
1664
+ "ao": {
1665
+ "from": "al",
1666
+ "to": "op",
1667
+ "label": "notifica"
1668
+ },
1669
+ "oq": {
1670
+ "from": "op",
1671
+ "to": "q",
1672
+ "label": "reprocessar",
1673
+ "pts": [
1674
+ "op",
1675
+ [
1676
+ "op",
1677
+ "q-5"
1678
+ ],
1679
+ [
1680
+ "q",
1681
+ "q-5"
1682
+ ],
1683
+ "q"
1684
+ ],
1685
+ "style": "dashed"
1686
+ }
1687
+ }
1688
+ },
1689
+ "steps": [
1690
+ {
1691
+ "short": "Alerta",
1692
+ "chapter": "failure",
1693
+ "title": "Chegou na DLQ, alguém fica sabendo",
1694
+ "body": [
1695
+ "Cada mensagem que entra na DLQ dispara um alerta no canal de plantão com o id do pedido e o último erro."
1696
+ ],
1697
+ "scene": {
1698
+ "entities": {
1699
+ "q": "q",
1700
+ "al": "al",
1701
+ "op": "op"
1702
+ },
1703
+ "links": {
1704
+ "qa": "qa",
1705
+ "ao": "ao"
1706
+ },
1707
+ "flows": [
1708
+ {
1709
+ "route": [
1710
+ "qa",
1711
+ "ao"
1712
+ ],
1713
+ "kind": "poison",
1714
+ "rate": 0.6
1715
+ }
1716
+ ]
1717
+ }
1718
+ },
1719
+ {
1720
+ "short": "Reprocesso",
1721
+ "chapter": "decision",
1722
+ "title": "O reprocesso ainda é manual",
1723
+ "body": [
1724
+ "O plantão corrige a causa (ex.: PSP fora) e reprocessa pelo painel. Automatizar isso é o próximo passo do ADR-007."
1725
+ ],
1726
+ "scene": {
1727
+ "links": {
1728
+ "oq": "oq"
1729
+ },
1730
+ "flows": [
1731
+ {
1732
+ "route": [
1733
+ "oq"
1734
+ ],
1735
+ "rate": 0.6
1736
+ }
1737
+ ]
1738
+ }
1739
+ }
1740
+ ]
1741
+ }
1742
+ }
1743
+ }