This is a simple demo project to show a Domain Driven Design with Kotlin.
Note that there is a similar version of this demo which is using event sourcing at event-sourcing-with-kotlin.
./gradlew bootRun
Then simulate an incoming event:
POST to http://localhost:8080/master_data_update
POST to http://localhost:8080/media_data_update
The subject of this demo is the Product Service
.
The Product Service
is located between five other components.
The Master Data Service
will push new products to the Product Service
.
This is the beginning of our business process.
The Product Service
will register each new product at the Media Data Service
.
After a product is registered, the Product Service
will receive updates for this product from the Media Data Service
.
After an update was received, the Product Service
will:
- Update the
CDN
if media data has changed - Update the
Shop
andsearch index
if master data has changed
+-------------+
| Master Data |
| Service |
+-------------+
| << DEMO >>
+------------------► +---------+
1: update product | Product |
| Service |---------+---------+
+------► +---------+ | |
3: | | 2: | | 5:
push updates | | register new | | update if master
| | product | | data has changed
+------------+ | | |
| Media Data | ◄----------+ | +----------+
| Service | | | |
+------------+ 4: update if media | | |
data has changed | | |
▼ ▼ ▼
+-----+ +------+ +--------+
| CDN | | Shop | | Search |
+-----+ +------+ +--------+
- A domain entity called
Product.kt
which encapsulates business logic and throws domain events. - A process flow with events ("something has happened") and commands ("now do something").
- Value objects such as
ProductNumber.kt
orProductInformation.kt
. - A ports-and-adapters package layout.
- An anti-corruption layer for external events - they will be transformed to internal commands.
- https://martinfowler.com/tags/domain%20driven%20design.html
- A collection of articles by Martin Fowler. Each article enlightens a different aspect of DDD.
- https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/ddd-oriented-microservice
- First article of series by Microsoft on how to use DDD for microservices. Although the series is using C#, the examples are easy to understand.