@wipal/agent-team 1.0.3 → 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.
- package/.claude/commands/skills/discover.md +127 -0
- package/.claude/commands/skills/install.md +225 -0
- package/.claude/commands/skills/review.md +234 -0
- package/.claude/commands/utils/learn.md +142 -0
- package/.claude/commands/utils/retrospect.md +62 -0
- package/.claude/commands/utils/switch.md +113 -0
- package/.claude/commands/utils/sync.md +183 -0
- package/.claude/rules/common/general-rules.md +6 -0
- package/.claude/rules/role-rules/dev-be-rules.md +241 -0
- package/.claude/rules/role-rules/dev-fe-rules.md +76 -0
- package/.claude/skills/SKILL-INDEX.md +24 -5
- package/.claude/skills/core/knowledge-graph/SKILL.md +214 -0
- package/.claude/skills/core/sequential-thinking/SKILL.md +112 -0
- package/.claude/skills/core/sequential-thinking/references/advanced.md +122 -0
- package/.claude/skills/core/sequential-thinking/references/examples.md +274 -0
- package/.claude/skills/domain/architecture/c4-architecture/SKILL.md +314 -0
- package/.claude/skills/domain/architecture/c4-architecture/references/advanced-patterns.md +552 -0
- package/.claude/skills/domain/architecture/c4-architecture/references/c4-syntax.md +492 -0
- package/.claude/skills/domain/architecture/c4-architecture/references/common-mistakes.md +437 -0
- package/.claude/skills/domain/architecture/mermaid-diagrams/SKILL.md +238 -0
- package/.claude/skills/domain/architecture/mermaid-diagrams/references/advanced-features.md +556 -0
- package/.claude/skills/domain/architecture/mermaid-diagrams/references/architecture-diagrams.md +192 -0
- package/.claude/skills/domain/architecture/mermaid-diagrams/references/c4-diagrams.md +410 -0
- package/.claude/skills/domain/architecture/mermaid-diagrams/references/class-diagrams.md +361 -0
- package/.claude/skills/domain/architecture/mermaid-diagrams/references/erd-diagrams.md +510 -0
- package/.claude/skills/domain/architecture/mermaid-diagrams/references/flowcharts.md +450 -0
- package/.claude/skills/domain/architecture/mermaid-diagrams/references/sequence-diagrams.md +394 -0
- package/.claude/skills/domain/backend/testing-be/SKILL.md +121 -17
- package/.claude/skills/domain/design/design-system/SKILL.md +169 -0
- package/.claude/skills/domain/design/html-css-output/SKILL.md +253 -0
- package/.claude/skills/domain/design/mockup-creation/SKILL.md +230 -0
- package/.claude/skills/domain/design/responsive-design/SKILL.md +207 -0
- package/.claude/skills/domain/design/ui-design/SKILL.md +124 -0
- package/.claude/skills/domain/frontend/testing-fe/SKILL.md +143 -38
- package/.claude/skills/domain/frontend/ui-ux-pro-max/README.md +45 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/SKILL.md +404 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/charts.csv +26 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/colors.csv +97 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/icons.csv +101 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/landing.csv +31 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/products.csv +97 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/styles.csv +68 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/typography.csv +58 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/scripts/core.py +253 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.claude/skills/domain/frontend/ui-ux-pro-max/scripts/search.py +114 -0
- package/.claude/skills/domain/product/requirements-clarity/SKILL.md +340 -0
- package/.claude/skills/skills-registry.yaml +103 -8
- package/README.md +107 -33
- package/README.npm.md +252 -0
- package/TUTORIAL.md +256 -0
- package/bin/agent-team.js +26 -7
- package/config/roles.yaml +107 -0
- package/docs/01-architecture.md +699 -0
- package/docs/02-setup-guide.md +634 -0
- package/docs/03-skills-guide.md +628 -0
- package/docs/04-workflows.md +792 -0
- package/docs/05-model-strategy.md +550 -0
- package/docs/06-extend-guide.md +1226 -0
- package/docs/07-quick-reference.md +578 -0
- package/docs/08-skills-discovery.md +342 -0
- package/docs/README.md +134 -0
- package/docs/rqm.md +560 -0
- package/package.json +10 -4
- package/scripts/postinstall.js +46 -0
- package/src/commands/add.js +131 -67
- package/src/commands/init.js +419 -9
- package/src/commands/list.js +20 -16
- package/src/commands/projects.js +127 -0
- package/src/commands/setup-hooks.js +261 -0
- package/src/index.js +0 -1
- package/src/utils/file-utils.js +147 -50
- package/src/utils/global-registry.js +224 -0
- package/templates/CLAUDE.md.tmpl +128 -20
- package/templates/MEMORY.md.tmpl +119 -0
- package/templates/agent.md.tmpl +205 -0
- package/templates/code/nestjs-controller.ts.tmpl +49 -0
- package/templates/code/nestjs-dto.ts.tmpl +63 -0
- package/templates/code/nestjs-service.ts.tmpl +45 -0
- package/templates/code/react-component.tsx.tmpl +24 -0
- package/templates/code/react-hook.ts.tmpl +54 -0
- package/templates/code/test.spec.ts.tmpl +50 -0
- package/templates/code/vue-component.vue.tmpl +49 -0
- package/templates/code/vue-composable.ts.tmpl +54 -0
- package/templates/knowledge.md.tmpl +152 -17
- package/templates/meeting-notes.md.tmpl +110 -0
- package/templates/memory/hooks.memory.json +50 -0
- package/templates/memory/settings.memory.json +16 -0
- package/templates/reports/bug-report.md.tmpl +164 -0
- package/templates/reports/code-review.md.tmpl +201 -0
- package/templates/reports/sprint-report.md.tmpl +218 -0
- package/templates/roles/ba.md +53 -0
- package/templates/roles/designer.md +82 -0
- package/templates/roles/dev-be.md +49 -0
- package/templates/roles/dev-fe.md +49 -0
- package/templates/roles/devops.md +53 -0
- package/templates/roles/pm.md +49 -0
- package/templates/roles/qa.md +53 -0
- package/templates/roles/sa.md +49 -0
- package/templates/roles/tech-lead.md +132 -0
- package/templates/skills/memory/memory-status.md +78 -0
- package/templates/skills/memory/recall.md +160 -0
- package/templates/skills/memory/reflect.md +168 -0
- package/templates/skills/memory/remember.md +105 -0
- package/templates/tasks/lessons.md.tmpl +77 -0
- package/templates/tasks/todo.md.tmpl +53 -0
- package/src/commands/switch.js +0 -53
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
# Common C4 Model Mistakes to Avoid
|
|
2
|
+
|
|
3
|
+
This guide documents frequent anti-patterns and errors when creating C4 architecture diagrams, with examples of what to do instead.
|
|
4
|
+
|
|
5
|
+
## Abstraction Level Mistakes
|
|
6
|
+
|
|
7
|
+
### 1. Confusing Containers and Components
|
|
8
|
+
|
|
9
|
+
**The Problem:**
|
|
10
|
+
Containers are **deployable units** (applications, services, databases). Components are **non-deployable elements inside a container** (modules, classes, packages).
|
|
11
|
+
|
|
12
|
+
**Wrong - Java class shown as container:**
|
|
13
|
+
```mermaid
|
|
14
|
+
C4Container
|
|
15
|
+
title WRONG: Class as Container
|
|
16
|
+
|
|
17
|
+
Container(userController, "UserController", "Java Class", "Handles user requests")
|
|
18
|
+
Container(userService, "UserService", "Java Class", "Business logic")
|
|
19
|
+
ContainerDb(db, "Database", "PostgreSQL", "User data")
|
|
20
|
+
|
|
21
|
+
Rel(userController, userService, "Calls")
|
|
22
|
+
Rel(userService, db, "Queries")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Correct - Classes as components inside a container:**
|
|
26
|
+
```mermaid
|
|
27
|
+
C4Component
|
|
28
|
+
title CORRECT: Classes as Components
|
|
29
|
+
|
|
30
|
+
ContainerDb(db, "Database", "PostgreSQL", "User data")
|
|
31
|
+
|
|
32
|
+
Container_Boundary(api, "User API Service") {
|
|
33
|
+
Component(userController, "UserController", "Spring MVC", "REST endpoints")
|
|
34
|
+
Component(userService, "UserService", "Spring Bean", "Business logic")
|
|
35
|
+
Component(userRepo, "UserRepository", "JPA", "Data access")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Rel(userController, userService, "Calls")
|
|
39
|
+
Rel(userService, userRepo, "Uses")
|
|
40
|
+
Rel(userRepo, db, "Queries", "JDBC")
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Adding Undefined Abstraction Levels
|
|
44
|
+
|
|
45
|
+
**The Problem:**
|
|
46
|
+
C4 defines exactly four levels. Don't invent "subcomponents", "modules", or other arbitrary levels.
|
|
47
|
+
|
|
48
|
+
**Wrong:**
|
|
49
|
+
- Level 3.5: "Subcomponents"
|
|
50
|
+
- Level 2.5: "Microservice groups"
|
|
51
|
+
- Custom levels like "packages" or "modules"
|
|
52
|
+
|
|
53
|
+
**Correct:**
|
|
54
|
+
Stick to Person, Software System, Container, Component. If you need more detail, you're at Level 4 (Code) which should use UML class diagrams.
|
|
55
|
+
|
|
56
|
+
### 3. Vague Subsystems
|
|
57
|
+
|
|
58
|
+
**The Problem:**
|
|
59
|
+
"Subsystem" is ambiguous. Is it a system, container, or component?
|
|
60
|
+
|
|
61
|
+
**Wrong:**
|
|
62
|
+
```
|
|
63
|
+
Subsystem(orders, "Order Subsystem", "Handles orders")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Correct - Be specific:**
|
|
67
|
+
```
|
|
68
|
+
System(orderSystem, "Order System", "Handles order lifecycle")
|
|
69
|
+
# OR
|
|
70
|
+
Container(orderService, "Order Service", "Java", "Order processing API")
|
|
71
|
+
# OR
|
|
72
|
+
Component(orderProcessor, "Order Processor", "Spring Bean", "Order business logic")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Shared Libraries Mistake
|
|
76
|
+
|
|
77
|
+
**The Problem:**
|
|
78
|
+
Modeling a shared library as a container implies it's an independently running service. Libraries are copied into applications, not deployed separately.
|
|
79
|
+
|
|
80
|
+
**Wrong - Library as separate container:**
|
|
81
|
+
```mermaid
|
|
82
|
+
C4Container
|
|
83
|
+
title WRONG: Library as Container
|
|
84
|
+
|
|
85
|
+
Container(serviceA, "Service A", "Java")
|
|
86
|
+
Container(serviceB, "Service B", "Java")
|
|
87
|
+
Container(sharedLib, "Shared Utils Library", "Java", "Common utilities")
|
|
88
|
+
|
|
89
|
+
Rel(serviceA, sharedLib, "Uses")
|
|
90
|
+
Rel(serviceB, sharedLib, "Uses")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Correct - Show library within each service:**
|
|
94
|
+
```mermaid
|
|
95
|
+
C4Component
|
|
96
|
+
title CORRECT: Library in Each Service
|
|
97
|
+
|
|
98
|
+
Container_Boundary(serviceA, "Service A") {
|
|
99
|
+
Component(controllerA, "Controller", "Spring MVC")
|
|
100
|
+
Component(utilsA, "Shared Utils", "Java Library", "Bundled copy")
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Container_Boundary(serviceB, "Service B") {
|
|
104
|
+
Component(controllerB, "Controller", "Spring MVC")
|
|
105
|
+
Component(utilsB, "Shared Utils", "Java Library", "Bundled copy")
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Or simply omit the library from architecture diagrams since it's an implementation detail.
|
|
110
|
+
|
|
111
|
+
## Message Broker Mistakes
|
|
112
|
+
|
|
113
|
+
### Single Message Bus Anti-Pattern
|
|
114
|
+
|
|
115
|
+
**The Problem:**
|
|
116
|
+
Showing Kafka/RabbitMQ as a single container creates a misleading "hub and spoke" diagram that hides actual data flows.
|
|
117
|
+
|
|
118
|
+
**Wrong - Central message bus:**
|
|
119
|
+
```mermaid
|
|
120
|
+
C4Container
|
|
121
|
+
title WRONG: Central Message Bus
|
|
122
|
+
|
|
123
|
+
Container(orderSvc, "Order Service", "Java")
|
|
124
|
+
Container(inventorySvc, "Inventory Service", "Java")
|
|
125
|
+
Container(paymentSvc, "Payment Service", "Java")
|
|
126
|
+
ContainerQueue(kafka, "Kafka", "Event Streaming", "Message bus")
|
|
127
|
+
|
|
128
|
+
Rel(orderSvc, kafka, "Publishes/Subscribes")
|
|
129
|
+
Rel(inventorySvc, kafka, "Publishes/Subscribes")
|
|
130
|
+
Rel(paymentSvc, kafka, "Publishes/Subscribes")
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Correct - Individual topics:**
|
|
134
|
+
```mermaid
|
|
135
|
+
C4Container
|
|
136
|
+
title CORRECT: Individual Topics
|
|
137
|
+
|
|
138
|
+
Container(orderSvc, "Order Service", "Java", "Creates orders")
|
|
139
|
+
Container(inventorySvc, "Inventory Service", "Java", "Manages stock")
|
|
140
|
+
Container(paymentSvc, "Payment Service", "Java", "Processes payments")
|
|
141
|
+
|
|
142
|
+
ContainerQueue(orderCreated, "order.created", "Kafka", "New orders")
|
|
143
|
+
ContainerQueue(stockReserved, "stock.reserved", "Kafka", "Stock events")
|
|
144
|
+
ContainerQueue(paymentComplete, "payment.complete", "Kafka", "Payment events")
|
|
145
|
+
|
|
146
|
+
Rel(orderSvc, orderCreated, "Publishes")
|
|
147
|
+
Rel(inventorySvc, orderCreated, "Consumes")
|
|
148
|
+
Rel(inventorySvc, stockReserved, "Publishes")
|
|
149
|
+
Rel(paymentSvc, stockReserved, "Consumes")
|
|
150
|
+
Rel(paymentSvc, paymentComplete, "Publishes")
|
|
151
|
+
Rel(orderSvc, paymentComplete, "Consumes")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Alternative - Topics on relationship labels:**
|
|
155
|
+
```mermaid
|
|
156
|
+
C4Container
|
|
157
|
+
title ALTERNATIVE: Topics as Labels
|
|
158
|
+
|
|
159
|
+
Container(orderSvc, "Order Service", "Java")
|
|
160
|
+
Container(inventorySvc, "Inventory Service", "Java")
|
|
161
|
+
Container(paymentSvc, "Payment Service", "Java")
|
|
162
|
+
|
|
163
|
+
Rel(orderSvc, inventorySvc, "order.created", "Kafka")
|
|
164
|
+
Rel(inventorySvc, paymentSvc, "stock.reserved", "Kafka")
|
|
165
|
+
Rel(paymentSvc, orderSvc, "payment.complete", "Kafka")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## External Systems Mistakes
|
|
169
|
+
|
|
170
|
+
### Showing Internal Details of External Systems
|
|
171
|
+
|
|
172
|
+
**The Problem:**
|
|
173
|
+
You don't control external systems. Showing their internals creates coupling and becomes stale quickly.
|
|
174
|
+
|
|
175
|
+
**Wrong - External system internals:**
|
|
176
|
+
```mermaid
|
|
177
|
+
C4Container
|
|
178
|
+
title WRONG: External System Internals
|
|
179
|
+
|
|
180
|
+
Container(myApp, "My App", "Node.js")
|
|
181
|
+
|
|
182
|
+
System_Boundary(stripe, "Stripe") {
|
|
183
|
+
Container(stripeApi, "Stripe API", "Ruby")
|
|
184
|
+
Container(stripeWorker, "Payment Worker", "Java")
|
|
185
|
+
ContainerDb(stripeDb, "Payment DB", "MySQL")
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
Rel(myApp, stripeApi, "Charges cards")
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Correct - External system as black box:**
|
|
192
|
+
```mermaid
|
|
193
|
+
C4Context
|
|
194
|
+
title CORRECT: External System Black Box
|
|
195
|
+
|
|
196
|
+
Container(myApp, "My App", "Node.js", "E-commerce backend")
|
|
197
|
+
System_Ext(stripe, "Stripe", "Payment processing platform")
|
|
198
|
+
|
|
199
|
+
Rel(myApp, stripe, "Processes payments", "REST API")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Metadata and Documentation Mistakes
|
|
203
|
+
|
|
204
|
+
### 1. Removing Type Labels
|
|
205
|
+
|
|
206
|
+
**The Problem:**
|
|
207
|
+
Removing element type labels (Container, Component, System) to "simplify" diagrams creates ambiguity.
|
|
208
|
+
|
|
209
|
+
**Wrong:**
|
|
210
|
+
```
|
|
211
|
+
Box(api, "API") # What is this? System? Container? Component?
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Correct:**
|
|
215
|
+
```
|
|
216
|
+
Container(api, "API Application", "Spring Boot", "REST API backend")
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 2. Missing Descriptions
|
|
220
|
+
|
|
221
|
+
**The Problem:**
|
|
222
|
+
Elements without descriptions force viewers to guess their purpose.
|
|
223
|
+
|
|
224
|
+
**Wrong:**
|
|
225
|
+
```
|
|
226
|
+
Container(svc, "Service", "Java")
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Correct:**
|
|
230
|
+
```
|
|
231
|
+
Container(orderSvc, "Order Service", "Spring Boot", "Manages order lifecycle and fulfillment")
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 3. Generic Relationship Labels
|
|
235
|
+
|
|
236
|
+
**The Problem:**
|
|
237
|
+
Labels like "uses" or "communicates with" don't explain what data flows or why.
|
|
238
|
+
|
|
239
|
+
**Wrong:**
|
|
240
|
+
```
|
|
241
|
+
Rel(frontend, api, "Uses")
|
|
242
|
+
Rel(api, db, "Accesses")
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Correct:**
|
|
246
|
+
```
|
|
247
|
+
Rel(frontend, api, "Fetches products, submits orders", "JSON/HTTPS")
|
|
248
|
+
Rel(api, db, "Reads/writes order data", "JDBC")
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Diagram Scope Mistakes
|
|
252
|
+
|
|
253
|
+
### 1. Not Tailoring to Audience
|
|
254
|
+
|
|
255
|
+
**The Problem:**
|
|
256
|
+
Showing Level 4 code diagrams to executives, or only Level 1 to developers who need implementation details.
|
|
257
|
+
|
|
258
|
+
| Audience | Appropriate Levels |
|
|
259
|
+
|----------|-------------------|
|
|
260
|
+
| Executives | Level 1 (Context) only |
|
|
261
|
+
| Product Managers | Levels 1-2 |
|
|
262
|
+
| Architects | Levels 1-3 |
|
|
263
|
+
| Developers | All levels as needed |
|
|
264
|
+
| DevOps | Levels 2 + Deployment |
|
|
265
|
+
|
|
266
|
+
### 2. Creating All Four Levels by Default
|
|
267
|
+
|
|
268
|
+
**The Problem:**
|
|
269
|
+
Not every system needs all four levels. Level 3 (Component) and Level 4 (Code) often add no value.
|
|
270
|
+
|
|
271
|
+
**Guidance:**
|
|
272
|
+
- **Always create:** Context (L1) and Container (L2)
|
|
273
|
+
- **Create if valuable:** Component (L3) for complex containers
|
|
274
|
+
- **Rarely create:** Code (L4) - let IDEs generate these
|
|
275
|
+
|
|
276
|
+
### 3. Too Many Elements Per Diagram
|
|
277
|
+
|
|
278
|
+
**The Problem:**
|
|
279
|
+
Diagrams with 20+ elements become unreadable.
|
|
280
|
+
|
|
281
|
+
**Simon Brown's advice:** "If a diagram with a dozen boxes is hard to understand, don't draw a diagram with a dozen boxes!"
|
|
282
|
+
|
|
283
|
+
**Solutions:**
|
|
284
|
+
- Split by bounded context or domain
|
|
285
|
+
- Create separate diagrams per service
|
|
286
|
+
- Show one service + its direct dependencies
|
|
287
|
+
- Use multiple focused diagrams instead of one comprehensive diagram
|
|
288
|
+
|
|
289
|
+
## Arrow Mistakes
|
|
290
|
+
|
|
291
|
+
### 1. Bidirectional Arrows
|
|
292
|
+
|
|
293
|
+
**The Problem:**
|
|
294
|
+
Bidirectional arrows are ambiguous. Who initiates the call? What flows each direction?
|
|
295
|
+
|
|
296
|
+
**Wrong:**
|
|
297
|
+
```
|
|
298
|
+
BiRel(frontend, api, "Data") # Ambiguous direction
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Correct:**
|
|
302
|
+
```
|
|
303
|
+
Rel(frontend, api, "Requests products", "JSON/HTTPS")
|
|
304
|
+
Rel(api, frontend, "Returns product data", "JSON/HTTPS")
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Or show the initiator's perspective:
|
|
308
|
+
```
|
|
309
|
+
Rel(frontend, api, "Fetches products", "JSON/HTTPS")
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### 2. Unlabeled Arrows
|
|
313
|
+
|
|
314
|
+
**The Problem:**
|
|
315
|
+
Arrows without labels force readers to guess what flows between elements.
|
|
316
|
+
|
|
317
|
+
**Wrong:**
|
|
318
|
+
```
|
|
319
|
+
Rel(orderSvc, paymentSvc)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**Correct:**
|
|
323
|
+
```
|
|
324
|
+
Rel(orderSvc, paymentSvc, "Requests payment authorization", "gRPC")
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Deployment Diagram Mistakes
|
|
328
|
+
|
|
329
|
+
### 1. Deployment Details in Container Diagrams
|
|
330
|
+
|
|
331
|
+
**The Problem:**
|
|
332
|
+
Container diagrams should show logical architecture, not infrastructure details.
|
|
333
|
+
|
|
334
|
+
**Wrong - Infrastructure in container diagram:**
|
|
335
|
+
```mermaid
|
|
336
|
+
C4Container
|
|
337
|
+
title WRONG: Infrastructure in Container Diagram
|
|
338
|
+
|
|
339
|
+
Container(api1, "API (Instance 1)", "Java", "Primary")
|
|
340
|
+
Container(api2, "API (Instance 2)", "Java", "Replica")
|
|
341
|
+
Container(api3, "API (Instance 3)", "Java", "Replica")
|
|
342
|
+
Container(lb, "Load Balancer", "HAProxy", "Distributes traffic")
|
|
343
|
+
ContainerDb(primary, "Primary DB", "PostgreSQL", "Write")
|
|
344
|
+
ContainerDb(replica, "Read Replica", "PostgreSQL", "Read")
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Correct - Use Deployment diagram for infrastructure:**
|
|
348
|
+
```mermaid
|
|
349
|
+
C4Deployment
|
|
350
|
+
title CORRECT: Deployment Diagram for Infrastructure
|
|
351
|
+
|
|
352
|
+
Deployment_Node(lb, "Load Balancer", "AWS ALB") {
|
|
353
|
+
Container(alb, "ALB", "AWS", "Traffic distribution")
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
Deployment_Node(ecs, "ECS Cluster", "Fargate") {
|
|
357
|
+
Container(api1, "API Instance 1", "Spring Boot")
|
|
358
|
+
Container(api2, "API Instance 2", "Spring Boot")
|
|
359
|
+
Container(api3, "API Instance 3", "Spring Boot")
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
Deployment_Node(rds, "RDS", "Multi-AZ") {
|
|
363
|
+
ContainerDb(primary, "Primary", "PostgreSQL")
|
|
364
|
+
ContainerDb(replica, "Replica", "PostgreSQL")
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### 2. Missing Environment Context
|
|
369
|
+
|
|
370
|
+
**The Problem:**
|
|
371
|
+
Deployment diagrams should specify which environment (production, staging, dev).
|
|
372
|
+
|
|
373
|
+
**Wrong:**
|
|
374
|
+
```
|
|
375
|
+
C4Deployment
|
|
376
|
+
title Deployment Diagram # Which environment?
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**Correct:**
|
|
380
|
+
```
|
|
381
|
+
C4Deployment
|
|
382
|
+
title Deployment Diagram - Production (AWS us-east-1)
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Consistency Mistakes
|
|
386
|
+
|
|
387
|
+
### 1. Inconsistent Notation Across Diagrams
|
|
388
|
+
|
|
389
|
+
**The Problem:**
|
|
390
|
+
Using different colors, shapes, or terminology for the same elements across diagrams.
|
|
391
|
+
|
|
392
|
+
**Wrong:**
|
|
393
|
+
- Context diagram: "Payment System" (blue)
|
|
394
|
+
- Container diagram: "Payment Service" (green)
|
|
395
|
+
- Component diagram: "Payment Module" (red)
|
|
396
|
+
|
|
397
|
+
**Correct:**
|
|
398
|
+
Use consistent naming, colors, and styling. Create a style guide for your team.
|
|
399
|
+
|
|
400
|
+
### 2. No Legend/Key
|
|
401
|
+
|
|
402
|
+
**The Problem:**
|
|
403
|
+
Assuming viewers understand your notation without explanation.
|
|
404
|
+
|
|
405
|
+
**Solution:**
|
|
406
|
+
Always include a legend explaining colors, shapes, and line styles. Even for "obvious" elements.
|
|
407
|
+
|
|
408
|
+
## Decision Documentation Mistakes
|
|
409
|
+
|
|
410
|
+
### Showing Decision Process in Diagrams
|
|
411
|
+
|
|
412
|
+
**The Problem:**
|
|
413
|
+
Architecture diagrams show **outcomes** of decisions, not the decision-making process.
|
|
414
|
+
|
|
415
|
+
**Wrong approach:**
|
|
416
|
+
Including "Option A vs Option B" annotations in diagrams.
|
|
417
|
+
|
|
418
|
+
**Correct approach:**
|
|
419
|
+
- Document decisions separately in Architecture Decision Records (ADRs)
|
|
420
|
+
- Link ADRs to relevant diagrams
|
|
421
|
+
- Diagrams show the chosen architecture, ADRs explain why
|
|
422
|
+
|
|
423
|
+
## Quick Reference: Checklist
|
|
424
|
+
|
|
425
|
+
Before finalizing any C4 diagram, verify:
|
|
426
|
+
|
|
427
|
+
- [ ] Every element has: name, type, technology (if applicable), description
|
|
428
|
+
- [ ] All arrows are unidirectional with action verb labels
|
|
429
|
+
- [ ] Technology/protocol included on relationships
|
|
430
|
+
- [ ] Diagram has a clear, specific title
|
|
431
|
+
- [ ] Under 20 elements (ideally under 15)
|
|
432
|
+
- [ ] Appropriate level for the target audience
|
|
433
|
+
- [ ] Containers are deployable, components are not
|
|
434
|
+
- [ ] External systems shown as black boxes
|
|
435
|
+
- [ ] Message topics shown individually (not as single broker)
|
|
436
|
+
- [ ] No infrastructure details in container diagrams
|
|
437
|
+
- [ ] Consistent with other diagrams in the set
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mermaid-diagrams
|
|
3
|
+
description: |
|
|
4
|
+
Comprehensive guide for creating software diagrams using Mermaid syntax.
|
|
5
|
+
Supports class diagrams, sequence diagrams, flowcharts, ERD, C4 diagrams,
|
|
6
|
+
state diagrams, and more. Use when diagramming, visualizing, or documenting
|
|
7
|
+
software architecture, database design, or code structure.
|
|
8
|
+
version: 1.0.0
|
|
9
|
+
category: architecture
|
|
10
|
+
tags:
|
|
11
|
+
- mermaid
|
|
12
|
+
- diagrams
|
|
13
|
+
- flowcharts
|
|
14
|
+
- sequence-diagrams
|
|
15
|
+
- documentation
|
|
16
|
+
depends_on: []
|
|
17
|
+
recommends: []
|
|
18
|
+
used_by:
|
|
19
|
+
- sa
|
|
20
|
+
- tech-lead
|
|
21
|
+
- ba
|
|
22
|
+
- pm
|
|
23
|
+
- dev-fe
|
|
24
|
+
- dev-be
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Mermaid Diagramming
|
|
28
|
+
|
|
29
|
+
Create professional software diagrams using Mermaid's text-based syntax. Mermaid renders diagrams from simple text definitions, making diagrams version-controllable, easy to update, and maintainable alongside code.
|
|
30
|
+
|
|
31
|
+
## Core Syntax Structure
|
|
32
|
+
|
|
33
|
+
All Mermaid diagrams follow this pattern:
|
|
34
|
+
|
|
35
|
+
```mermaid
|
|
36
|
+
diagramType
|
|
37
|
+
definition content
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Key principles:**
|
|
41
|
+
- First line declares diagram type (e.g., `classDiagram`, `sequenceDiagram`, `flowchart`)
|
|
42
|
+
- Use `%%` for comments
|
|
43
|
+
- Line breaks and indentation improve readability but aren't required
|
|
44
|
+
- Unknown words break diagrams; parameters fail silently
|
|
45
|
+
|
|
46
|
+
## Diagram Type Selection Guide
|
|
47
|
+
|
|
48
|
+
**Choose the right diagram type:**
|
|
49
|
+
|
|
50
|
+
1. **Class Diagrams** - Domain modeling, OOP design, entity relationships
|
|
51
|
+
- Domain-driven design documentation
|
|
52
|
+
- Object-oriented class structures
|
|
53
|
+
- Entity relationships and dependencies
|
|
54
|
+
|
|
55
|
+
2. **Sequence Diagrams** - Temporal interactions, message flows
|
|
56
|
+
- API request/response flows
|
|
57
|
+
- User authentication flows
|
|
58
|
+
- System component interactions
|
|
59
|
+
- Method call sequences
|
|
60
|
+
|
|
61
|
+
3. **Flowcharts** - Processes, algorithms, decision trees
|
|
62
|
+
- User journeys and workflows
|
|
63
|
+
- Business processes
|
|
64
|
+
- Algorithm logic
|
|
65
|
+
- Deployment pipelines
|
|
66
|
+
|
|
67
|
+
4. **Entity Relationship Diagrams (ERD)** - Database schemas
|
|
68
|
+
- Table relationships
|
|
69
|
+
- Data modeling
|
|
70
|
+
- Schema design
|
|
71
|
+
|
|
72
|
+
5. **C4 Diagrams** - Software architecture at multiple levels
|
|
73
|
+
- System Context (systems and users)
|
|
74
|
+
- Container (applications, databases, services)
|
|
75
|
+
- Component (internal structure)
|
|
76
|
+
- Code (class/interface level)
|
|
77
|
+
|
|
78
|
+
6. **State Diagrams** - State machines, lifecycle states
|
|
79
|
+
7. **Git Graphs** - Version control branching strategies
|
|
80
|
+
8. **Gantt Charts** - Project timelines, scheduling
|
|
81
|
+
9. **Pie/Bar Charts** - Data visualization
|
|
82
|
+
|
|
83
|
+
## Quick Start Examples
|
|
84
|
+
|
|
85
|
+
### Class Diagram (Domain Model)
|
|
86
|
+
```mermaid
|
|
87
|
+
classDiagram
|
|
88
|
+
Title -- Genre
|
|
89
|
+
Title *-- Season
|
|
90
|
+
Title *-- Review
|
|
91
|
+
User --> Review : creates
|
|
92
|
+
|
|
93
|
+
class Title {
|
|
94
|
+
+string name
|
|
95
|
+
+int releaseYear
|
|
96
|
+
+play()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
class Genre {
|
|
100
|
+
+string name
|
|
101
|
+
+getTopTitles()
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Sequence Diagram (API Flow)
|
|
106
|
+
```mermaid
|
|
107
|
+
sequenceDiagram
|
|
108
|
+
participant User
|
|
109
|
+
participant API
|
|
110
|
+
participant Database
|
|
111
|
+
|
|
112
|
+
User->>API: POST /login
|
|
113
|
+
API->>Database: Query credentials
|
|
114
|
+
Database-->>API: Return user data
|
|
115
|
+
alt Valid credentials
|
|
116
|
+
API-->>User: 200 OK + JWT token
|
|
117
|
+
else Invalid credentials
|
|
118
|
+
API-->>User: 401 Unauthorized
|
|
119
|
+
end
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Flowchart (User Journey)
|
|
123
|
+
```mermaid
|
|
124
|
+
flowchart TD
|
|
125
|
+
Start([User visits site]) --> Auth{Authenticated?}
|
|
126
|
+
Auth -->|No| Login[Show login page]
|
|
127
|
+
Auth -->|Yes| Dashboard[Show dashboard]
|
|
128
|
+
Login --> Creds[Enter credentials]
|
|
129
|
+
Creds --> Validate{Valid?}
|
|
130
|
+
Validate -->|Yes| Dashboard
|
|
131
|
+
Validate -->|No| Error[Show error]
|
|
132
|
+
Error --> Login
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### ERD (Database Schema)
|
|
136
|
+
```mermaid
|
|
137
|
+
erDiagram
|
|
138
|
+
USER ||--o{ ORDER : places
|
|
139
|
+
ORDER ||--|{ LINE_ITEM : contains
|
|
140
|
+
PRODUCT ||--o{ LINE_ITEM : includes
|
|
141
|
+
|
|
142
|
+
USER {
|
|
143
|
+
int id PK
|
|
144
|
+
string email UK
|
|
145
|
+
string name
|
|
146
|
+
datetime created_at
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
ORDER {
|
|
150
|
+
int id PK
|
|
151
|
+
int user_id FK
|
|
152
|
+
decimal total
|
|
153
|
+
datetime created_at
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Detailed References
|
|
158
|
+
|
|
159
|
+
For in-depth guidance on specific diagram types, see:
|
|
160
|
+
|
|
161
|
+
- **[references/class-diagrams.md](references/class-diagrams.md)** - Domain modeling, relationships (association, composition, aggregation, inheritance), multiplicity, methods/properties
|
|
162
|
+
- **[references/sequence-diagrams.md](references/sequence-diagrams.md)** - Actors, participants, messages (sync/async), activations, loops, alt/opt/par blocks, notes
|
|
163
|
+
- **[references/flowcharts.md](references/flowcharts.md)** - Node shapes, connections, decision logic, subgraphs, styling
|
|
164
|
+
- **[references/erd-diagrams.md](references/erd-diagrams.md)** - Entities, relationships, cardinality, keys, attributes
|
|
165
|
+
- **[references/c4-diagrams.md](references/c4-diagrams.md)** - System context, container, component diagrams, boundaries
|
|
166
|
+
- **[references/architecture-diagrams.md](references/architecture-diagrams.md)** - Cloud services, infrastructure, CI/CD deployments
|
|
167
|
+
- **[references/advanced-features.md](references/advanced-features.md)** - Themes, styling, configuration, layout options
|
|
168
|
+
|
|
169
|
+
## Best Practices
|
|
170
|
+
|
|
171
|
+
1. **Start Simple** - Begin with core entities/components, add details incrementally
|
|
172
|
+
2. **Use Meaningful Names** - Clear labels make diagrams self-documenting
|
|
173
|
+
3. **Comment Extensively** - Use `%%` comments to explain complex relationships
|
|
174
|
+
4. **Keep Focused** - One diagram per concept; split large diagrams into multiple focused views
|
|
175
|
+
5. **Version Control** - Store `.mmd` files alongside code for easy updates
|
|
176
|
+
6. **Add Context** - Include titles and notes to explain diagram purpose
|
|
177
|
+
7. **Iterate** - Refine diagrams as understanding evolves
|
|
178
|
+
|
|
179
|
+
## Configuration and Theming
|
|
180
|
+
|
|
181
|
+
Configure diagrams using frontmatter:
|
|
182
|
+
|
|
183
|
+
```mermaid
|
|
184
|
+
---
|
|
185
|
+
config:
|
|
186
|
+
theme: base
|
|
187
|
+
themeVariables:
|
|
188
|
+
primaryColor: "#ff6b6b"
|
|
189
|
+
---
|
|
190
|
+
flowchart LR
|
|
191
|
+
A --> B
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Available themes:** default, forest, dark, neutral, base
|
|
195
|
+
|
|
196
|
+
**Layout options:**
|
|
197
|
+
- `layout: dagre` (default) - Classic balanced layout
|
|
198
|
+
- `layout: elk` - Advanced layout for complex diagrams (requires integration)
|
|
199
|
+
|
|
200
|
+
**Look options:**
|
|
201
|
+
- `look: classic` - Traditional Mermaid style
|
|
202
|
+
- `look: handDrawn` - Sketch-like appearance
|
|
203
|
+
|
|
204
|
+
## Exporting and Rendering
|
|
205
|
+
|
|
206
|
+
**Native support in:**
|
|
207
|
+
- GitHub/GitLab - Automatically renders in Markdown
|
|
208
|
+
- VS Code - With Markdown Mermaid extension
|
|
209
|
+
- Notion, Obsidian, Confluence - Built-in support
|
|
210
|
+
|
|
211
|
+
**Export options:**
|
|
212
|
+
- [Mermaid Live Editor](https://mermaid.live) - Online editor with PNG/SVG export
|
|
213
|
+
- Mermaid CLI - `npm install -g @mermaid-js/mermaid-cli` then `mmdc -i input.mmd -o output.png`
|
|
214
|
+
- Docker - `docker run --rm -v $(pwd):/data minlag/mermaid-cli -i /data/input.mmd -o /data/output.png`
|
|
215
|
+
|
|
216
|
+
## Common Pitfalls
|
|
217
|
+
|
|
218
|
+
- **Breaking characters** - Avoid `{}` in comments, use proper escape sequences for special characters
|
|
219
|
+
- **Syntax errors** - Misspellings break diagrams; validate syntax in Mermaid Live
|
|
220
|
+
- **Overcomplexity** - Split complex diagrams into multiple focused views
|
|
221
|
+
- **Missing relationships** - Document all important connections between entities
|
|
222
|
+
|
|
223
|
+
## When to Create Diagrams
|
|
224
|
+
|
|
225
|
+
**Always diagram when:**
|
|
226
|
+
- Starting new projects or features
|
|
227
|
+
- Documenting complex systems
|
|
228
|
+
- Explaining architecture decisions
|
|
229
|
+
- Designing database schemas
|
|
230
|
+
- Planning refactoring efforts
|
|
231
|
+
- Onboarding new team members
|
|
232
|
+
|
|
233
|
+
**Use diagrams to:**
|
|
234
|
+
- Align stakeholders on technical decisions
|
|
235
|
+
- Document domain models collaboratively
|
|
236
|
+
- Visualize data flows and system interactions
|
|
237
|
+
- Plan before coding
|
|
238
|
+
- Create living documentation that evolves with code
|