DDD with Kotlin

Thomas Uhrig · May 5, 2018

I recently made my first steps with Kotlin. After exploring the language for a couple of weeks, I tried to translate one of my favorite architectural patterns from my Java background to the Kotlin world - Domain Driven Design.

Example project

I’ve prepared an example project on GitHub showing some of the most important concepts of DDD with Kotlin. The project implements a fictitious product service which takes care of the bounded context of a product. The product service implements domain entities as well as value objects and uses an asynchronous communication via events and commands. The example use case (which is described in the README.md on GitHub) involves communication with five fictitious external systems.

+-------------+
| 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 |
                                         +-----+  +------+  +--------+

More

Best regards, Thomas.