Coder Social home page Coder Social logo

ddd-with-kotlin's Introduction

DDD with Kotlin

Build Status License

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.

Run it

./gradlew bootRun

Then simulate an incoming event:

POST to http://localhost:8080/master_data_update
POST to http://localhost:8080/media_data_update

Example Use Case

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

What to see

  • 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 or ProductInformation.kt.
  • A ports-and-adapters package layout.
  • An anti-corruption layer for external events - they will be transformed to internal commands.

Resources

ddd-with-kotlin's People

Contributors

tuhrig avatar jbellmann avatar

Watchers

James Cloos avatar Kleber Almeida Toyota avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.