Skip to content

Commit 6594d7b

Browse files
committed
GH-6 - More reference documentation.
1 parent 615c72b commit 6594d7b

File tree

6 files changed

+270
-24
lines changed

6 files changed

+270
-24
lines changed

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ limitations under the License.
266266
<artifactId>asciidoctorj</artifactId>
267267
<version>2.5.3</version>
268268
</dependency>
269+
<dependency>
270+
<groupId>org.asciidoctor</groupId>
271+
<artifactId>asciidoctorj-diagram</artifactId>
272+
<version>2.2.3</version>
273+
</dependency>
269274
<dependency>
270275
<groupId>io.spring.asciidoctor.backends</groupId>
271276
<artifactId>spring-asciidoctor-backends</artifactId>
@@ -309,6 +314,9 @@ limitations under the License.
309314
<toclevels>4</toclevels>
310315
<numbered>true</numbered>
311316
</attributes>
317+
<requires>
318+
<require>asciidoctor-diagram</require>
319+
</requires>
312320
</configuration>
313321

314322
</plugin>

src/docs/asciidoc/00-preface.adoc

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,35 @@
22
[[preface]]
33
= Preface
44

5-
[[preface.subheadline]]
6-
== Subheadline
7-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
8-
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
9-
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
10-
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
5+
[[preface.project-metadata]]
6+
== Project Metadata
117

8+
* Version control https://github.com/spring-projects-experimental/spring-modulith
9+
* Bug tracker: https://github.com/spring-projects-experimental/spring-modulith
10+
* Release repository: Maven central
11+
* Milestone repository: https://repo.spring.io/milestone
12+
* Snapshot repository: https://repo.spring.io/snapshot
13+
14+
== Using Spring Modulith
15+
16+
Spring Modulith consists of a set of libraries that can be used individually and depending on which features of it you would like to use.
17+
To ease the declaration of the individual modules, we recommend to declare the following BOM in you Maven POM:
18+
19+
.Using the Spring Modulith BOM
20+
[source, xml, subs="+attributes"]
21+
----
22+
<dependencyManagement>
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.springframework.experimental</groupId>
26+
<artifactId>spring-modulith-bom</artifactId>
27+
<version>{projectVersion}</version>
28+
<scope>import</scope>
29+
<type>pom</type>
30+
</dependency>
31+
</dependencies>
32+
</dependencyManagement>
33+
----
34+
35+
The individual sections describing Spring Modulith features will refer to the individual artifacts that are needed to make use of the feature.
36+
For an overview about all modules available, have a look at <<appendix.artifacts>>.

src/docs/asciidoc/10-fundamentals.adoc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ In a Spring Boot application, an application module is a unit of functionality t
1212

1313
* An API exposed to other modules implemented by Spring bean instances and application events published by the module, usually referred to as _provided interface_.
1414
* Internal implementation components that are not supposed to be accessed by other modules.
15-
* References to API exposed by other modules in the form of Spring bean dependencies, application events listened to and configuration properties exposed.
15+
* References to API exposed by other modules in the form of Spring bean dependencies, application events listened to and configuration properties exposed, usually referred to as _required interface_.
1616

17-
Spring Moduliths provides different ways of expressing modules, primarily differing in the level of complexity involved in the overall arrangement.
17+
Spring Moduliths provides different ways of expressing modules within Spring Boot applications, primarily differing in the level of complexity involved in the overall arrangement.
1818
This allows developers to start simple and naturally move to more sophisticated means as and if needed.
1919

2020
[[fundamentals.modules.simple]]
2121
=== Simple Application Modules
2222

23-
The application's main package is the one that the main application class resides in.
24-
The class, that is annotated with `@SpringBootApplication` and usually contains the `main(…)` method used to run it.
25-
By default, each direct sub-package of the main package is considered an application module package.
23+
The application's _main package_ is the one that the main application class resides in.
24+
That is the class, that is annotated with `@SpringBootApplication` and usually contains the `main(…)` method used to run it.
25+
By default, each direct sub-package of the main package is considered an _application module package_.
2626

2727
If this package does not contain any sub-packages, it is considered a simple one.
2828
It allows to hide code inside it by using Java's package scope to hide types from being referred to by code residing in other packages and thus not subject for dependency injection into those.
@@ -31,13 +31,13 @@ Thus, naturally, the module's API consists of all public types in the package.
3131
Let us have a look at an example arrangement (icon:plus-circle[] denotes a public type, icon:minus-circle[] a package protected one).
3232

3333
.A single inventory application module
34-
[source, subs="macros"]
34+
[source, subs="+specialchars, macros"]
3535
----
3636
icon:cubes[] Example
3737
└─ icon:folder[] src/main/java
38-
├─ icon:cube[] example <1>
38+
├─ icon:cube[] example <1>
3939
| └─ icon:plus-circle[] Application.java
40-
└─ icon:cube[] example.inventory <2>
40+
└─ icon:cube[] example.inventory <2>
4141
├─ icon:plus-circle[] InventoryManagement.java
4242
└─ icon:minus-circle[] SomethingInventoryInternal.java
4343
----
@@ -71,6 +71,7 @@ Code from other application modules is allowed to refer to types within that.
7171
Code within those must not be referred to from other modules.
7272
Note, how `SomethingOrderInternal` is a public type, likely because `OrderManagement` depends on it.
7373
This unfortunately means, that it can also be referred to from other packages such as the `inventory` one.
74+
In this case, the Java compiler is not of much use to prevent these illegal references.
7475

7576
[[fundamentals.modules.explicit-dependencies]]
7677
=== Explicit Application Module Dependencies
@@ -128,7 +129,7 @@ modules.forEach(System.out::println);
128129

129130
Note, how each module is listed and the contained Spring components are identified and the respective visibility is rendered, too.
130131

131-
[[fundamentals.modules.named-interface]]
132+
[[fundamentals.modules.named-interfaces]]
132133
=== Named Interfaces
133134

134135
By default and as described in <<fundamentals.modules.advanced>>, an application module's base package is considered the API package and thus is the only package to allow incoming dependencies from other modules.

src/docs/asciidoc/60-documentation.adoc

Lines changed: 180 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,63 @@ class DocumentationTests {
2929
}
3030
----
3131

32-
The first call on `Documenter` will generate a C4 component diagram containin all modules within the system.
32+
The first call on `Documenter` will generate a C4 component diagram containing all modules within the system.
33+
34+
.All modules and their relationships rendered as C4 component diagram
35+
[plantuml, c4-all-modules, svg]
36+
....
37+
top to bottom direction
38+
39+
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
40+
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
41+
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
42+
43+
Container_Boundary("Modulith.Application_boundary", "Application") {
44+
Component(Modulith.Application.core, "core", "Module", "", $tags="")
45+
Component(Modulith.Application.catalog, "catalog", "Module", "", $tags="")
46+
Component(Modulith.Application.inventory, "inventory", "Module", "", $tags="")
47+
Component(Modulith.Application.order, "order", "Module", "", $tags="")
48+
Component(Modulith.Application.customer, "customer", "Module", "", $tags="")
49+
}
50+
51+
Rel_D(Modulith.Application.order, Modulith.Application.core, "depends on", $tags="")
52+
Rel_D(Modulith.Application.order, Modulith.Application.customer, "uses", $tags="")
53+
Rel_D(Modulith.Application.catalog, Modulith.Application.core, "depends on", $tags="")
54+
Rel_D(Modulith.Application.inventory, Modulith.Application.order, "listens to", $tags="")
55+
Rel_D(Modulith.Application.inventory, Modulith.Application.catalog, "uses", $tags="")
56+
Rel_D(Modulith.Application.inventory, Modulith.Application.order, "uses", $tags="")
57+
Rel_D(Modulith.Application.inventory, Modulith.Application.core, "uses", $tags="")
58+
Rel_D(Modulith.Application.order, Modulith.Application.catalog, "depends on", $tags="")
59+
60+
SHOW_LEGEND()
61+
....
62+
3363
The second call will create additional diagrams that only include the individual module and the ones they directly depend on on the canvas.
3464

65+
.A subset of application modules and their relationships starting from the order module rendered as C4 component diagram
66+
[plantuml, c4-individual-modules, svg]
67+
....
68+
top to bottom direction
69+
70+
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
71+
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
72+
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
73+
74+
Container_Boundary("Modulith.Application_boundary", "Application") {
75+
Component(Modulith.Application.core, "core", "Module", "", $tags="")
76+
Component(Modulith.Application.catalog, "catalog", "Module", "", $tags="")
77+
Component(Modulith.Application.order, "order", "Module", "", $tags="")
78+
Component(Modulith.Application.customer, "customer", "Module", "", $tags="")
79+
}
80+
81+
Rel_D(Modulith.Application.order, Modulith.Application.core, "depends on", $tags="")
82+
Rel_D(Modulith.Application.order, Modulith.Application.customer, "uses", $tags="")
83+
Rel_D(Modulith.Application.catalog, Modulith.Application.core, "depends on", $tags="")
84+
Rel_D(Modulith.Application.order, Modulith.Application.catalog, "depends on", $tags="")
85+
86+
SHOW_LEGEND()
87+
....
88+
3589
[[documentation.component-diagrams.uml]]
3690
=== Using Traditional UML Component Diagrams
3791

@@ -45,7 +99,84 @@ DiagramOptions.defaults()
4599

46100
This will cause the diagrams to look like this:
47101

48-
TODO: Add diagram
102+
.All modules and their relationships rendered as UML component diagram
103+
[plantuml, uml-all-modules, svg]
104+
....
105+
skinparam {
106+
shadowing false
107+
arrowColor #707070
108+
actorBorderColor #707070
109+
componentBorderColor #707070
110+
rectangleBorderColor #707070
111+
noteBackgroundColor #ffffff
112+
noteBorderColor #707070
113+
defaultTextAlignment center
114+
wrapWidth 200
115+
maxMessageSize 100
116+
componentStyle uml1
117+
}
118+
package "Application" <<Container>> {
119+
component 4 <<Component: Module>> #dddddd [
120+
com.acme.commerce.catalog
121+
]
122+
component 3 <<Component: Module>> #dddddd [
123+
com.acme.commerce.core
124+
]
125+
component 7 <<Component: Module>> #dddddd [
126+
com.acme.commerce.customer
127+
]
128+
component 5 <<Component: Module>> #dddddd [
129+
com.acme.commerce.inventory
130+
]
131+
component 6 <<Component: Module>> #dddddd [
132+
com.acme.commerce.order
133+
]
134+
}
135+
4 .[#707070].> 3 : depends on
136+
5 .[#707070].> 4 : uses
137+
5 .[#707070].> 3 : uses
138+
5 .[#707070].> 6 : uses
139+
5 .[#707070].> 6 : listens to
140+
6 .[#707070].> 4 : depends on
141+
6 .[#707070].> 3 : depends on
142+
6 .[#707070].> 7 : uses
143+
....
144+
145+
.A subset of application modules and their relationships starting from the order module rendered as UML component diagram
146+
[plantuml,uml-individiual-module, svg]
147+
....
148+
skinparam {
149+
shadowing false
150+
arrowColor #707070
151+
actorBorderColor #707070
152+
componentBorderColor #707070
153+
rectangleBorderColor #707070
154+
noteBackgroundColor #ffffff
155+
noteBorderColor #707070
156+
defaultTextAlignment center
157+
wrapWidth 200
158+
maxMessageSize 100
159+
componentStyle uml1
160+
}
161+
package "Application" <<Container>> {
162+
component 4 <<Component: Module>> #dddddd [
163+
com.acme.commerce.catalog
164+
]
165+
component 3 <<Component: Module>> #dddddd [
166+
com.acme.commerce.core
167+
]
168+
component 7 <<Component: Module>> #dddddd [
169+
com.acme.commerce.customer
170+
]
171+
component 6 <<Component: Module>> #dddddd [
172+
com.acme.commerce.order
173+
]
174+
}
175+
4 .[#707070].> 3 : depends on
176+
6 .[#707070].> 4 : depends on
177+
6 .[#707070].> 3 : depends on
178+
6 .[#707070].> 7 : uses
179+
....
49180

50181
[[documentation.application-module-canvas]]
51182
== Generating Application Module Canvases
@@ -70,12 +201,53 @@ class DocumentationTests {
70201

71202
A canvas generated looks like this:
72203

73-
TODO: Include generated canvas
204+
.A sample Application Module Canvas
205+
[cols="1h,4a"]
206+
|===
207+
|Base package
208+
|`com.acme.commerce.inventory`
209+
|Spring components
210+
|_Services_
211+
212+
* `c.a.c.i.InventoryManagement`
213+
214+
_Repositories_
215+
216+
* `c.a.c.i.Inventory`
217+
218+
_Event listeners_
219+
220+
* `c.a.c.i.InternalInventoryListeners` listening to `o.s.m.m.DayHasPassed`, `c.a.c.i.QuantityReduced`
221+
* `c.a.c.i.InventoryOrderEventListener` listening to `c.a.c.o.OrderCanceled`, `c.a.c.o.OrderCompleted`
222+
223+
_Configuration properties_
224+
225+
* `c.a.c.i.InventoryProperties`
226+
227+
_Others_
228+
229+
* `c.a.c.i.InventoryItemCreationListener`
230+
|Aggregate roots
231+
|* `c.a.c.i.InventoryItem`
232+
|Published events
233+
|* `c.a.c.i.QuantityReduced` created by:
234+
** `c.a.c.i.InventoryItem.decreaseQuantity(…)`
235+
* `c.a.c.i.StockShort` created by:
236+
** `c.a.c.i.InternalInventoryListeners.on(…)`
237+
238+
|Events listened to
239+
|* `c.a.c.o.OrderCompleted`
240+
* `c.a.c.o.OrderCanceled`
241+
|Properties
242+
|* `acme.commerce.inventory.restock-threshold` -- `c.a.c.c.Quantity`. The threshold at which a `InventoryEvents.StockShort` is supposed to be triggered during inventory updates.
243+
|===
74244

75245
It consists of the following sections:
76-
* __The application module's name and base package.__
77-
* __The Spring beans exposed by the application module, grouped by stereotype.__ -- In other words beans that are located in either the API package or any <<fundamentals.modules.named-interface, named interface package>>.
78-
* __Exposed aggregate roots__
246+
247+
* __The application module's base package.__
248+
* __The Spring beans exposed by the application module, grouped by stereotype.__ -- In other words beans that are located in either the API package or any <<fundamentals.modules.named-interfaces, named interface package>>.
249+
* __Exposed aggregate roots__ -- Any entities that we find repositories for or explicitly declared as aggregate via jMolecules.
79250
* __Application events published by the module__ -- Those event types need to be demarcated using jMolecules `@DomainEvent` or implement its `DomainEvent` interface.
80-
* __Application events listened to by the module__ -- Derived from methods annotated with Spring's `@EventListener`, `@TransactionalEventListener` or beans implementing `ApplicationListener`.
81-
* __Configuration properties__ -- Requires the usage of the `spring-boot-configuration-processor` artifact to extract the metadata attached to the properties.
251+
* __Application events listened to by the module__ -- Derived from methods annotated with Spring's `@EventListener`, `@TransactionalEventListener`, jMolecules' `@DomainEventHandler` or beans implementing `ApplicationListener`.
252+
* __Configuration properties__ -- Spring Boot Configuration properties exposed by the application module.
253+
Requires the usage of the `spring-boot-configuration-processor` artifact to extract the metadata attached to the properties.

src/docs/asciidoc/90-appendix.adoc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,43 @@
22
= Appendix
33
:jdbc-schema-base: ../../../spring-modulith-events/spring-modulith-events-jdbc/src/main/resources
44

5+
[appendix]
6+
[[appendix.migrating-from-moduliths]]
7+
== Migrating from Moduliths
8+
9+
* `Modules` -> `ApplicationModules`
10+
* `@ModuleTest`-> `ApplicationModuleTest`
11+
12+
[appendix]
13+
[[appendix.artifacts]]
14+
== Spring Modulith modules
15+
16+
.Spring Modulith starter POMs
17+
[cols="3,1,5", options="header, unbreakable"]
18+
|===
19+
|Starter|Typical scope|Description
20+
|`spring-modulith-starter-jdbc`|`compile`|Includes `spring-modulith-api`, `spring-modulith-moments` as well as `spring-modulith-events-jdbc`.
21+
|`spring-modulith-starter-jpa`|`compile`|Includes `spring-modulith-api`, `spring-modulith-moments` as well as `spring-modulith-events-jpa`.
22+
|`spring-modulith-starter-mongodb`|`compile`|Includes `spring-modulith-api`, `spring-modulith-moments` as well as `spring-modulith-events-mongodb`.
23+
|`spring-modulith-starter-test`|`compile`|Includes `spring-modulith-docs` and `spring-modulith-test`.
24+
|===
25+
26+
.Individual Spring Modulith JARs
27+
[cols="3,1,5", options="header, unbreakable"]
28+
|===
29+
|Module|Typical scope|Description
30+
|`spring-modulith-api`|`compile`|The abstractions to be used in your production code to customize Spring Modulith's default behavior.
31+
|`spring-modulith-core`|`runtime`|The core application module model and API.
32+
|`spring-modulith-docs`|`test`|The `Documenter` API to create Asciidoctor and PlantUML documentation from the module model.
33+
|`spring-modulith-events-core`|`runtime`|The core implementation of the event publication registry as well as the integration abstractions `EventPublicationRegistry` and `EventPublicationSerializer`.
34+
|`spring-modulith-events-jackson`|`runtime`|A Jackson-based implementation of the `EventPublicationSerializer`.
35+
|`spring-modulith-events-jdbc`|`runtime`|A JDBC-based implementation of the `EventPublicationRegistry`.
36+
|`spring-modulith-events-jpa`|`runtime`|A JPA-based implementation of the `EventPublicationRegistry`.
37+
|`spring-modulith-events-mongodb`|`runtime`|A MongoDB-based implementation of the `EventPublicationRegistry`.
38+
|`spring-modulith-moments`|`compile`|The Passage of Time events implementation described <<moments, here>>.
39+
|`spring-modulith-observability`|`runtime`|Observability infrastructure described <<observability, here>>.
40+
|===
41+
542
[appendix]
643
[[appendix.schemas]]
744
== Event publication registry schemas

src/docs/asciidoc/index.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ Oliver Drotbohm
1010
NOTE: Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.
1111

1212
:leveloffset: +1
13+
:!numbered:
1314

14-
// include::00-preface.adoc[]
15+
include::00-preface.adoc[]
16+
17+
:numbered:
1518

1619
include::10-fundamentals.adoc[]
1720

0 commit comments

Comments
 (0)