@mytechtoday/augment-extensions 1.2.1 → 1.2.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.
Files changed (31) hide show
  1. package/AGENTS.md +33 -1
  2. package/README.md +3 -3
  3. package/augment-extensions/domain-rules/software-architecture/README.md +143 -0
  4. package/augment-extensions/domain-rules/software-architecture/examples/banking-layered.md +961 -0
  5. package/augment-extensions/domain-rules/software-architecture/examples/ecommerce-microservices.md +990 -0
  6. package/augment-extensions/domain-rules/software-architecture/examples/iot-eventdriven.md +882 -0
  7. package/augment-extensions/domain-rules/software-architecture/examples/monolith-to-microservices-migration.md +703 -0
  8. package/augment-extensions/domain-rules/software-architecture/examples/serverless-imageprocessing.md +957 -0
  9. package/augment-extensions/domain-rules/software-architecture/examples/trading-eventdriven.md +747 -0
  10. package/augment-extensions/domain-rules/software-architecture/module.json +119 -0
  11. package/augment-extensions/domain-rules/software-architecture/rules/challenges-solutions.md +763 -0
  12. package/augment-extensions/domain-rules/software-architecture/rules/definitions-terminology.md +409 -0
  13. package/augment-extensions/domain-rules/software-architecture/rules/design-principles.md +684 -0
  14. package/augment-extensions/domain-rules/software-architecture/rules/evaluation-testing.md +1381 -0
  15. package/augment-extensions/domain-rules/software-architecture/rules/event-driven-architecture.md +616 -0
  16. package/augment-extensions/domain-rules/software-architecture/rules/fundamentals.md +306 -0
  17. package/augment-extensions/domain-rules/software-architecture/rules/industry-architectures.md +554 -0
  18. package/augment-extensions/domain-rules/software-architecture/rules/layered-architecture.md +776 -0
  19. package/augment-extensions/domain-rules/software-architecture/rules/microservices-architecture.md +503 -0
  20. package/augment-extensions/domain-rules/software-architecture/rules/modeling-documentation.md +1199 -0
  21. package/augment-extensions/domain-rules/software-architecture/rules/monolithic-architecture.md +351 -0
  22. package/augment-extensions/domain-rules/software-architecture/rules/principles.md +556 -0
  23. package/augment-extensions/domain-rules/software-architecture/rules/quality-attributes.md +797 -0
  24. package/augment-extensions/domain-rules/software-architecture/rules/scalability-performance.md +1345 -0
  25. package/augment-extensions/domain-rules/software-architecture/rules/security-architecture.md +1039 -0
  26. package/augment-extensions/domain-rules/software-architecture/rules/serverless-architecture.md +711 -0
  27. package/augment-extensions/domain-rules/software-architecture/rules/skills-development.md +568 -0
  28. package/augment-extensions/domain-rules/software-architecture/rules/tools-methodologies.md +961 -0
  29. package/augment-extensions/workflows/beads/rules/workflow.md +1 -1
  30. package/modules.md +40 -3
  31. package/package.json +1 -1
@@ -0,0 +1,1199 @@
1
+ # Modeling and Documentation
2
+
3
+ ## Overview
4
+
5
+ This document covers architectural modeling techniques including the 4+1 View Model, UML diagrams, C4 Model, and automated documentation generation strategies.
6
+
7
+ ---
8
+
9
+ ## Knowledge
10
+
11
+ ### 4+1 View Model
12
+
13
+ **What is the 4+1 View Model?**
14
+ - Architectural description framework by Philippe Kruchten
15
+ - Describes software architecture from multiple perspectives
16
+ - Each view addresses specific stakeholder concerns
17
+ - "+1" represents scenarios that tie views together
18
+
19
+ **The Five Views**
20
+
21
+ **1. Logical View (Functionality)**
22
+ - **Purpose**: What the system does
23
+ - **Audience**: End users, analysts
24
+ - **Diagrams**: Class diagrams, state diagrams
25
+ - **Focus**: Functional requirements, domain model
26
+ - **Elements**: Classes, interfaces, packages, modules
27
+
28
+ **2. Process View (Concurrency)**
29
+ - **Purpose**: How the system executes
30
+ - **Audience**: System integrators, performance engineers
31
+ - **Diagrams**: Activity diagrams, sequence diagrams
32
+ - **Focus**: Concurrency, distribution, performance, scalability
33
+ - **Elements**: Processes, threads, tasks
34
+
35
+ **3. Development View (Organization)**
36
+ - **Purpose**: How the system is organized for development
37
+ - **Audience**: Developers, project managers
38
+ - **Diagrams**: Package diagrams, component diagrams
39
+ - **Focus**: Software management, reusability
40
+ - **Elements**: Modules, layers, subsystems
41
+
42
+ **4. Physical View (Deployment)**
43
+ - **Purpose**: Where the system runs
44
+ - **Audience**: System engineers, operations
45
+ - **Diagrams**: Deployment diagrams
46
+ - **Focus**: Topology, installation, communication
47
+ - **Elements**: Nodes, hardware, networks
48
+
49
+ **5. Scenarios (+1)**
50
+ - **Purpose**: Validate and illustrate architecture
51
+ - **Audience**: All stakeholders
52
+ - **Diagrams**: Use case diagrams, sequence diagrams
53
+ - **Focus**: Key use cases, quality attributes
54
+ - **Elements**: Use cases, scenarios, user stories
55
+
56
+ ### UML (Unified Modeling Language)
57
+
58
+ **Structural Diagrams**
59
+
60
+ **Class Diagram**
61
+ - Shows classes, attributes, methods, relationships
62
+ - Relationships: association, aggregation, composition, inheritance
63
+ - Visibility: public (+), private (-), protected (#)
64
+ - Multiplicity: 1, 0..1, 0..*, 1..*
65
+
66
+ **Component Diagram**
67
+ - Shows components and dependencies
68
+ - Interfaces (provided/required)
69
+ - Component boundaries
70
+ - Deployment units
71
+
72
+ **Package Diagram**
73
+ - Shows package organization
74
+ - Package dependencies
75
+ - Namespace hierarchy
76
+ - Module structure
77
+
78
+ **Deployment Diagram**
79
+ - Shows physical deployment
80
+ - Nodes (hardware/execution environments)
81
+ - Artifacts (deployable units)
82
+ - Communication paths
83
+
84
+ **Behavioral Diagrams**
85
+
86
+ **Sequence Diagram**
87
+ - Shows object interactions over time
88
+ - Messages between objects
89
+ - Lifelines and activation boxes
90
+ - Return messages
91
+
92
+ **Activity Diagram**
93
+ - Shows workflow and business processes
94
+ - Actions and decisions
95
+ - Parallel flows (fork/join)
96
+ - Swim lanes for responsibilities
97
+
98
+ **State Machine Diagram**
99
+ - Shows object states and transitions
100
+ - States, events, guards, actions
101
+ - Entry/exit actions
102
+ - Nested states
103
+
104
+ **Use Case Diagram**
105
+ - Shows system functionality
106
+ - Actors and use cases
107
+ - Relationships: include, extend, generalization
108
+ - System boundary
109
+
110
+ ### C4 Model
111
+
112
+ **What is the C4 Model?**
113
+ - Hierarchical set of diagrams for software architecture
114
+ - Created by Simon Brown
115
+ - Four levels of abstraction
116
+ - Simple, accessible notation
117
+
118
+ **Level 1: System Context Diagram**
119
+ - **Purpose**: Big picture view
120
+ - **Audience**: Everyone (technical and non-technical)
121
+ - **Shows**: System, users, external systems
122
+ - **Hides**: Internal details
123
+ - **Notation**: Boxes and lines
124
+
125
+ **Level 2: Container Diagram**
126
+ - **Purpose**: High-level technology choices
127
+ - **Audience**: Technical people inside and outside team
128
+ - **Shows**: Containers (applications, data stores, microservices)
129
+ - **Hides**: Implementation details
130
+ - **Notation**: Boxes for containers, lines for interactions
131
+
132
+ **Level 3: Component Diagram**
133
+ - **Purpose**: Internal structure of containers
134
+ - **Audience**: Software architects and developers
135
+ - **Shows**: Components and their interactions
136
+ - **Hides**: Code-level details
137
+ - **Notation**: Boxes for components, lines for dependencies
138
+
139
+ **Level 4: Code Diagram**
140
+ - **Purpose**: Implementation details
141
+ - **Audience**: Developers
142
+ - **Shows**: Classes, interfaces, methods
143
+ - **Hides**: Nothing (most detailed)
144
+ - **Notation**: UML class diagrams, ER diagrams
145
+
146
+ **C4 Notation**
147
+ - **Person**: User or actor (blue)
148
+ - **Software System**: Highest level of abstraction (gray)
149
+ - **Container**: Deployable/executable unit (light blue)
150
+ - **Component**: Grouping of related functionality (darker blue)
151
+ - **Relationship**: Interaction with description and technology
152
+
153
+ ### Architecture Documentation
154
+
155
+ **Architecture Decision Records (ADRs)**
156
+
157
+ **ADR Structure**
158
+ ```markdown
159
+ # ADR-NNN: Title
160
+
161
+ ## Status
162
+ [Proposed | Accepted | Deprecated | Superseded]
163
+
164
+ ## Context
165
+ What is the issue we're facing?
166
+ What factors are driving this decision?
167
+
168
+ ## Decision
169
+ What are we going to do?
170
+ What is the change we're making?
171
+
172
+ ## Consequences
173
+ What becomes easier or harder?
174
+ What are the trade-offs?
175
+ ```
176
+
177
+ **ADR Best Practices**
178
+ - One decision per ADR
179
+ - Immutable (create new ADR to reverse)
180
+ - Version controlled with code
181
+ - Short and focused
182
+ - Include date and author
183
+
184
+ **Documentation as Code**
185
+
186
+ **Benefits**
187
+ - Version controlled
188
+ - Reviewed like code
189
+ - Automated generation
190
+ - Always up-to-date
191
+ - Searchable
192
+
193
+ **Tools**
194
+ - **Markdown**: Simple, readable, version-controllable
195
+ - **AsciiDoc**: More features than Markdown
196
+ - **MkDocs**: Static site generator for documentation
197
+ - **Docusaurus**: React-based documentation framework
198
+ - **Sphinx**: Python documentation generator
199
+
200
+ **Diagram as Code**
201
+
202
+ **PlantUML**
203
+ - Text-based UML diagrams
204
+ - Supports all UML diagram types
205
+ - Integration with IDEs and CI/CD
206
+ - Version controllable
207
+
208
+ **Mermaid**
209
+ - Markdown-embedded diagrams
210
+ - Flowcharts, sequence diagrams, class diagrams
211
+ - Rendered in GitHub, GitLab, Notion
212
+ - Simple syntax
213
+
214
+ **Structurizr DSL**
215
+ - C4 model diagrams as code
216
+ - Workspace-based approach
217
+ - Multiple output formats
218
+ - Automatic layout
219
+
220
+ ---
221
+
222
+ ## Skills
223
+
224
+ ### Creating 4+1 Views
225
+
226
+ **Skill: Develop Logical View**
227
+ - Identify key abstractions (domain model)
228
+ - Define class structure and relationships
229
+ - Document design patterns used
230
+ - Show module organization
231
+
232
+ **Skill: Develop Process View**
233
+ - Identify concurrent processes
234
+ - Map process communication
235
+ - Document synchronization mechanisms
236
+ - Show runtime behavior
237
+
238
+ **Skill: Develop Development View**
239
+ - Organize code into layers/modules
240
+ - Define package dependencies
241
+ - Establish coding standards
242
+ - Document build structure
243
+
244
+ **Skill: Develop Physical View**
245
+ - Map software to hardware
246
+ - Define deployment topology
247
+ - Document network configuration
248
+ - Show scalability approach
249
+
250
+ **Skill: Create Scenarios**
251
+ - Identify key use cases
252
+ - Create sequence diagrams
253
+ - Validate architecture decisions
254
+ - Demonstrate quality attributes
255
+
256
+ ### Creating UML Diagrams
257
+
258
+ **Skill: Create Class Diagrams**
259
+ - Identify classes and relationships
260
+ - Define attributes and methods
261
+ - Show inheritance hierarchies
262
+ - Document design patterns
263
+
264
+ **Skill: Create Sequence Diagrams**
265
+ - Identify participants (objects/actors)
266
+ - Show message flow over time
267
+ - Document interaction logic
268
+ - Highlight synchronous/asynchronous calls
269
+
270
+ **Skill: Create Component Diagrams**
271
+ - Identify major components
272
+ - Define interfaces (provided/required)
273
+ - Show dependencies
274
+ - Document component responsibilities
275
+
276
+ **Skill: Create Deployment Diagrams**
277
+ - Map components to nodes
278
+ - Show network topology
279
+ - Document protocols
280
+ - Identify deployment artifacts
281
+
282
+ ### Creating C4 Diagrams
283
+
284
+ **Skill: Create System Context Diagram**
285
+ - Identify system boundary
286
+ - Show users and external systems
287
+ - Document high-level interactions
288
+ - Keep it simple (one page)
289
+
290
+ **Skill: Create Container Diagram**
291
+ - Identify containers (apps, databases, services)
292
+ - Show technology choices
293
+ - Document inter-container communication
294
+ - Highlight deployment units
295
+
296
+ **Skill: Create Component Diagram**
297
+ - Break down containers into components
298
+ - Show component responsibilities
299
+ - Document dependencies
300
+ - Identify key abstractions
301
+
302
+ **Skill: Create Code Diagrams**
303
+ - Show class structure
304
+ - Document important relationships
305
+ - Highlight design patterns
306
+ - Focus on critical areas
307
+
308
+ ### Writing ADRs
309
+
310
+ **Skill: Document Architectural Decisions**
311
+ - Identify significant decisions
312
+ - Capture context and constraints
313
+ - Document alternatives considered
314
+ - List consequences and trade-offs
315
+
316
+ **Skill: Maintain ADR Log**
317
+ - Number ADRs sequentially
318
+ - Keep ADRs immutable
319
+ - Link related ADRs
320
+ - Update index/table of contents
321
+
322
+ ### Generating Documentation
323
+
324
+ **Skill: Automate Diagram Generation**
325
+ - Generate diagrams from code
326
+ - Use PlantUML/Mermaid in CI/CD
327
+ - Keep diagrams in sync with code
328
+ - Version control diagram sources
329
+
330
+ **Skill: Create Living Documentation**
331
+ - Extract documentation from code
332
+ - Generate API documentation
333
+ - Automate architecture views
334
+ - Keep documentation current
335
+
336
+ ---
337
+
338
+ ## Examples
339
+
340
+ ### Example 1: 4+1 Views for E-Commerce Platform
341
+
342
+ **Logical View: Domain Model**
343
+
344
+ ```plantuml
345
+ @startuml
346
+ class Customer {
347
+ - id: UUID
348
+ - email: String
349
+ - name: String
350
+ + register()
351
+ + login()
352
+ }
353
+
354
+ class Product {
355
+ - id: UUID
356
+ - name: String
357
+ - price: Money
358
+ - inventory: int
359
+ + updatePrice()
360
+ + checkAvailability()
361
+ }
362
+
363
+ class Order {
364
+ - id: UUID
365
+ - customer: Customer
366
+ - items: OrderItem[]
367
+ - status: OrderStatus
368
+ - total: Money
369
+ + addItem()
370
+ + checkout()
371
+ + cancel()
372
+ }
373
+
374
+ class OrderItem {
375
+ - product: Product
376
+ - quantity: int
377
+ - price: Money
378
+ }
379
+
380
+ class Payment {
381
+ - id: UUID
382
+ - order: Order
383
+ - amount: Money
384
+ - status: PaymentStatus
385
+ + process()
386
+ + refund()
387
+ }
388
+
389
+ Customer "1" -- "*" Order
390
+ Order "1" *-- "*" OrderItem
391
+ OrderItem "*" -- "1" Product
392
+ Order "1" -- "1" Payment
393
+ @enduml
394
+ ```
395
+
396
+ **Process View: Order Processing**
397
+
398
+ ```plantuml
399
+ @startuml
400
+ participant "Web App" as Web
401
+ participant "Order Service" as Order
402
+ participant "Inventory Service" as Inventory
403
+ participant "Payment Service" as Payment
404
+ participant "Event Bus" as Events
405
+
406
+ Web -> Order: POST /orders
407
+ activate Order
408
+
409
+ Order -> Inventory: Check availability
410
+ activate Inventory
411
+ Inventory --> Order: Available
412
+ deactivate Inventory
413
+
414
+ Order -> Order: Create order (PENDING)
415
+ Order -> Events: Publish OrderCreated
416
+ activate Events
417
+ Events --> Order: Acknowledged
418
+ deactivate Events
419
+
420
+ Order --> Web: 201 Created (order_id)
421
+ deactivate Order
422
+
423
+ Events -> Payment: OrderCreated event
424
+ activate Payment
425
+ Payment -> Payment: Process payment
426
+ Payment -> Events: Publish PaymentProcessed
427
+ deactivate Payment
428
+
429
+ Events -> Order: PaymentProcessed event
430
+ activate Order
431
+ Order -> Order: Update status (CONFIRMED)
432
+ Order -> Events: Publish OrderConfirmed
433
+ deactivate Order
434
+
435
+ Events -> Inventory: OrderConfirmed event
436
+ activate Inventory
437
+ Inventory -> Inventory: Reserve stock
438
+ deactivate Inventory
439
+ @enduml
440
+ ```
441
+
442
+ **Development View: Package Structure**
443
+
444
+ ```plantuml
445
+ @startuml
446
+ package "Presentation Layer" {
447
+ [Web Controllers]
448
+ [API Gateway]
449
+ }
450
+
451
+ package "Application Layer" {
452
+ [Order Service]
453
+ [User Service]
454
+ [Product Service]
455
+ [Payment Service]
456
+ }
457
+
458
+ package "Domain Layer" {
459
+ [Order Domain]
460
+ [User Domain]
461
+ [Product Domain]
462
+ [Payment Domain]
463
+ }
464
+
465
+ package "Infrastructure Layer" {
466
+ [Repositories]
467
+ [Event Bus]
468
+ [External APIs]
469
+ }
470
+
471
+ [Web Controllers] --> [API Gateway]
472
+ [API Gateway] --> [Order Service]
473
+ [API Gateway] --> [User Service]
474
+ [API Gateway] --> [Product Service]
475
+
476
+ [Order Service] --> [Order Domain]
477
+ [User Service] --> [User Domain]
478
+ [Product Service] --> [Product Domain]
479
+ [Payment Service] --> [Payment Domain]
480
+
481
+ [Order Domain] --> [Repositories]
482
+ [User Domain] --> [Repositories]
483
+ [Product Domain] --> [Repositories]
484
+
485
+ [Payment Service] --> [External APIs]
486
+ [Order Service] --> [Event Bus]
487
+ @enduml
488
+ ```
489
+
490
+ **Physical View: Deployment**
491
+
492
+ ```plantuml
493
+ @startuml
494
+ node "Load Balancer" as LB {
495
+ }
496
+
497
+ node "Web Server 1" as Web1 {
498
+ [Web App]
499
+ }
500
+
501
+ node "Web Server 2" as Web2 {
502
+ [Web App]
503
+ }
504
+
505
+ node "API Gateway" as Gateway {
506
+ [Kong]
507
+ }
508
+
509
+ node "Kubernetes Cluster" as K8s {
510
+ node "Order Service Pod" {
511
+ [Order Service]
512
+ }
513
+ node "User Service Pod" {
514
+ [User Service]
515
+ }
516
+ node "Product Service Pod" {
517
+ [Product Service]
518
+ }
519
+ node "Payment Service Pod" {
520
+ [Payment Service]
521
+ }
522
+ }
523
+
524
+ database "PostgreSQL Cluster" as DB {
525
+ [Order DB]
526
+ [User DB]
527
+ [Product DB]
528
+ }
529
+
530
+ queue "Kafka Cluster" as Kafka {
531
+ }
532
+
533
+ LB --> Web1 : HTTPS
534
+ LB --> Web2 : HTTPS
535
+ Web1 --> Gateway : HTTPS
536
+ Web2 --> Gateway : HTTPS
537
+ Gateway --> K8s : HTTP
538
+ K8s --> DB : TCP
539
+ K8s --> Kafka : TCP
540
+ @enduml
541
+ ```
542
+
543
+ **Scenario: Place Order**
544
+
545
+ ```plantuml
546
+ @startuml
547
+ actor Customer
548
+ participant "Web App" as Web
549
+ participant "API Gateway" as Gateway
550
+ participant "Order Service" as Order
551
+ participant "Inventory Service" as Inventory
552
+ participant "Payment Service" as Payment
553
+ database "Order DB" as DB
554
+
555
+ Customer -> Web: Add items to cart
556
+ Customer -> Web: Click "Checkout"
557
+ Web -> Gateway: POST /orders
558
+ Gateway -> Order: Create order
559
+ Order -> Inventory: Check stock
560
+ Inventory --> Order: Stock available
561
+ Order -> DB: Save order (PENDING)
562
+ Order --> Gateway: Order created
563
+ Gateway --> Web: 201 Created
564
+ Web --> Customer: Show order confirmation
565
+
566
+ Order -> Payment: Process payment
567
+ Payment -> Payment: Call payment gateway
568
+ Payment --> Order: Payment successful
569
+ Order -> DB: Update status (CONFIRMED)
570
+ Order -> Customer: Send confirmation email
571
+ @enduml
572
+ ```
573
+
574
+ ### Example 2: C4 Model for Microservices Platform
575
+
576
+ **Level 1: System Context**
577
+
578
+ ```
579
+ ┌─────────────────────────────────────────────────────────────┐
580
+ │ │
581
+ │ E-Commerce Platform │
582
+ │ │
583
+ │ ┌──────────┐ ┌──────────┐ │
584
+ │ │ │ Browse products │ │ │
585
+ │ │ Customer │────────────────────────────────▶│ Web │ │
586
+ │ │ │ Place orders │ App │ │
587
+ │ │ │◀────────────────────────────────│ │ │
588
+ │ └──────────┘ └──────────┘ │
589
+ │ │
590
+ │ ┌──────────┐ ┌──────────┐ │
591
+ │ │ │ Manage products │ Admin │ │
592
+ │ │ Admin │────────────────────────────────▶│ Portal │ │
593
+ │ │ │ View reports │ │ │
594
+ │ │ │◀────────────────────────────────│ │ │
595
+ │ └──────────┘ └──────────┘ │
596
+ │ │
597
+ └─────────────────────────────────────────────────────────────┘
598
+
599
+ │ Process payments
600
+
601
+ ┌──────────────┐
602
+ │ Payment │
603
+ │ Gateway │
604
+ │ (External) │
605
+ └──────────────┘
606
+ ```
607
+
608
+ **Level 2: Container Diagram**
609
+
610
+ ```
611
+ ┌─────────────────────────────────────────────────────────────────┐
612
+ │ E-Commerce Platform │
613
+ │ │
614
+ │ ┌──────────────┐ ┌──────────────┐ │
615
+ │ │ Web App │ │ API Gateway │ │
616
+ │ │ (React) │────────▶│ (Kong) │ │
617
+ │ └──────────────┘ HTTPS └──────────────┘ │
618
+ │ │ │
619
+ │ │ HTTP │
620
+ │ ┌─────────────┼─────────────┐ │
621
+ │ │ │ │ │
622
+ │ ▼ ▼ ▼ │
623
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
624
+ │ │ Order │ │ Product │ │ User │ │
625
+ │ │ Service │ │ Service │ │ Service │ │
626
+ │ │ (Node.js)│ │ (Node.js)│ │ (Node.js)│ │
627
+ │ └──────────┘ └──────────┘ └──────────┘ │
628
+ │ │ │ │ │
629
+ │ │ │ │ │
630
+ │ ▼ ▼ ▼ │
631
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
632
+ │ │ Order DB │ │Product DB│ │ User DB │ │
633
+ │ │(Postgres)│ │(Postgres)│ │(Postgres)│ │
634
+ │ └──────────┘ └──────────┘ └──────────┘ │
635
+ │ │
636
+ │ ┌────────────────────────────────────┐ │
637
+ │ │ Event Bus (Kafka) │ │
638
+ │ └────────────────────────────────────┘ │
639
+ │ │
640
+ └─────────────────────────────────────────────────────────────────┘
641
+ ```
642
+
643
+ **Level 3: Component Diagram (Order Service)**
644
+
645
+ ```
646
+ ┌─────────────────────────────────────────────────────────────┐
647
+ │ Order Service │
648
+ │ │
649
+ │ ┌──────────────────┐ │
650
+ │ │ Order Controller │ │
651
+ │ │ (REST API) │ │
652
+ │ └────────┬─────────┘ │
653
+ │ │ │
654
+ │ ▼ │
655
+ │ ┌──────────────────┐ ┌──────────────────┐ │
656
+ │ │ Order Use Cases │────────▶│ Order Domain │ │
657
+ │ │ (Application) │ │ (Entities) │ │
658
+ │ └────────┬─────────┘ └──────────────────┘ │
659
+ │ │ │
660
+ │ ▼ │
661
+ │ ┌──────────────────┐ ┌──────────────────┐ │
662
+ │ │Order Repository │────────▶│ Order DB │ │
663
+ │ │ (Interface) │ │ (PostgreSQL) │ │
664
+ │ └──────────────────┘ └──────────────────┘ │
665
+ │ │
666
+ │ ┌──────────────────┐ ┌──────────────────┐ │
667
+ │ │ Event Publisher │────────▶│ Event Bus │ │
668
+ │ │ │ │ (Kafka) │ │
669
+ │ └──────────────────┘ └──────────────────┘ │
670
+ │ │
671
+ └─────────────────────────────────────────────────────────────┘
672
+ ```
673
+
674
+ ### Example 3: PlantUML Sequence Diagram
675
+
676
+ ```plantuml
677
+ @startuml
678
+ title User Authentication Flow
679
+
680
+ actor User
681
+ participant "Web App" as Web
682
+ participant "Auth Service" as Auth
683
+ participant "User Service" as UserSvc
684
+ database "User DB" as DB
685
+ participant "Token Service" as Token
686
+
687
+ User -> Web: Enter credentials
688
+ activate Web
689
+
690
+ Web -> Auth: POST /auth/login
691
+ activate Auth
692
+
693
+ Auth -> UserSvc: Validate credentials
694
+ activate UserSvc
695
+
696
+ UserSvc -> DB: SELECT user WHERE email = ?
697
+ activate DB
698
+ DB --> UserSvc: User record
699
+ deactivate DB
700
+
701
+ UserSvc -> UserSvc: Verify password hash
702
+ UserSvc --> Auth: User validated
703
+ deactivate UserSvc
704
+
705
+ Auth -> Token: Generate JWT
706
+ activate Token
707
+ Token -> Token: Sign token with secret
708
+ Token --> Auth: JWT token
709
+ deactivate Token
710
+
711
+ Auth --> Web: 200 OK (token, user)
712
+ deactivate Auth
713
+
714
+ Web -> Web: Store token in localStorage
715
+ Web --> User: Redirect to dashboard
716
+ deactivate Web
717
+
718
+ == Subsequent Requests ==
719
+
720
+ User -> Web: Access protected resource
721
+ activate Web
722
+
723
+ Web -> Auth: GET /api/orders\nAuthorization: Bearer <token>
724
+ activate Auth
725
+
726
+ Auth -> Token: Verify JWT
727
+ activate Token
728
+ Token -> Token: Validate signature
729
+ Token -> Token: Check expiration
730
+ Token --> Auth: Token valid (user_id)
731
+ deactivate Token
732
+
733
+ Auth -> UserSvc: GET /users/{user_id}/orders
734
+ activate UserSvc
735
+ UserSvc -> DB: SELECT orders WHERE user_id = ?
736
+ activate DB
737
+ DB --> UserSvc: Orders
738
+ deactivate DB
739
+ UserSvc --> Auth: Orders data
740
+ deactivate UserSvc
741
+
742
+ Auth --> Web: 200 OK (orders)
743
+ deactivate Auth
744
+
745
+ Web --> User: Display orders
746
+ deactivate Web
747
+
748
+ @enduml
749
+ ```
750
+
751
+ ### Example 4: Mermaid Class Diagram
752
+
753
+ ```mermaid
754
+ classDiagram
755
+ class Order {
756
+ -UUID id
757
+ -Customer customer
758
+ -List~OrderItem~ items
759
+ -OrderStatus status
760
+ -Money total
761
+ +addItem(product, quantity)
762
+ +removeItem(productId)
763
+ +checkout()
764
+ +cancel()
765
+ +calculateTotal() Money
766
+ }
767
+
768
+ class OrderItem {
769
+ -Product product
770
+ -int quantity
771
+ -Money price
772
+ +updateQuantity(quantity)
773
+ +getSubtotal() Money
774
+ }
775
+
776
+ class Product {
777
+ -UUID id
778
+ -String name
779
+ -String description
780
+ -Money price
781
+ -int inventory
782
+ +updatePrice(price)
783
+ +checkAvailability(quantity) bool
784
+ +reserveStock(quantity)
785
+ }
786
+
787
+ class Customer {
788
+ -UUID id
789
+ -String email
790
+ -String name
791
+ -Address address
792
+ +register()
793
+ +updateProfile()
794
+ }
795
+
796
+ class Payment {
797
+ -UUID id
798
+ -Order order
799
+ -Money amount
800
+ -PaymentStatus status
801
+ -String transactionId
802
+ +process()
803
+ +refund()
804
+ +verify() bool
805
+ }
806
+
807
+ class OrderStatus {
808
+ <<enumeration>>
809
+ PENDING
810
+ CONFIRMED
811
+ SHIPPED
812
+ DELIVERED
813
+ CANCELLED
814
+ }
815
+
816
+ class PaymentStatus {
817
+ <<enumeration>>
818
+ PENDING
819
+ PROCESSING
820
+ COMPLETED
821
+ FAILED
822
+ REFUNDED
823
+ }
824
+
825
+ Order "1" *-- "*" OrderItem : contains
826
+ OrderItem "*" --> "1" Product : references
827
+ Order "*" --> "1" Customer : placed by
828
+ Order "1" --> "1" Payment : paid with
829
+ Order --> OrderStatus : has
830
+ Payment --> PaymentStatus : has
831
+ ```
832
+
833
+ ### Example 5: Architecture Decision Record
834
+
835
+ ```markdown
836
+ # ADR-003: Use Event-Driven Architecture for Order Processing
837
+
838
+ ## Status
839
+ Accepted
840
+
841
+ ## Date
842
+ 2026-02-05
843
+
844
+ ## Context
845
+ Our current order processing system uses synchronous REST API calls between services:
846
+ - Order Service → Inventory Service (check stock)
847
+ - Order Service → Payment Service (process payment)
848
+ - Order Service → Notification Service (send emails)
849
+
850
+ **Problems:**
851
+ 1. **Tight Coupling**: Order Service depends on availability of all downstream services
852
+ 2. **Cascading Failures**: If Payment Service is down, entire order flow fails
853
+ 3. **Performance**: Synchronous calls increase latency (300ms+ per order)
854
+ 4. **Scalability**: Difficult to scale individual services independently
855
+
856
+ **Requirements:**
857
+ - Decouple services for independent deployment
858
+ - Improve resilience (handle partial failures)
859
+ - Reduce order processing latency
860
+ - Enable asynchronous workflows
861
+
862
+ ## Decision
863
+ We will implement event-driven architecture using Apache Kafka for order processing:
864
+
865
+ **Architecture:**
866
+ ```
867
+ Order Service → Kafka → [Inventory, Payment, Notification] Services
868
+ ```
869
+
870
+ **Event Flow:**
871
+ 1. Order Service publishes `OrderCreated` event
872
+ 2. Inventory Service subscribes and reserves stock
873
+ 3. Payment Service subscribes and processes payment
874
+ 4. Notification Service subscribes and sends confirmation
875
+
876
+ **Implementation:**
877
+ - **Event Bus**: Apache Kafka (3 brokers, replication factor 3)
878
+ - **Event Schema**: Avro with Schema Registry
879
+ - **Retry Strategy**: Exponential backoff with dead letter queue
880
+ - **Idempotency**: Event deduplication using event IDs
881
+ - **Monitoring**: Kafka lag monitoring, event tracing
882
+
883
+ **Event Schema Example:**
884
+ ```json
885
+ {
886
+ "type": "record",
887
+ "name": "OrderCreated",
888
+ "fields": [
889
+ {"name": "orderId", "type": "string"},
890
+ {"name": "customerId", "type": "string"},
891
+ {"name": "items", "type": {"type": "array", "items": "OrderItem"}},
892
+ {"name": "total", "type": "double"},
893
+ {"name": "timestamp", "type": "long"}
894
+ ]
895
+ }
896
+ ```
897
+
898
+ ## Consequences
899
+
900
+ ### Positive
901
+ ✅ **Loose Coupling**: Services don't need to know about each other
902
+ ✅ **Resilience**: Services can fail independently without affecting others
903
+ ✅ **Scalability**: Easy to add new consumers without changing producers
904
+ ✅ **Performance**: Asynchronous processing reduces latency (100ms vs 300ms)
905
+ ✅ **Audit Trail**: All events are logged in Kafka for debugging
906
+ ✅ **Flexibility**: Easy to add new event consumers (analytics, reporting)
907
+
908
+ ### Negative
909
+ ❌ **Complexity**: More moving parts (Kafka cluster, schema registry)
910
+ ❌ **Eventual Consistency**: Order status updates are not immediate
911
+ ❌ **Debugging**: Harder to trace requests across services
912
+ ❌ **Operational Overhead**: Need to manage Kafka infrastructure
913
+ ❌ **Learning Curve**: Team needs to learn event-driven patterns
914
+
915
+ ### Mitigation Strategies
916
+ - **Distributed Tracing**: Implement OpenTelemetry for request tracing
917
+ - **Event Versioning**: Use Avro schema evolution for backward compatibility
918
+ - **Monitoring**: Set up Kafka lag alerts and event processing metrics
919
+ - **Documentation**: Create event catalog documenting all events
920
+ - **Testing**: Implement contract testing for event schemas
921
+
922
+ ## Alternatives Considered
923
+
924
+ ### Alternative 1: Keep Synchronous REST
925
+ - **Pros**: Simpler, easier to debug, immediate consistency
926
+ - **Cons**: Tight coupling, cascading failures, poor scalability
927
+ - **Rejected**: Doesn't address core problems
928
+
929
+ ### Alternative 2: Use Message Queue (RabbitMQ)
930
+ - **Pros**: Simpler than Kafka, good for task queues
931
+ - **Cons**: Not designed for event streaming, limited retention
932
+ - **Rejected**: Kafka better for event sourcing and replay
933
+
934
+ ### Alternative 3: Use AWS EventBridge
935
+ - **Pros**: Managed service, no infrastructure
936
+ - **Cons**: Vendor lock-in, higher cost at scale
937
+ - **Rejected**: Want to avoid cloud vendor lock-in
938
+
939
+ ## Implementation Plan
940
+
941
+ **Phase 1: Infrastructure (Week 1-2)**
942
+ - Set up Kafka cluster (3 brokers)
943
+ - Configure Schema Registry
944
+ - Set up monitoring (Prometheus + Grafana)
945
+
946
+ **Phase 2: Order Service (Week 3-4)**
947
+ - Implement event publishing
948
+ - Add event schema definitions
949
+ - Update order creation flow
950
+
951
+ **Phase 3: Consumer Services (Week 5-6)**
952
+ - Migrate Inventory Service to event consumer
953
+ - Migrate Payment Service to event consumer
954
+ - Migrate Notification Service to event consumer
955
+
956
+ **Phase 4: Testing & Rollout (Week 7-8)**
957
+ - Integration testing
958
+ - Load testing
959
+ - Gradual rollout (10% → 50% → 100%)
960
+
961
+ ## References
962
+ - "Designing Event-Driven Systems" by Ben Stopford
963
+ - "Building Event-Driven Microservices" by Adam Bellemare
964
+ - Kafka Documentation: https://kafka.apache.org/documentation/
965
+ - Event-Driven Architecture Pattern: https://martinfowler.com/articles/201701-event-driven.html
966
+ ```
967
+
968
+ ### Example 6: Automated Documentation with MkDocs
969
+
970
+ **mkdocs.yml**
971
+ ```yaml
972
+ site_name: E-Commerce Platform Architecture
973
+ site_description: Architecture documentation for e-commerce platform
974
+ site_author: Architecture Team
975
+
976
+ theme:
977
+ name: material
978
+ palette:
979
+ primary: indigo
980
+ accent: indigo
981
+ features:
982
+ - navigation.tabs
983
+ - navigation.sections
984
+ - toc.integrate
985
+ - search.suggest
986
+
987
+ nav:
988
+ - Home: index.md
989
+ - Architecture:
990
+ - Overview: architecture/overview.md
991
+ - System Context: architecture/system-context.md
992
+ - Containers: architecture/containers.md
993
+ - Components: architecture/components.md
994
+ - Design Decisions:
995
+ - ADR Index: decisions/index.md
996
+ - ADR-001 Microservices: decisions/adr-001-microservices.md
997
+ - ADR-002 Database Per Service: decisions/adr-002-database-per-service.md
998
+ - ADR-003 Event-Driven: decisions/adr-003-event-driven.md
999
+ - API Documentation:
1000
+ - Order Service: api/order-service.md
1001
+ - Product Service: api/product-service.md
1002
+ - User Service: api/user-service.md
1003
+ - Deployment:
1004
+ - Infrastructure: deployment/infrastructure.md
1005
+ - CI/CD Pipeline: deployment/cicd.md
1006
+ - Monitoring: deployment/monitoring.md
1007
+
1008
+ plugins:
1009
+ - search
1010
+ - mermaid2
1011
+ - plantuml
1012
+
1013
+ markdown_extensions:
1014
+ - admonition
1015
+ - codehilite
1016
+ - toc:
1017
+ permalink: true
1018
+ - pymdownx.superfences:
1019
+ custom_fences:
1020
+ - name: mermaid
1021
+ class: mermaid
1022
+ format: !!python/name:pymdownx.superfences.fence_code_format
1023
+ ```
1024
+
1025
+ **docs/architecture/overview.md**
1026
+ ```markdown
1027
+ # Architecture Overview
1028
+
1029
+ ## System Context
1030
+
1031
+ ```mermaid
1032
+ graph TB
1033
+ Customer[Customer]
1034
+ Admin[Administrator]
1035
+ Platform[E-Commerce Platform]
1036
+ Payment[Payment Gateway]
1037
+ Email[Email Service]
1038
+
1039
+ Customer -->|Browse & Purchase| Platform
1040
+ Admin -->|Manage| Platform
1041
+ Platform -->|Process Payments| Payment
1042
+ Platform -->|Send Notifications| Email
1043
+ ```
1044
+
1045
+ ## Container Diagram
1046
+
1047
+ See [Containers](containers.md) for detailed container architecture.
1048
+
1049
+ ## Key Architectural Decisions
1050
+
1051
+ - [ADR-001: Microservices Architecture](../decisions/adr-001-microservices.md)
1052
+ - [ADR-002: Database Per Service](../decisions/adr-002-database-per-service.md)
1053
+ - [ADR-003: Event-Driven Architecture](../decisions/adr-003-event-driven.md)
1054
+
1055
+ ## Quality Attributes
1056
+
1057
+ | Attribute | Target | Measurement |
1058
+ |-----------|--------|-------------|
1059
+ | Availability | 99.9% | Uptime monitoring |
1060
+ | Latency | < 200ms | P95 response time |
1061
+ | Throughput | 1000 req/s | Load testing |
1062
+ | Scalability | 10x traffic | Horizontal scaling |
1063
+ ```
1064
+
1065
+ ---
1066
+
1067
+ ## Understanding
1068
+
1069
+ ### When to Use 4+1 Views
1070
+
1071
+ **Use 4+1 Views When:**
1072
+ - Complex system with multiple stakeholders
1073
+ - Need to address different concerns (functionality, deployment, development)
1074
+ - Large team with specialized roles
1075
+ - Regulatory documentation requirements
1076
+
1077
+ **Don't Use 4+1 Views When:**
1078
+ - Simple system with few components
1079
+ - Small team (everyone understands everything)
1080
+ - Rapid prototyping phase
1081
+ - Overkill for the project size
1082
+
1083
+ ### When to Use UML vs C4
1084
+
1085
+ **Use UML When:**
1086
+ - Detailed design documentation needed
1087
+ - Team familiar with UML
1088
+ - Tool support available
1089
+ - Formal modeling required
1090
+
1091
+ **Use C4 When:**
1092
+ - Need simple, accessible diagrams
1093
+ - Communicating with non-technical stakeholders
1094
+ - Want to avoid UML complexity
1095
+ - Focus on architecture over design
1096
+
1097
+ **Use Both:**
1098
+ - C4 for high-level architecture
1099
+ - UML for detailed design
1100
+
1101
+ ### ADR Best Practices
1102
+
1103
+ **Do:**
1104
+ - Write ADRs for significant decisions
1105
+ - Keep ADRs short and focused
1106
+ - Version control with code
1107
+ - Link related ADRs
1108
+ - Include consequences (positive and negative)
1109
+
1110
+ **Don't:**
1111
+ - Document trivial decisions
1112
+ - Modify existing ADRs (create new one)
1113
+ - Write ADRs after implementation
1114
+ - Skip alternatives considered
1115
+ - Forget to update ADR index
1116
+
1117
+ ### Documentation Automation
1118
+
1119
+ **Automate:**
1120
+ - Diagram generation from code
1121
+ - API documentation from OpenAPI specs
1122
+ - Architecture views from models
1123
+ - Dependency graphs
1124
+ - Metrics and dashboards
1125
+
1126
+ **Don't Automate:**
1127
+ - Architectural decisions (ADRs)
1128
+ - Design rationale
1129
+ - Trade-off analysis
1130
+ - Stakeholder concerns
1131
+
1132
+ ### Common Pitfalls
1133
+
1134
+ **4+1 Views Pitfalls:**
1135
+ - Creating all views when not needed
1136
+ - Views not aligned with each other
1137
+ - Too much detail in early stages
1138
+ - Forgetting scenarios (+1)
1139
+
1140
+ **UML Pitfalls:**
1141
+ - Over-complicating diagrams
1142
+ - Using wrong diagram type
1143
+ - Too much detail
1144
+ - Not keeping diagrams updated
1145
+
1146
+ **C4 Pitfalls:**
1147
+ - Skipping levels (going straight to code)
1148
+ - Inconsistent notation
1149
+ - Too many elements per diagram
1150
+ - Not defining boundaries clearly
1151
+
1152
+ **ADR Pitfalls:**
1153
+ - Writing ADRs after the fact
1154
+ - Not documenting alternatives
1155
+ - Modifying existing ADRs
1156
+ - Missing consequences
1157
+
1158
+ ---
1159
+
1160
+ ## References
1161
+
1162
+ ### 4+1 View Model
1163
+ - **Paper**: "Architectural Blueprints—The '4+1' View Model of Software Architecture" by Philippe Kruchten
1164
+ - **Book**: "Software Architecture in Practice" by Bass, Clements, Kazman
1165
+
1166
+ ### UML
1167
+ - **Official**: OMG UML Specification: https://www.omg.org/spec/UML/
1168
+ - **Books**:
1169
+ - "UML Distilled" by Martin Fowler
1170
+ - "Applying UML and Patterns" by Craig Larman
1171
+ - **Tools**: PlantUML, StarUML, Visual Paradigm
1172
+
1173
+ ### C4 Model
1174
+ - **Official**: https://c4model.com/
1175
+ - **Tools**:
1176
+ - Structurizr: https://structurizr.com/
1177
+ - PlantUML C4: https://github.com/plantuml-stdlib/C4-PlantUML
1178
+ - Mermaid: https://mermaid-js.github.io/
1179
+
1180
+ ### ADRs
1181
+ - **GitHub**: https://adr.github.io/
1182
+ - **Tools**:
1183
+ - adr-tools: https://github.com/npryce/adr-tools
1184
+ - log4brains: https://github.com/thomvaill/log4brains
1185
+ - **Templates**: https://github.com/joelparkerhenderson/architecture-decision-record
1186
+
1187
+ ### Documentation Tools
1188
+ - **MkDocs**: https://www.mkdocs.org/
1189
+ - **Docusaurus**: https://docusaurus.io/
1190
+ - **Sphinx**: https://www.sphinx-doc.org/
1191
+ - **AsciiDoc**: https://asciidoc.org/
1192
+
1193
+ ### Related Architecture Documents
1194
+ - [Fundamentals](./fundamentals.md) - Core architectural elements
1195
+ - [Tools and Methodologies](./tools-methodologies.md) - TOGAF, DDD, CI/CD
1196
+ - [Quality Attributes](./quality-attributes.md) - Non-functional requirements
1197
+ - [Microservices Architecture](./microservices-architecture.md) - Microservices patterns
1198
+
1199
+