Skip to content

Commit 077bed7

Browse files
authored
Merge pull request #166 from cosmicpython/tweakdiags
Mess about with plantuml diagram styling.
2 parents bcdd857 + 83437b3 commit 077bed7

28 files changed

+152
-68
lines changed

chapter_01_domain_model.asciidoc

+27-17
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,15 @@ image::images/allocation_context_diagram.png[]
122122
----
123123
[plantuml, allocation_context_diagram]
124124
@startuml Allocation Context Diagram
125-
!includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/master/C4.puml
126125
!includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/master/C4_Context.puml
127126
127+
skinparam roundCorner 20
128+
skinparam Padding 2
129+
skinparam wrapWidth 200
130+
skinparam default {
131+
FontName Guardian Sans Cond Regular
132+
}
133+
128134
System(systema, "Allocation", "Allocates stock to customer orders")
129135
130136
Person(customer, "Customer", "Wants to buy furniture")
@@ -145,8 +151,6 @@ Rel_U(warehouse, customer, "Dispatches goods to")
145151
@enduml
146152
----
147153

148-
//TODO: illustration text is cut off
149-
150154
For the purposes of this book, we're imagining a situation where the business
151155
decides to implement an exciting new way of allocating stock. Until now, the
152156
business has been presenting stock and lead times based on what is physically
@@ -455,20 +459,26 @@ class Batch:
455459
image::images/model_diagram.png[]
456460
[role="image-source"]
457461
----
458-
[ditaa, model_diagram]
459-
+=====================+
460-
| Batch |
461-
+---------------------+
462-
| reference |
463-
| sku |
464-
| eta |
465-
| _purchased_quantity | +=============+
466-
| _allocations ------------->>| OrderLine |
467-
+---------------------+ +-------------+
468-
| order_id |
469-
| sku |
470-
| qty |
471-
+-------------+
462+
[plantuml, model_diagram, config=plantuml.cfg]
463+
464+
left to right direction
465+
hide empty members
466+
467+
class Batch {
468+
reference
469+
sku
470+
eta
471+
_purchased_quantity
472+
_allocations
473+
}
474+
475+
class OrderLine {
476+
order_id
477+
sku
478+
qty
479+
}
480+
481+
Batch::_allocations o-- OrderLine
472482
----
473483

474484

chapter_02_repository.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ allowing us to decouple our model layer from the data layer. We'll see a
99
concrete example of how this simplifying abstraction makes our system more
1010
testable by hiding the complexities of the database.
1111

12-
<<chapter_02_class_diagram>> shows a little preview of what we're going to
12+
<<repository_class_diagram>> shows a little preview of what we're going to
1313
build: a `Repository` class that sits between `SqlAlchemy` (our ORM) and our
1414
Domain Model's `Batch` classes.
1515

16-
[[chapter_02_class_diagram]]
16+
[[repository_class_diagram]]
1717
.Batch, Repository and SqlAlchemy
18-
image::images/chapter_02_class_diagram.png[]
18+
image::images/repository_class_diagram.png[]
1919
[role="image-source"]
2020
----
21-
[plantuml, chapter_02_class_diagram]
21+
[plantuml, repository_class_diagram, config=plantuml.cfg]
2222
@startuml
2323
2424
package allocation {

chapter_04_service_layer.asciidoc

+25-19
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,34 @@ By the end of this chapter, we'll have added a Flask API that will talk to
1717
the Service Layer, which will serve as the entrypoint to our Domain Model.
1818
By making the service layer depend on the `AbstractRepository`, we'll be
1919
able to unit test it using `FakeRepository`, and then run it in real life
20-
using `SqlAlchemyRepository`. <<chapter_03_class_diagram>> is a class
20+
using `SqlAlchemyRepository`. <<service_layer_class_diagram>> is a class
2121
diagram showing where we're heading.
2222

23-
[[chapter_03_class_diagram]]
23+
[[service_layer_class_diagram]]
2424
.Our target architecture for the end of this chapter
25-
image::images/chapter_03_class_diagram.png[]
25+
image::images/service_layer_class_diagram.png[]
2626

2727
[role="image-source"]
2828
----
29-
[plantuml, chapter_03_class_diagram]
29+
[plantuml, service_layer_class_diagram, config=plantuml.cfg]
3030
@startuml
31+
hide empty members
32+
left to right direction
3133
32-
package api {
34+
package "Flask API" as api {
3335
34-
class Flask {
35-
allocate_endpoint()
36+
class "allocate_endpoint()" as allocate_endpoint {
3637
}
38+
hide allocate_endpoint circle
3739
}
3840
39-
package sqlalchemy {
40-
class Session {
41-
query()
42-
add()
43-
}
44-
}
4541
4642
package allocation {
4743
48-
class services {
49-
allocate(line, repository, session)
44+
package services {
45+
class "allocate(line, repository, session)" as allocate {
46+
}
47+
hide allocate circle
5048
}
5149
5250
abstract class AbstractRepository {
@@ -61,7 +59,7 @@ package allocation {
6159
6260
6361
class FakeRepository {
64-
batches: List<Batch>
62+
batches: List[Batch]
6563
}
6664
6765
class BatchRepository {
@@ -70,14 +68,22 @@ package allocation {
7068
7169
}
7270
73-
services -> AbstractRepository: uses
71+
package sqlalchemy {
72+
class Session {
73+
query()
74+
add()
75+
}
76+
}
77+
78+
79+
allocate -> AbstractRepository: uses
7480
AbstractRepository -> Batch : stores
7581
7682
AbstractRepository <|-- FakeRepository : implements
7783
AbstractRepository <|-- BatchRepository : implements
78-
Flask --> services : invokes
84+
allocate_endpoint --> allocate : invokes
7985
80-
BatchRepository ---> Session : abstracts
86+
BatchRepository --> Session : abstracts
8187
@enduml
8288
----
8389

chapter_06_aggregate.asciidoc

+23-13
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,27 @@ service (<<chapter_08_before_diagram>>):
1818
image::images/before_aggregates_diagram.png[]
1919
[role="image-source"]
2020
----
21-
[plantuml, before_aggregates_diagram]
21+
[plantuml, before_aggregates_diagram, config=plantuml.cfg]
2222
@startuml
2323
24-
class services {
25-
allocate()
24+
package "Service Layer" as services {
25+
class "allocate()" as allocate {
26+
}
2627
}
2728
29+
hide allocate circle
30+
hide allocate members
31+
2832
29-
package domain_model {
33+
package "Domain Model" as domain_model {
3034
3135
class Batch {
3236
}
3337
34-
class allocate {
38+
class "allocate()" as allocate_domain_service {
3539
}
40+
hide allocate_domain_service circle
41+
hide allocate_domain_service members
3642
}
3743
3844
@@ -45,7 +51,7 @@ package repositories {
4551
}
4652
4753
services -> BatchRepository: list all batches
48-
services --> allocate: allocate(orderline, batches)
54+
services --> allocate_domain_service: allocate(orderline, batches)
4955
5056
@enduml
5157
----
@@ -59,15 +65,19 @@ allocate against (<<after_aggregates_diagram>>):
5965
image::images/after_aggregates_diagram.png[]
6066
[role="image-source"]
6167
----
62-
[plantuml, after_aggregates_diagram]
68+
[plantuml, after_aggregates_diagram, config=plantuml.cfg]
6369
@startuml
6470
65-
class services {
66-
allocate()
71+
package "Service Layer" as services {
72+
class "allocate()" as allocate {
73+
}
6774
}
6875
76+
hide allocate circle
77+
hide allocate members
78+
6979
70-
package domain_model {
80+
package "Domain Model" as domain_model {
7181
7282
class Product {
7383
allocate()
@@ -87,8 +97,8 @@ package repositories {
8797
}
8898
8999
services -> ProductRepository: get me the product for this sku
90-
services --> Product: allocate(orderline)
91-
Product o-- Batch: has
100+
services --> Product: product.allocate(orderline)
101+
Product o- Batch: has
92102
93103
@enduml
94104
----
@@ -480,7 +490,7 @@ with `version=4`, and the other update will be rejected.
480490
image::images/version_numbers_sequence_diagram.png[]
481491
[role="image-source"]
482492
----
483-
[plantuml, version_numbers_sequence_diagram]
493+
[plantuml, version_numbers_sequence_diagram, config=plantuml.cfg]
484494
@startuml
485495
486496
entity Model

chapter_08_all_messagebus.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ back to our existing handler for allocation, to be re-allocated.
466466
image::images/reallocation_sequence_diagram.png[]
467467
[role="image-source"]
468468
----
469-
[plantuml, reallocation_sequence_diagram]
469+
[plantuml, reallocation_sequence_diagram, config=plantuml.cfg]
470470
@startuml
471471
API -> MessageBus : BatchQuantityChanged event
472472

chapter_10_external_events.asciidoc

+13-12
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,20 @@ we've named our system after a noun, _batches_, instead of _allocation_).
7272
image::images/batches_context_diagram.png[]
7373
[role="image-source"]
7474
----
75-
[plantuml, batches_context_diagram]
75+
[plantuml, batches_context_diagram, config=plantuml.cfg]
7676
@startuml Batches Context Diagram
77-
!includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/master/C4.puml
7877
!includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/master/C4_Context.puml
7978
80-
System(batches, "Batches", "Knows about available stock")
79+
skinparam roundCorner 20
8180
81+
System(batches, "Batches", "Knows about available stock")
8282
Person(customer, "Customer", "Wants to buy furniture")
83-
8483
System(orders, "Orders", "Knows about customer orders")
8584
System(warehouse, "Warehouse", "Knows about shipping instructions")
8685
87-
Rel(customer, orders, "Places order with")
88-
Rel(orders, batches, "Reserves stock with")
89-
Rel(batches, warehouse, "Sends instructions to")
86+
Rel_R(customer, orders, "Places order with")
87+
Rel_D(orders, batches, "Reserves stock with")
88+
Rel_D(batches, warehouse, "Sends instructions to")
9089
9190
@enduml
9291
----
@@ -105,7 +104,7 @@ order, we want to update the customer record to flag them as a VIP.
105104
image::images/command_flow_diagram_1.png[]
106105
[role="image-source"]
107106
----
108-
[plantuml, command_flow_diagram_1]
107+
[plantuml, command_flow_diagram_1, config=plantuml.cfg]
109108
@startuml
110109
111110
actor Customer
@@ -180,7 +179,7 @@ should own this process, as shown in <<command_flow_diagram_2>>?
180179
image::images/command_flow_diagram_2.png[]
181180
[role="image-source"]
182181
----
183-
[plantuml, command_flow_diagram_2]
182+
[plantuml, command_flow_diagram_2, config=plantuml.cfg]
184183
@startuml
185184
186185
actor w as "Warehouse worker"
@@ -221,7 +220,7 @@ right after we take a user's order for 3 MISBEGOTTEN-RUG,
221220
image::images/command_flow_diagram_with_error.png[]
222221
[role="image-source"]
223222
----
224-
[plantuml, command_flow_diagram_with_error]
223+
[plantuml, command_flow_diagram_with_error, config=plantuml.cfg]
225224
@startuml
226225
227226
actor Customer
@@ -344,11 +343,13 @@ Our new flow will look like this:
344343

345344
[[reallocation_sequence_diagram_with_redis]]
346345
.Sequence diagram for reallocation flow
347-
image::images/reallocation_sequence_diagram.png[]
346+
image::images/reallocation_sequence_diagram_with_redis.png[]
348347
[role="image-source"]
349348
----
350-
[plantuml, reallocation_sequence_diagram]
349+
[plantuml, reallocation_sequence_diagram_with_redis, config=plantuml.cfg]
350+
351351
@startuml
352+
352353
Redis -> MessageBus : BatchQuantityChanged event
353354
354355
group BatchQuantityChanged Handler + Unit of Work 1

chapter_11_cqrs.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ to update the read model, which the GET/read operation can use.
497497
image::images/read_model_sequence_diagram.png[]
498498
[role="image-source"]
499499
----
500-
[plantuml, read_model_sequence_diagram]
500+
[plantuml, read_model_sequence_diagram, config=plantuml.cfg]
501501
@startuml
502502
actor User order 1
503503
boundary Flask order 2
-52.3 KB
Binary file not shown.

diagrams/Chapter2ClassDiagram.png

-15 KB
Binary file not shown.

diagrams/Chapter3ClassDiagram.png

-40.4 KB
Binary file not shown.

images/after_aggregates_diagram.png

5.88 KB
Loading

images/allocation_context_diagram.png

560 Bytes
Loading

images/batches_context_diagram.png

6.25 KB
Loading

images/before_aggregates_diagram.png

4.58 KB
Loading

images/chapter_02_class_diagram.png

-14.2 KB
Binary file not shown.

images/chapter_03_class_diagram.png

-33.4 KB
Binary file not shown.

images/command_flow_diagram_1.png

5.85 KB
Loading

images/command_flow_diagram_2.png

4.51 KB
Loading
2.39 KB
Loading

images/model_diagram.png

2.65 KB
Loading
11.1 KB
Loading
6.34 KB
Loading
Loading

images/repository_class_diagram.png

19.6 KB
Loading
47.8 KB
Loading
8.54 KB
Loading

plantuml.cfg

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
skinparam default {
2+
FontName Guardian Sans Cond Regular
3+
FontSize 18
4+
FontColor Black
5+
}
6+
7+
skinparam class {
8+
BackgroundColor Lavender
9+
BorderColor RoyalBlue
10+
}
11+
skinparam package {
12+
FontName Guardian Sans Cond Light
13+
}
14+
15+
skinparam sequencelifeline {
16+
BorderColor RoyalBlue
17+
}
18+
skinparam arrow {
19+
Color RoyalBlue
20+
}
21+
skinparam participant {
22+
BackgroundColor Lavender
23+
BorderColor RoyalBlue
24+
}
25+
skinparam entity {
26+
BackgroundColor Lavender
27+
BorderColor RoyalBlue
28+
}
29+
skinparam collections {
30+
BackgroundColor Lavender
31+
BorderColor RoyalBlue
32+
}
33+
skinparam database {
34+
BackgroundColor Lavender
35+
BorderColor RoyalBlue
36+
}
37+
skinparam boundary {
38+
BackgroundColor Lavender
39+
BorderColor RoyalBlue
40+
}
41+
skinparam actor {
42+
Color DeepSkyBlue
43+
BackgroundColor Lavender
44+
BorderColor RoyalBlue
45+
}
46+
skinparam sequencegroupheader {
47+
FontName Guardian Sans Cond Light
48+
}
49+
skinparam padding 4

0 commit comments

Comments
 (0)