odoo-forge-bundle 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,394 @@
1
+ # Sequence Diagrams
2
+
3
+ Sequence diagrams show interactions between participants over time. They're ideal for API flows, authentication sequences, and system component interactions.
4
+
5
+ ## Basic Syntax
6
+
7
+ ```mermaid
8
+ sequenceDiagram
9
+ participant A
10
+ participant B
11
+ A->>B: Message
12
+ ```
13
+
14
+ ## Participants and Actors
15
+
16
+ ```mermaid
17
+ sequenceDiagram
18
+ actor User
19
+ participant Frontend
20
+ participant API
21
+ participant Database
22
+
23
+ User->>Frontend: Click button
24
+ Frontend->>API: POST /data
25
+ ```
26
+
27
+ **Difference:**
28
+ - `participant` - System components (services, classes, databases)
29
+ - `actor` - External entities (users, external systems)
30
+
31
+ ## Message Types
32
+
33
+ ### Solid Arrow (Synchronous)
34
+ ```mermaid
35
+ sequenceDiagram
36
+ Client->>Server: Request
37
+ Server-->>Client: Response
38
+ ```
39
+
40
+ - `->>` Solid arrow (request)
41
+ - `-->>` Dotted arrow (response/return)
42
+
43
+ ### Open Arrow (Asynchronous)
44
+ ```mermaid
45
+ sequenceDiagram
46
+ Client-)Server: Async message
47
+ Server--)Client: Async response
48
+ ```
49
+
50
+ - `-)` Solid open arrow
51
+ - `--)` Dotted open arrow
52
+
53
+ ### Cross/X (Delete)
54
+ ```mermaid
55
+ sequenceDiagram
56
+ Client-xServer: Delete
57
+ ```
58
+
59
+ ## Activations
60
+
61
+ Show when a participant is actively processing:
62
+
63
+ ```mermaid
64
+ sequenceDiagram
65
+ Client->>+Server: Request
66
+ Server->>+Database: Query
67
+ Database-->>-Server: Data
68
+ Server-->>-Client: Response
69
+ ```
70
+
71
+ - `+` after arrow activates
72
+ - `-` before arrow deactivates
73
+
74
+ ## Alt/Else (Conditional Logic)
75
+
76
+ ```mermaid
77
+ sequenceDiagram
78
+ User->>API: POST /login
79
+ API->>Database: Query user
80
+ Database-->>API: User data
81
+
82
+ alt Valid credentials
83
+ API-->>User: 200 OK + Token
84
+ else Invalid credentials
85
+ API-->>User: 401 Unauthorized
86
+ else Account locked
87
+ API-->>User: 403 Forbidden
88
+ end
89
+ ```
90
+
91
+ ## Opt (Optional)
92
+
93
+ ```mermaid
94
+ sequenceDiagram
95
+ User->>API: POST /order
96
+ API->>PaymentService: Process payment
97
+
98
+ opt Payment successful
99
+ API->>EmailService: Send confirmation
100
+ end
101
+
102
+ API-->>User: Order result
103
+ ```
104
+
105
+ ## Par (Parallel)
106
+
107
+ Show concurrent operations:
108
+
109
+ ```mermaid
110
+ sequenceDiagram
111
+ API->>Service: Process order
112
+
113
+ par Send email
114
+ Service->>EmailService: Send confirmation
115
+ and Update inventory
116
+ Service->>InventoryService: Reduce stock
117
+ and Log event
118
+ Service->>LogService: Log order
119
+ end
120
+
121
+ Service-->>API: Complete
122
+ ```
123
+
124
+ ## Loop
125
+
126
+ ```mermaid
127
+ sequenceDiagram
128
+ Client->>Server: Request batch
129
+
130
+ loop For each item
131
+ Server->>Database: Process item
132
+ Database-->>Server: Result
133
+ end
134
+
135
+ Server-->>Client: All results
136
+ ```
137
+
138
+ **Loop with condition:**
139
+ ```mermaid
140
+ sequenceDiagram
141
+ loop Every 5 seconds
142
+ Monitor->>API: Health check
143
+ API-->>Monitor: Status
144
+ end
145
+ ```
146
+
147
+ ## Break (Early Exit)
148
+
149
+ ```mermaid
150
+ sequenceDiagram
151
+ User->>API: Submit form
152
+ API->>Validator: Validate input
153
+
154
+ break Input invalid
155
+ API-->>User: 400 Bad Request
156
+ end
157
+
158
+ API->>Database: Save data
159
+ Database-->>API: Success
160
+ API-->>User: 200 OK
161
+ ```
162
+
163
+ ## Notes
164
+
165
+ ### Note over single participant
166
+ ```mermaid
167
+ sequenceDiagram
168
+ User->>API: Request
169
+ Note over API: Validates JWT token
170
+ API-->>User: Response
171
+ ```
172
+
173
+ ### Note spanning participants
174
+ ```mermaid
175
+ sequenceDiagram
176
+ Frontend->>API: Request
177
+ Note over Frontend,API: HTTPS encrypted
178
+ API-->>Frontend: Response
179
+ ```
180
+
181
+ ### Right/Left notes
182
+ ```mermaid
183
+ sequenceDiagram
184
+ User->>System: Action
185
+ Note right of System: Logs to database
186
+ System-->>User: Response
187
+ Note left of User: Updates UI
188
+ ```
189
+
190
+ ## Sequence Numbers
191
+
192
+ Automatically number messages:
193
+
194
+ ```mermaid
195
+ sequenceDiagram
196
+ autonumber
197
+
198
+ User->>Frontend: Login
199
+ Frontend->>API: Authenticate
200
+ API->>Database: Verify credentials
201
+ Database-->>API: User data
202
+ API-->>Frontend: JWT token
203
+ Frontend-->>User: Success
204
+ ```
205
+
206
+ ## Links and Tooltips
207
+
208
+ Add clickable links:
209
+
210
+ ```mermaid
211
+ sequenceDiagram
212
+ participant A as Service A
213
+ link A: Dashboard @ https://dashboard.example.com
214
+ link A: API Docs @ https://docs.example.com
215
+
216
+ A->>B: Message
217
+ ```
218
+
219
+ ## Comprehensive Example: User Authentication Flow
220
+
221
+ ```mermaid
222
+ sequenceDiagram
223
+ autonumber
224
+ actor User
225
+ participant Frontend
226
+ participant AuthAPI
227
+ participant Database
228
+ participant Redis
229
+ participant EmailService
230
+
231
+ User->>+Frontend: Enter credentials
232
+ Frontend->>+AuthAPI: POST /auth/login
233
+
234
+ AuthAPI->>+Database: Query user by email
235
+ Database-->>-AuthAPI: User record
236
+
237
+ alt User not found
238
+ AuthAPI-->>Frontend: 404 User not found
239
+ Frontend-->>User: Show error
240
+ else User found
241
+ AuthAPI->>AuthAPI: Verify password hash
242
+
243
+ alt Invalid password
244
+ AuthAPI->>Database: Increment failed attempts
245
+
246
+ opt Failed attempts > 5
247
+ AuthAPI->>Database: Lock account
248
+ AuthAPI->>EmailService: Send security alert
249
+ end
250
+
251
+ AuthAPI-->>Frontend: 401 Invalid credentials
252
+ Frontend-->>User: Show error
253
+ else Valid password
254
+ AuthAPI->>AuthAPI: Generate JWT token
255
+ AuthAPI->>+Redis: Store session
256
+ Redis-->>-AuthAPI: Confirm
257
+
258
+ par Update login metadata
259
+ AuthAPI->>Database: Update last_login
260
+ and Track analytics
261
+ AuthAPI->>Database: Log login event
262
+ end
263
+
264
+ AuthAPI-->>-Frontend: 200 OK + JWT token
265
+ Frontend->>Frontend: Store token in localStorage
266
+ Frontend-->>-User: Redirect to dashboard
267
+
268
+ opt First login
269
+ EmailService->>User: Welcome email
270
+ end
271
+ end
272
+ end
273
+ ```
274
+
275
+ ## API Request/Response Example
276
+
277
+ ```mermaid
278
+ sequenceDiagram
279
+ autonumber
280
+ participant Client
281
+ participant Gateway
282
+ participant AuthService
283
+ participant UserService
284
+ participant Database
285
+
286
+ Client->>+Gateway: GET /api/users/123
287
+ Note over Gateway: Rate limiting check
288
+
289
+ Gateway->>+AuthService: Validate JWT
290
+ AuthService->>AuthService: Verify signature
291
+
292
+ alt Token invalid or expired
293
+ AuthService-->>Gateway: 401 Unauthorized
294
+ Gateway-->>Client: 401 Unauthorized
295
+ else Token valid
296
+ AuthService-->>-Gateway: User context
297
+
298
+ Gateway->>+UserService: GET /users/123
299
+ UserService->>+Database: SELECT * FROM users WHERE id=123
300
+ Database-->>-UserService: User record
301
+
302
+ alt User not found
303
+ UserService-->>Gateway: 404 Not Found
304
+ Gateway-->>Client: 404 Not Found
305
+ else User found
306
+ UserService-->>-Gateway: 200 OK + User data
307
+ Gateway-->>-Client: 200 OK + User data
308
+ end
309
+ end
310
+ ```
311
+
312
+ ## Microservices Communication
313
+
314
+ ```mermaid
315
+ sequenceDiagram
316
+ actor User
317
+ participant Gateway
318
+ participant OrderService
319
+ participant PaymentService
320
+ participant InventoryService
321
+ participant NotificationService
322
+ participant MessageQueue
323
+
324
+ User->>+Gateway: POST /orders
325
+ Gateway->>+OrderService: Create order
326
+
327
+ OrderService->>+InventoryService: Check stock
328
+ InventoryService-->>-OrderService: Stock available
329
+
330
+ break Insufficient stock
331
+ OrderService-->>Gateway: 400 Out of stock
332
+ Gateway-->>User: Error message
333
+ end
334
+
335
+ OrderService->>OrderService: Reserve order
336
+ OrderService->>+PaymentService: Charge customer
337
+
338
+ alt Payment successful
339
+ PaymentService-->>-OrderService: Payment confirmed
340
+ OrderService->>MessageQueue: Publish OrderConfirmed event
341
+
342
+ par Async processing
343
+ MessageQueue->>InventoryService: Reduce stock
344
+ and
345
+ MessageQueue->>NotificationService: Send confirmation
346
+ NotificationService->>User: Email confirmation
347
+ end
348
+
349
+ OrderService-->>-Gateway: 201 Created
350
+ Gateway-->>User: Order confirmed
351
+ else Payment failed
352
+ PaymentService-->>OrderService: Payment declined
353
+ OrderService->>OrderService: Release reservation
354
+ OrderService-->>Gateway: 402 Payment Required
355
+ Gateway-->>User: Payment failed
356
+ end
357
+ ```
358
+
359
+ ## Best Practices
360
+
361
+ 1. **Order participants logically** - Typically: User → Frontend → Backend → Database
362
+ 2. **Use activations** - Shows when components are actively processing
363
+ 3. **Group related logic** - Use alt/opt/par to organize conditional flows
364
+ 4. **Add descriptive notes** - Explain complex logic or important details
365
+ 5. **Keep diagrams focused** - One scenario per diagram
366
+ 6. **Number messages** - Use autonumber for complex flows
367
+ 7. **Show error paths** - Document failure scenarios with alt/else
368
+ 8. **Indicate async operations** - Use open arrows for fire-and-forget messages
369
+
370
+ ## Common Use Cases
371
+
372
+ ### Authentication
373
+ - Login flows
374
+ - OAuth/SSO flows
375
+ - Token refresh
376
+ - Password reset
377
+
378
+ ### API Operations
379
+ - CRUD operations
380
+ - Search and filtering
381
+ - Batch processing
382
+ - Webhook handling
383
+
384
+ ### System Integration
385
+ - Microservice communication
386
+ - Third-party API calls
387
+ - Message queue processing
388
+ - Event-driven architecture
389
+
390
+ ### Business Processes
391
+ - Order fulfillment
392
+ - Payment processing
393
+ - Approval workflows
394
+ - Notification chains