@jarrodmedrano/claude-skills 1.0.3 → 1.0.5
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.
- package/.claude/skills/bevy/SKILL.md +406 -0
- package/.claude/skills/bevy/references/bevy_specific_tips.md +385 -0
- package/.claude/skills/bevy/references/common_pitfalls.md +217 -0
- package/.claude/skills/bevy/references/ecs_patterns.md +277 -0
- package/.claude/skills/bevy/references/project_structure.md +116 -0
- package/.claude/skills/bevy/references/ui_development.md +147 -0
- package/.claude/skills/domain-driven-design/SKILL.md +459 -0
- package/.claude/skills/domain-driven-design/references/ddd_foundations_and_patterns.md +664 -0
- package/.claude/skills/domain-driven-design/references/rich_hickey_principles.md +406 -0
- package/.claude/skills/domain-driven-design/references/visualization_examples.md +790 -0
- package/.claude/skills/domain-driven-design/references/wlaschin_patterns.md +639 -0
- package/.claude/skills/godot/SKILL.md +728 -0
- package/.claude/skills/godot/assets/templates/attribute_template.gd +109 -0
- package/.claude/skills/godot/assets/templates/component_template.gd +76 -0
- package/.claude/skills/godot/assets/templates/interaction_template.gd +108 -0
- package/.claude/skills/godot/assets/templates/item_resource.tres +11 -0
- package/.claude/skills/godot/assets/templates/spell_resource.tres +20 -0
- package/.claude/skills/godot/references/architecture-patterns.md +608 -0
- package/.claude/skills/godot/references/common-pitfalls.md +518 -0
- package/.claude/skills/godot/references/file-formats.md +491 -0
- package/.claude/skills/godot/references/godot4-physics-api.md +302 -0
- package/.claude/skills/godot/scripts/validate_tres.py +145 -0
- package/.claude/skills/godot/scripts/validate_tscn.py +170 -0
- package/.claude/skills/guitar-fretboard-mastery/SKILL.md +179 -0
- package/.claude/skills/guitar-fretboard-mastery/guitar-fretboard-mastery.skill +0 -0
- package/.claude/skills/react-three-fiber/SKILL.md +2055 -0
- package/.claude/skills/react-three-fiber/scripts/build-scene.ts +171 -0
- package/package.json +1 -1
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
# Domain Modeling Visualization Examples
|
|
2
|
+
|
|
3
|
+
This reference provides comprehensive examples of using Mermaid, Graphviz/DOT, and ASCII diagrams for domain modeling visualization.
|
|
4
|
+
|
|
5
|
+
## When to Use Each Format
|
|
6
|
+
|
|
7
|
+
| Format | Best For | Strengths | Limitations |
|
|
8
|
+
|--------|----------|-----------|-------------|
|
|
9
|
+
| **Mermaid** | Quick diagrams, workflows, state machines | Easy syntax, widely supported, good for communication | Limited layout control |
|
|
10
|
+
| **Graphviz/DOT** | Complex relationships, dependency graphs | Powerful layout algorithms, precise control | More verbose syntax |
|
|
11
|
+
| **ASCII** | Quick sketches, simple hierarchies, inline docs | Immediately readable in any editor, minimal | Limited visual appeal, simple structures only |
|
|
12
|
+
|
|
13
|
+
## Mermaid Diagrams
|
|
14
|
+
|
|
15
|
+
### Class Diagrams for Domain Entities
|
|
16
|
+
|
|
17
|
+
**Use for:** Showing entity relationships and structure
|
|
18
|
+
|
|
19
|
+
```mermaid
|
|
20
|
+
classDiagram
|
|
21
|
+
Customer "1" --> "*" Order : places
|
|
22
|
+
Order "1" --> "*" OrderLine : contains
|
|
23
|
+
OrderLine "*" --> "1" Product : references
|
|
24
|
+
Order "1" --> "1" PaymentStatus : has
|
|
25
|
+
|
|
26
|
+
class Customer {
|
|
27
|
+
+CustomerId id
|
|
28
|
+
+EmailAddress email
|
|
29
|
+
+CustomerName name
|
|
30
|
+
+MembershipLevel level
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Order {
|
|
34
|
+
+OrderId id
|
|
35
|
+
+CustomerId customerId
|
|
36
|
+
+List~OrderLine~ lines
|
|
37
|
+
+PaymentStatus status
|
|
38
|
+
+Timestamp createdAt
|
|
39
|
+
+calculateTotal() Money
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class OrderLine {
|
|
43
|
+
+ProductId productId
|
|
44
|
+
+Quantity quantity
|
|
45
|
+
+Money unitPrice
|
|
46
|
+
+calculateSubtotal() Money
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class Product {
|
|
50
|
+
+ProductId id
|
|
51
|
+
+ProductName name
|
|
52
|
+
+Money price
|
|
53
|
+
+Category category
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class PaymentStatus {
|
|
57
|
+
<<enumeration>>
|
|
58
|
+
Pending
|
|
59
|
+
Approved
|
|
60
|
+
Rejected
|
|
61
|
+
Refunded
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**With generics and constraints:**
|
|
66
|
+
|
|
67
|
+
```mermaid
|
|
68
|
+
classDiagram
|
|
69
|
+
class Result~T, E~ {
|
|
70
|
+
<<interface>>
|
|
71
|
+
+isOk() boolean
|
|
72
|
+
+isErr() boolean
|
|
73
|
+
+map(fn) Result~U, E~
|
|
74
|
+
+flatMap(fn) Result~U, E~
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
class Ok~T~ {
|
|
78
|
+
+value T
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class Err~E~ {
|
|
82
|
+
+error E
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
Result~T, E~ <|-- Ok~T~
|
|
86
|
+
Result~T, E~ <|-- Err~E~
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Flowcharts for Business Workflows
|
|
90
|
+
|
|
91
|
+
**Use for:** Showing decision points and process flow
|
|
92
|
+
|
|
93
|
+
```mermaid
|
|
94
|
+
flowchart TD
|
|
95
|
+
Start([Receive Order Request]) --> Parse[Parse Request]
|
|
96
|
+
Parse --> Valid{Valid Format?}
|
|
97
|
+
Valid -->|No| ReturnError[Return 400 Bad Request]
|
|
98
|
+
Valid -->|Yes| Validate[Validate Business Rules]
|
|
99
|
+
|
|
100
|
+
Validate --> Rules{Rules Pass?}
|
|
101
|
+
Rules -->|No| ReturnValidation[Return Validation Errors]
|
|
102
|
+
Rules -->|Yes| CheckInventory[Check Inventory]
|
|
103
|
+
|
|
104
|
+
CheckInventory --> InStock{In Stock?}
|
|
105
|
+
InStock -->|No| OutOfStock[Return Out of Stock Error]
|
|
106
|
+
InStock -->|Yes| CalculatePrice[Calculate Price]
|
|
107
|
+
|
|
108
|
+
CalculatePrice --> ProcessPayment[Process Payment]
|
|
109
|
+
ProcessPayment --> PaymentOk{Payment Success?}
|
|
110
|
+
|
|
111
|
+
PaymentOk -->|No| PaymentError[Return Payment Error]
|
|
112
|
+
PaymentOk -->|Yes| CreateOrder[Create Order Record]
|
|
113
|
+
|
|
114
|
+
CreateOrder --> SendConfirmation[Send Confirmation Email]
|
|
115
|
+
SendConfirmation --> End([Return 201 Created])
|
|
116
|
+
|
|
117
|
+
ReturnError --> End
|
|
118
|
+
ReturnValidation --> End
|
|
119
|
+
OutOfStock --> End
|
|
120
|
+
PaymentError --> End
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Railway-oriented programming pattern:**
|
|
124
|
+
|
|
125
|
+
```mermaid
|
|
126
|
+
flowchart LR
|
|
127
|
+
Input[Unvalidated Order] --> Validate
|
|
128
|
+
Validate --> ValidResult{Result}
|
|
129
|
+
ValidResult -->|Ok| Price[Price Order]
|
|
130
|
+
ValidResult -->|Err| Error1[Validation Error]
|
|
131
|
+
|
|
132
|
+
Price --> PriceResult{Result}
|
|
133
|
+
PriceResult -->|Ok| Save[Save Order]
|
|
134
|
+
PriceResult -->|Err| Error2[Pricing Error]
|
|
135
|
+
|
|
136
|
+
Save --> SaveResult{Result}
|
|
137
|
+
SaveResult -->|Ok| Notify[Send Notification]
|
|
138
|
+
SaveResult -->|Err| Error3[Database Error]
|
|
139
|
+
|
|
140
|
+
Notify --> Success[Order Placed]
|
|
141
|
+
|
|
142
|
+
Error1 --> ErrorHandler[Handle Error]
|
|
143
|
+
Error2 --> ErrorHandler
|
|
144
|
+
Error3 --> ErrorHandler
|
|
145
|
+
ErrorHandler --> FailureOutput[Error Response]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### State Diagrams for Lifecycle Modeling
|
|
149
|
+
|
|
150
|
+
**Use for:** Showing valid state transitions
|
|
151
|
+
|
|
152
|
+
```mermaid
|
|
153
|
+
stateDiagram-v2
|
|
154
|
+
[*] --> Draft
|
|
155
|
+
|
|
156
|
+
Draft --> Submitted : submit()
|
|
157
|
+
Draft --> Abandoned : timeout()
|
|
158
|
+
|
|
159
|
+
Submitted --> UnderReview : startReview()
|
|
160
|
+
|
|
161
|
+
UnderReview --> Approved : approve()
|
|
162
|
+
UnderReview --> Rejected : reject()
|
|
163
|
+
UnderReview --> NeedsRevision : requestChanges()
|
|
164
|
+
|
|
165
|
+
NeedsRevision --> Submitted : resubmit()
|
|
166
|
+
NeedsRevision --> Abandoned : cancel()
|
|
167
|
+
|
|
168
|
+
Approved --> Published : publish()
|
|
169
|
+
Approved --> Archived : archive()
|
|
170
|
+
|
|
171
|
+
Rejected --> [*]
|
|
172
|
+
Abandoned --> [*]
|
|
173
|
+
Published --> Archived : archive()
|
|
174
|
+
Archived --> [*]
|
|
175
|
+
|
|
176
|
+
note right of UnderReview
|
|
177
|
+
Review must complete
|
|
178
|
+
within 48 hours
|
|
179
|
+
end note
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**With nested states:**
|
|
183
|
+
|
|
184
|
+
```mermaid
|
|
185
|
+
stateDiagram-v2
|
|
186
|
+
[*] --> Active
|
|
187
|
+
|
|
188
|
+
state Active {
|
|
189
|
+
[*] --> Free
|
|
190
|
+
Free --> Trial : startTrial()
|
|
191
|
+
Trial --> Paid : subscribe()
|
|
192
|
+
Trial --> Free : trialExpires()
|
|
193
|
+
Paid --> Free : cancel()
|
|
194
|
+
|
|
195
|
+
state Paid {
|
|
196
|
+
[*] --> Monthly
|
|
197
|
+
Monthly --> Annual : upgrade()
|
|
198
|
+
Annual --> Monthly : downgrade()
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
Active --> Suspended : suspend()
|
|
203
|
+
Suspended --> Active : reactivate()
|
|
204
|
+
Suspended --> Closed : permanentClose()
|
|
205
|
+
Active --> Closed : closeAccount()
|
|
206
|
+
Closed --> [*]
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Sequence Diagrams for Interactions
|
|
210
|
+
|
|
211
|
+
**Use for:** Showing message flow between components
|
|
212
|
+
|
|
213
|
+
```mermaid
|
|
214
|
+
sequenceDiagram
|
|
215
|
+
participant Client
|
|
216
|
+
participant API
|
|
217
|
+
participant Domain
|
|
218
|
+
participant DB
|
|
219
|
+
participant EmailService
|
|
220
|
+
|
|
221
|
+
Client->>API: POST /orders
|
|
222
|
+
API->>API: Parse request
|
|
223
|
+
API->>Domain: validateOrder(data)
|
|
224
|
+
Domain-->>API: Result<ValidatedOrder>
|
|
225
|
+
|
|
226
|
+
alt validation failed
|
|
227
|
+
API-->>Client: 400 Bad Request
|
|
228
|
+
else validation succeeded
|
|
229
|
+
API->>Domain: priceOrder(validatedOrder)
|
|
230
|
+
Domain-->>API: PricedOrder
|
|
231
|
+
|
|
232
|
+
API->>DB: saveOrder(pricedOrder)
|
|
233
|
+
DB-->>API: OrderId
|
|
234
|
+
|
|
235
|
+
API->>EmailService: sendConfirmation(orderId)
|
|
236
|
+
EmailService-->>API: Async confirmation
|
|
237
|
+
|
|
238
|
+
API-->>Client: 201 Created
|
|
239
|
+
end
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Entity Relationship Diagrams
|
|
243
|
+
|
|
244
|
+
**Use for:** Database schema or aggregate boundaries
|
|
245
|
+
|
|
246
|
+
```mermaid
|
|
247
|
+
erDiagram
|
|
248
|
+
CUSTOMER ||--o{ ORDER : places
|
|
249
|
+
ORDER ||--|{ ORDER_LINE : contains
|
|
250
|
+
PRODUCT ||--o{ ORDER_LINE : "ordered in"
|
|
251
|
+
ORDER ||--|| PAYMENT : requires
|
|
252
|
+
PAYMENT ||--|| PAYMENT_METHOD : uses
|
|
253
|
+
|
|
254
|
+
CUSTOMER {
|
|
255
|
+
uuid id PK
|
|
256
|
+
string email
|
|
257
|
+
string name
|
|
258
|
+
enum membership_level
|
|
259
|
+
timestamp created_at
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
ORDER {
|
|
263
|
+
uuid id PK
|
|
264
|
+
uuid customer_id FK
|
|
265
|
+
enum status
|
|
266
|
+
decimal total
|
|
267
|
+
timestamp created_at
|
|
268
|
+
timestamp updated_at
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
ORDER_LINE {
|
|
272
|
+
uuid id PK
|
|
273
|
+
uuid order_id FK
|
|
274
|
+
uuid product_id FK
|
|
275
|
+
int quantity
|
|
276
|
+
decimal unit_price
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
PRODUCT {
|
|
280
|
+
uuid id PK
|
|
281
|
+
string name
|
|
282
|
+
decimal price
|
|
283
|
+
enum category
|
|
284
|
+
int stock_quantity
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
PAYMENT {
|
|
288
|
+
uuid id PK
|
|
289
|
+
uuid order_id FK
|
|
290
|
+
uuid payment_method_id FK
|
|
291
|
+
decimal amount
|
|
292
|
+
enum status
|
|
293
|
+
timestamp processed_at
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Gantt Charts for Project Planning
|
|
298
|
+
|
|
299
|
+
**Use for:** Timeline and dependency visualization
|
|
300
|
+
|
|
301
|
+
```mermaid
|
|
302
|
+
gantt
|
|
303
|
+
title Domain Model Implementation Timeline
|
|
304
|
+
dateFormat YYYY-MM-DD
|
|
305
|
+
section Core Types
|
|
306
|
+
Define value objects :done, types1, 2024-01-01, 3d
|
|
307
|
+
Define entities :done, types2, after types1, 2d
|
|
308
|
+
Define aggregates :active, types3, after types2, 3d
|
|
309
|
+
|
|
310
|
+
section Validation
|
|
311
|
+
Input validation :valid1, after types3, 2d
|
|
312
|
+
Business rule validation :valid2, after valid1, 3d
|
|
313
|
+
|
|
314
|
+
section Workflows
|
|
315
|
+
Order placement workflow :wf1, after valid2, 5d
|
|
316
|
+
Payment workflow :wf2, after wf1, 4d
|
|
317
|
+
Fulfillment workflow :wf3, after wf2, 4d
|
|
318
|
+
|
|
319
|
+
section Testing
|
|
320
|
+
Unit tests :test1, after types1, 15d
|
|
321
|
+
Integration tests :test2, after wf1, 10d
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Graphviz/DOT Diagrams
|
|
325
|
+
|
|
326
|
+
### Complex Dependency Graphs
|
|
327
|
+
|
|
328
|
+
**Use for:** Module dependencies, complex relationships
|
|
329
|
+
|
|
330
|
+
```dot
|
|
331
|
+
digraph dependencies {
|
|
332
|
+
rankdir=LR;
|
|
333
|
+
node [shape=box, style=rounded];
|
|
334
|
+
|
|
335
|
+
// Layers
|
|
336
|
+
subgraph cluster_domain {
|
|
337
|
+
label="Domain Layer";
|
|
338
|
+
style=filled;
|
|
339
|
+
color=lightblue;
|
|
340
|
+
|
|
341
|
+
types [label="Domain Types"];
|
|
342
|
+
validation [label="Validation"];
|
|
343
|
+
logic [label="Business Logic"];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
subgraph cluster_application {
|
|
347
|
+
label="Application Layer";
|
|
348
|
+
style=filled;
|
|
349
|
+
color=lightgreen;
|
|
350
|
+
|
|
351
|
+
workflows [label="Workflows"];
|
|
352
|
+
commands [label="Commands"];
|
|
353
|
+
queries [label="Queries"];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
subgraph cluster_infrastructure {
|
|
357
|
+
label="Infrastructure Layer";
|
|
358
|
+
style=filled;
|
|
359
|
+
color=lightgrey;
|
|
360
|
+
|
|
361
|
+
db [label="Database"];
|
|
362
|
+
http [label="HTTP Client"];
|
|
363
|
+
email [label="Email Service"];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Dependencies
|
|
367
|
+
validation -> types;
|
|
368
|
+
logic -> types;
|
|
369
|
+
logic -> validation;
|
|
370
|
+
|
|
371
|
+
workflows -> logic;
|
|
372
|
+
workflows -> validation;
|
|
373
|
+
commands -> workflows;
|
|
374
|
+
queries -> workflows;
|
|
375
|
+
|
|
376
|
+
workflows -> db [style=dashed, label="port"];
|
|
377
|
+
workflows -> http [style=dashed, label="port"];
|
|
378
|
+
workflows -> email [style=dashed, label="port"];
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Aggregate Boundaries
|
|
383
|
+
|
|
384
|
+
**Use for:** DDD aggregates and bounded contexts
|
|
385
|
+
|
|
386
|
+
```dot
|
|
387
|
+
digraph aggregates {
|
|
388
|
+
rankdir=TB;
|
|
389
|
+
node [shape=box];
|
|
390
|
+
|
|
391
|
+
subgraph cluster_order_aggregate {
|
|
392
|
+
label="Order Aggregate";
|
|
393
|
+
style=filled;
|
|
394
|
+
color=lightblue;
|
|
395
|
+
|
|
396
|
+
Order [shape=box, style="rounded,filled", fillcolor=gold, label="Order\n(Root)"];
|
|
397
|
+
OrderLine [label="OrderLine"];
|
|
398
|
+
ShippingAddress [label="ShippingAddress"];
|
|
399
|
+
|
|
400
|
+
Order -> OrderLine [label="contains"];
|
|
401
|
+
Order -> ShippingAddress [label="has"];
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
subgraph cluster_customer_aggregate {
|
|
405
|
+
label="Customer Aggregate";
|
|
406
|
+
style=filled;
|
|
407
|
+
color=lightgreen;
|
|
408
|
+
|
|
409
|
+
Customer [shape=box, style="rounded,filled", fillcolor=gold, label="Customer\n(Root)"];
|
|
410
|
+
Address [label="Address"];
|
|
411
|
+
|
|
412
|
+
Customer -> Address [label="has many"];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
subgraph cluster_product_aggregate {
|
|
416
|
+
label="Product Aggregate";
|
|
417
|
+
style=filled;
|
|
418
|
+
color=lightyellow;
|
|
419
|
+
|
|
420
|
+
Product [shape=box, style="rounded,filled", fillcolor=gold, label="Product\n(Root)"];
|
|
421
|
+
Price [label="Price"];
|
|
422
|
+
Inventory [label="Inventory"];
|
|
423
|
+
|
|
424
|
+
Product -> Price [label="has"];
|
|
425
|
+
Product -> Inventory [label="tracks"];
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// Cross-aggregate references (by ID only)
|
|
429
|
+
Order -> Customer [style=dashed, label="customerId"];
|
|
430
|
+
OrderLine -> Product [style=dashed, label="productId"];
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Layered Architecture
|
|
435
|
+
|
|
436
|
+
**Use for:** Showing architectural layers and flow
|
|
437
|
+
|
|
438
|
+
```dot
|
|
439
|
+
digraph architecture {
|
|
440
|
+
rankdir=TB;
|
|
441
|
+
node [shape=box, width=3];
|
|
442
|
+
|
|
443
|
+
subgraph cluster_presentation {
|
|
444
|
+
label="Presentation Layer";
|
|
445
|
+
style=filled;
|
|
446
|
+
color=lightblue;
|
|
447
|
+
API [label="REST API"];
|
|
448
|
+
WebUI [label="Web UI"];
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
subgraph cluster_application {
|
|
452
|
+
label="Application Layer";
|
|
453
|
+
style=filled;
|
|
454
|
+
color=lightgreen;
|
|
455
|
+
Workflows [label="Workflows & Use Cases"];
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
subgraph cluster_domain {
|
|
459
|
+
label="Domain Layer";
|
|
460
|
+
style=filled;
|
|
461
|
+
color=gold;
|
|
462
|
+
DomainLogic [label="Domain Logic"];
|
|
463
|
+
DomainTypes [label="Domain Types"];
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
subgraph cluster_infrastructure {
|
|
467
|
+
label="Infrastructure Layer";
|
|
468
|
+
style=filled;
|
|
469
|
+
color=lightgrey;
|
|
470
|
+
Database [label="Database"];
|
|
471
|
+
ExternalAPIs [label="External APIs"];
|
|
472
|
+
MessageQueue [label="Message Queue"];
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
API -> Workflows;
|
|
476
|
+
WebUI -> Workflows;
|
|
477
|
+
Workflows -> DomainLogic;
|
|
478
|
+
DomainLogic -> DomainTypes;
|
|
479
|
+
Workflows -> Database [style=dashed];
|
|
480
|
+
Workflows -> ExternalAPIs [style=dashed];
|
|
481
|
+
Workflows -> MessageQueue [style=dashed];
|
|
482
|
+
|
|
483
|
+
{rank=same; API; WebUI}
|
|
484
|
+
{rank=same; Database; ExternalAPIs; MessageQueue}
|
|
485
|
+
}
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Data Flow Diagrams
|
|
489
|
+
|
|
490
|
+
**Use for:** Showing how data moves through the system
|
|
491
|
+
|
|
492
|
+
```dot
|
|
493
|
+
digraph dataflow {
|
|
494
|
+
rankdir=LR;
|
|
495
|
+
node [shape=circle];
|
|
496
|
+
|
|
497
|
+
Input [label="External\nInput"];
|
|
498
|
+
Parse [label="Parse"];
|
|
499
|
+
Validate [label="Validate"];
|
|
500
|
+
Transform [label="Transform"];
|
|
501
|
+
Execute [label="Execute\nLogic"];
|
|
502
|
+
Persist [label="Persist"];
|
|
503
|
+
Output [label="External\nOutput"];
|
|
504
|
+
|
|
505
|
+
Input -> Parse [label="raw data"];
|
|
506
|
+
Parse -> Validate [label="structured data"];
|
|
507
|
+
Validate -> Transform [label="validated data"];
|
|
508
|
+
Transform -> Execute [label="domain types"];
|
|
509
|
+
Execute -> Persist [label="results"];
|
|
510
|
+
Persist -> Output [label="response"];
|
|
511
|
+
|
|
512
|
+
// Error paths
|
|
513
|
+
Parse -> Output [label="parse error", style=dashed, color=red];
|
|
514
|
+
Validate -> Output [label="validation error", style=dashed, color=red];
|
|
515
|
+
Execute -> Output [label="business error", style=dashed, color=red];
|
|
516
|
+
Persist -> Output [label="persistence error", style=dashed, color=red];
|
|
517
|
+
}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
## ASCII Diagrams
|
|
521
|
+
|
|
522
|
+
### Simple Hierarchies
|
|
523
|
+
|
|
524
|
+
**Use for:** Quick sketches, documentation, inline comments
|
|
525
|
+
|
|
526
|
+
```
|
|
527
|
+
Domain Model Hierarchy
|
|
528
|
+
======================
|
|
529
|
+
|
|
530
|
+
Order (Aggregate Root)
|
|
531
|
+
├─> OrderId (Value Object)
|
|
532
|
+
├─> CustomerId (Value Object)
|
|
533
|
+
├─> OrderStatus (Enum)
|
|
534
|
+
│ ├─ Draft
|
|
535
|
+
│ ├─ Submitted
|
|
536
|
+
│ ├─ Approved
|
|
537
|
+
│ └─ Fulfilled
|
|
538
|
+
├─> OrderLines (Collection)
|
|
539
|
+
│ └─> OrderLine
|
|
540
|
+
│ ├─> ProductId
|
|
541
|
+
│ ├─> Quantity
|
|
542
|
+
│ └─> UnitPrice
|
|
543
|
+
└─> PaymentInfo
|
|
544
|
+
├─> PaymentMethod
|
|
545
|
+
└─> PaymentStatus
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Relationships
|
|
549
|
+
|
|
550
|
+
```
|
|
551
|
+
Customer Relationships
|
|
552
|
+
=====================
|
|
553
|
+
|
|
554
|
+
Customer (1) ────places────> (*) Order
|
|
555
|
+
│
|
|
556
|
+
├── contains ──> (*) OrderLine
|
|
557
|
+
│ │
|
|
558
|
+
│ └── references ──> (1) Product
|
|
559
|
+
│
|
|
560
|
+
└── requires ──> (1) Payment
|
|
561
|
+
│
|
|
562
|
+
└── uses ──> (1) PaymentMethod
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
### State Transitions
|
|
566
|
+
|
|
567
|
+
```
|
|
568
|
+
Order Lifecycle
|
|
569
|
+
===============
|
|
570
|
+
|
|
571
|
+
┌───────┐
|
|
572
|
+
│ Draft │
|
|
573
|
+
└───┬───┘
|
|
574
|
+
│ submit()
|
|
575
|
+
v
|
|
576
|
+
┌─────────┐
|
|
577
|
+
│Submitted│
|
|
578
|
+
└────┬────┘
|
|
579
|
+
│
|
|
580
|
+
├── approve() ────> ┌────────┐
|
|
581
|
+
│ │Approved│
|
|
582
|
+
│ └────┬───┘
|
|
583
|
+
│ │ fulfill()
|
|
584
|
+
│ v
|
|
585
|
+
│ ┌─────────┐
|
|
586
|
+
│ │Fulfilled│────> [END]
|
|
587
|
+
│ └─────────┘
|
|
588
|
+
│
|
|
589
|
+
└── reject() ─────> ┌────────┐
|
|
590
|
+
│Rejected│────> [END]
|
|
591
|
+
└────────┘
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
### Data Flow
|
|
595
|
+
|
|
596
|
+
```
|
|
597
|
+
Order Placement Pipeline
|
|
598
|
+
========================
|
|
599
|
+
|
|
600
|
+
Unvalidated Validated Priced Saved
|
|
601
|
+
Order => Order => Order => Order => Event
|
|
602
|
+
│ │ │ │ │
|
|
603
|
+
└─ validate() ──┘ │ │ │
|
|
604
|
+
└─ priceOrder() ┘ │ │
|
|
605
|
+
└─ saveOrder() ─┘ │
|
|
606
|
+
└─ notify() ┘
|
|
607
|
+
|
|
608
|
+
Errors:
|
|
609
|
+
ValidationError ─┐
|
|
610
|
+
PricingError ────├──> ErrorHandler ──> ErrorResponse
|
|
611
|
+
DatabaseError ───┘
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
### Component Boxes
|
|
615
|
+
|
|
616
|
+
```
|
|
617
|
+
┌─────────────────────────────────────────────┐
|
|
618
|
+
│ Order Management Domain │
|
|
619
|
+
├─────────────────────────────────────────────┤
|
|
620
|
+
│ │
|
|
621
|
+
│ ┌──────────────┐ ┌─────────────────┐ │
|
|
622
|
+
│ │ Commands │ │ Queries │ │
|
|
623
|
+
│ ├──────────────┤ ├─────────────────┤ │
|
|
624
|
+
│ │ PlaceOrder │ │ GetOrder │ │
|
|
625
|
+
│ │ CancelOrder │ │ ListOrders │ │
|
|
626
|
+
│ │ ApproveOrder │ │ GetOrderHistory │ │
|
|
627
|
+
│ └──────────────┘ └─────────────────┘ │
|
|
628
|
+
│ │ │ │
|
|
629
|
+
│ v v │
|
|
630
|
+
│ ┌──────────────────────────────────────┐ │
|
|
631
|
+
│ │ Domain Logic │ │
|
|
632
|
+
│ │ ┌────────────┐ ┌───────────────┐ │ │
|
|
633
|
+
│ │ │ Validation │ │ Business Rules│ │ │
|
|
634
|
+
│ │ └────────────┘ └───────────────┘ │ │
|
|
635
|
+
│ └──────────────────────────────────────┘ │
|
|
636
|
+
│ │
|
|
637
|
+
└─────────────────────────────────────────────┘
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
### Matrix/Table Layouts
|
|
641
|
+
|
|
642
|
+
```
|
|
643
|
+
State Transition Matrix
|
|
644
|
+
=======================
|
|
645
|
+
|
|
646
|
+
From/To │ Draft │ Submitted │ Approved │ Rejected │ Fulfilled
|
|
647
|
+
────────────┼───────┼───────────┼──────────┼──────────┼──────────
|
|
648
|
+
Draft │ - │ Yes │ No │ No │ No
|
|
649
|
+
Submitted │ No │ - │ Yes │ Yes │ No
|
|
650
|
+
Approved │ No │ No │ - │ No │ Yes
|
|
651
|
+
Rejected │ No │ No │ No │ - │ No
|
|
652
|
+
Fulfilled │ No │ No │ No │ No │ -
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
### Layered Architecture
|
|
656
|
+
|
|
657
|
+
```
|
|
658
|
+
Layered Architecture
|
|
659
|
+
====================
|
|
660
|
+
|
|
661
|
+
┌────────────────────────────────────────┐
|
|
662
|
+
│ Presentation Layer (API) │ ← HTTP, JSON, Auth
|
|
663
|
+
├────────────────────────────────────────┤
|
|
664
|
+
│ Application Layer │ ← Workflows, Use Cases
|
|
665
|
+
│ ┌──────────────┐ ┌────────────────┐ │
|
|
666
|
+
│ │ Order Mgmt │ │ Customer Mgmt │ │
|
|
667
|
+
│ └──────────────┘ └────────────────┘ │
|
|
668
|
+
├────────────────────────────────────────┤
|
|
669
|
+
│ Domain Layer │ ← Pure Business Logic
|
|
670
|
+
│ ┌──────┐ ┌────────┐ ┌───────────┐ │
|
|
671
|
+
│ │Types │ │Validation│ │ Business │ │
|
|
672
|
+
│ │ │ │ │ │ Rules │ │
|
|
673
|
+
│ └──────┘ └────────┘ └───────────┘ │
|
|
674
|
+
├────────────────────────────────────────┤
|
|
675
|
+
│ Infrastructure Layer │ ← DB, External APIs
|
|
676
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────┐│
|
|
677
|
+
│ │ Database │ │ HTTP │ │Email ││
|
|
678
|
+
│ └──────────┘ └──────────┘ └──────┘│
|
|
679
|
+
└────────────────────────────────────────┘
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
## Choosing the Right Visualization
|
|
683
|
+
|
|
684
|
+
### Decision Matrix
|
|
685
|
+
|
|
686
|
+
| Need | Recommended Format | Reason |
|
|
687
|
+
|------|-------------------|---------|
|
|
688
|
+
| Show entity relationships | Mermaid classDiagram or ER diagram | Clear, standard notation |
|
|
689
|
+
| Show business workflow | Mermaid flowchart | Easy to follow decision paths |
|
|
690
|
+
| Show state machine | Mermaid stateDiagram | Built-in state diagram support |
|
|
691
|
+
| Show message flow | Mermaid sequence diagram | Temporal ordering clear |
|
|
692
|
+
| Show module dependencies | Graphviz/DOT | Better layout for complex graphs |
|
|
693
|
+
| Show architectural layers | Graphviz/DOT or ASCII | Clear separation of concerns |
|
|
694
|
+
| Quick sketch in docs | ASCII | Works everywhere, minimal |
|
|
695
|
+
| Inline code comments | ASCII (simple) | Readable in source code |
|
|
696
|
+
|
|
697
|
+
### Complexity Guidelines
|
|
698
|
+
|
|
699
|
+
**Simple (1-5 entities/states):**
|
|
700
|
+
- ASCII often sufficient
|
|
701
|
+
- Quick to create and modify
|
|
702
|
+
|
|
703
|
+
**Medium (6-15 entities/states):**
|
|
704
|
+
- Mermaid recommended
|
|
705
|
+
- Good balance of features and simplicity
|
|
706
|
+
|
|
707
|
+
**Complex (15+ entities/states):**
|
|
708
|
+
- Graphviz/DOT for maximum control
|
|
709
|
+
- Or break into multiple simpler diagrams
|
|
710
|
+
|
|
711
|
+
### Communication Context
|
|
712
|
+
|
|
713
|
+
**For developers:**
|
|
714
|
+
- Any format works
|
|
715
|
+
- Prefer precision over aesthetics
|
|
716
|
+
- Include technical details
|
|
717
|
+
|
|
718
|
+
**For stakeholders:**
|
|
719
|
+
- Mermaid flowcharts (intuitive)
|
|
720
|
+
- Avoid technical jargon in labels
|
|
721
|
+
- Focus on business concepts
|
|
722
|
+
|
|
723
|
+
**For documentation:**
|
|
724
|
+
- Mermaid (renders in Markdown viewers)
|
|
725
|
+
- ASCII for inline code comments
|
|
726
|
+
- Include both high-level and detailed views
|
|
727
|
+
|
|
728
|
+
## Tips and Best Practices
|
|
729
|
+
|
|
730
|
+
### General Principles
|
|
731
|
+
|
|
732
|
+
1. **Start simple** - Add complexity only as needed
|
|
733
|
+
2. **Use consistent naming** - Match code/domain language exactly
|
|
734
|
+
3. **Show relationships clearly** - Label edges meaningfully
|
|
735
|
+
4. **Group related concepts** - Use subgraphs/clusters
|
|
736
|
+
5. **Highlight important paths** - Use color/style for emphasis
|
|
737
|
+
6. **Keep it readable** - Don't cram too much in one diagram
|
|
738
|
+
|
|
739
|
+
### Mermaid Tips
|
|
740
|
+
|
|
741
|
+
- Use meaningful IDs (not just A, B, C)
|
|
742
|
+
- Add notes for important details
|
|
743
|
+
- Use subgraphs for grouping
|
|
744
|
+
- Set direction (TD, LR) for best layout
|
|
745
|
+
|
|
746
|
+
### Graphviz Tips
|
|
747
|
+
|
|
748
|
+
- Use `rankdir` to control flow direction
|
|
749
|
+
- Use `subgraph cluster_*` for grouping
|
|
750
|
+
- Use `style=filled` and `color` for visual hierarchy
|
|
751
|
+
- Use edge styles (solid, dashed, dotted) to show relationship types
|
|
752
|
+
|
|
753
|
+
### ASCII Tips
|
|
754
|
+
|
|
755
|
+
- Use box-drawing characters for cleaner look: ┌─┐│└┘├┤┬┴┼
|
|
756
|
+
- Keep lines aligned for readability
|
|
757
|
+
- Use indentation to show hierarchy
|
|
758
|
+
- Add whitespace for visual separation
|
|
759
|
+
|
|
760
|
+
### Version Control Friendly
|
|
761
|
+
|
|
762
|
+
All three formats are text-based and work well with git:
|
|
763
|
+
- Easy to diff
|
|
764
|
+
- Easy to review in PRs
|
|
765
|
+
- Easy to search
|
|
766
|
+
- No binary files to worry about
|
|
767
|
+
|
|
768
|
+
## Templates
|
|
769
|
+
|
|
770
|
+
### Quick Reference Template
|
|
771
|
+
|
|
772
|
+
```
|
|
773
|
+
Domain: [Domain Name]
|
|
774
|
+
====================
|
|
775
|
+
|
|
776
|
+
Key Entities:
|
|
777
|
+
- [Entity1]: [Brief description]
|
|
778
|
+
- [Entity2]: [Brief description]
|
|
779
|
+
|
|
780
|
+
Relationships:
|
|
781
|
+
[Entity1] ──> [Entity2]: [relationship description]
|
|
782
|
+
|
|
783
|
+
States:
|
|
784
|
+
[Entity] can be in: [State1] → [State2] → [State3]
|
|
785
|
+
|
|
786
|
+
Workflows:
|
|
787
|
+
1. [Workflow Name]: [Input] → [Step1] → [Step2] → [Output]
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
Use these visualization patterns to clearly communicate domain models and facilitate shared understanding among team members and stakeholders.
|