Design a basic basket domain with EventSourcing and Pipeline Pattern

In this sample,I develop a basic basket with products and discounts using EventSourcing and DDD.I dont need of any heavy Aggregate base library but just using a functional approach.


First of all, I created a basic helper for object validation.

you can find different varieties of ensure at github,gist etc. And then, I created a basic basket aggregate like that.

So, we have to define a basic object for all events.

And I created all Basket Events

Basket Created Event

Discount Applied Event

Product Added Event

After I defined the events, I created commands which are related with Basket aggregate.

Add Product Command

Create basket command

Finally, I developed  a basic pipeline pattern implementation for discounts.

And then, I created a discount service



Happy Coding!

Leave a Reply

Your email address will not be published. Required fields are marked *