2

I am in the process of moving an application from c# to node.js. I am learning node.js as I go along, so I am a node.js newbie. I am reading the book, Patterns, Principles and Practices of Domain Driven Design and found a lot of great information my current project could benefit from.

For instance, in the book, there is a sample e-commerce application that contains three bounded contexts: sales, shipping and billing. Each bounded context is responsible for its own database and each bounded context is running in an instance of NServiceBus. This seems to be a great approach as everything is running under the same solution, but different projects. In translating this to node.js, I am having a few areas of confusion.

1) I am having a rough time finding good examples that incorporate node.js with ddd like the e-commerce example above? Some of the hurdle here is the difference in how OOP is handled.

2) If in the book sample code, each bounded context is in its own project and runs within NServiceBus, would this mean that in translating this to node.js, I am using vscode as GUI, that I would need to create a separate parent folder(bounded context) for each project and supply a different port for each bounded context to listen on if I want all of the bounded contexts to run on the same server until I need to scale accordingly?

3) NServiceBus allows messages and events to get passed back ad forth. For node.js, what service bus technology, preferably open source and can run on linux-based machine, exists that would provide the kind of functionality NServiceBus provides and reliably? Should I just look at using rabbitmq alone to provide this functionality including sending events?

halfer
  • 19,824
  • 17
  • 99
  • 186
user1790300
  • 2,143
  • 10
  • 54
  • 123
  • I implemented a real personal project in NodeJS since I wanted to learn and I went through a pragmatic way. I used Mongoose static and instance methods to drive my domain. It serves the purpose despite you tight your business logic to Mongoose. – Sebastian Oliveri Dec 26 '16 at 13:51
  • i'd recommend that each bounded context will be a micro service in its own git repository and own deployment process as stand alone instances in the cloud. I'd go for something abstract like aws elasticbeanstalk or docker container. they can all communicate via async message bus or synchronous http calls – danfromisrael Dec 26 '16 at 22:10
  • @danfromisrael That is kind of what I was thinking as far as each bounded context(microservice) being in its own project folder. Now, if I was running express api as the interface to allow clients to access the microservice through a rest api, would the microservice still run in a node.js server with a specified port if I am using elasticbeanstalk or docker or would they replace the server aspects of the node.js server setup? Should I consider AWS Lambda as well as it seems to be event-driven? I know I need to consider a service bus scenario for commands and events. – user1790300 Dec 28 '16 at 04:25
  • 1
    when you deploy to elasticbeanstalk you get a url (default port 8080) for your service. you can use it from your other services. to expose REST api you can use express. id recommend watching some tutorials of how to deploy express app to aws. eb / docker just set up your machine os + dependencies and have a app entry point command to start your server. – danfromisrael Dec 28 '16 at 14:53
  • Using elasticbeanstalk, I assume that I would get a url and initially, as scaling permits, deploy a docker container for each of the services, please correct me if incorrect. I would assume each service would have to listen from a different port and handles its own requests independently using rest. Is this the direction you are suggesting? I noticed above you stated that elasticbeanstalk already comes equipped with async messaging capabilities. The more I looked at lambda, the more it seemed to not fit due to the nature of how bounded contexts are tied together. – user1790300 Dec 28 '16 at 15:54
  • [node-cqrs-domain](https://github.com/adrai/node-cqrs-domain) looks like it offers full ddd, cqrs, event-sourcing in your node solution (see also [example code](http://cqrs.js.org/pages/domain.html)). – Arnold Schrijver Aug 07 '17 at 15:18

3 Answers3

3

You might be interested in wolkenkit, a CQRS and event-sourcing framework for Node.js and JavaScript that plays very well together with domain-driven design (DDD).

Besides the actual framework (which is deployed as npm module wolkenkit), there are a number of sample applications available that show how things work:

Apart from that you might want to take a look at the wolkenkit documentation, and there again especially at the brochure you can download which explains DDD, event-sourcing and CQRS, what they are, how they relate to each other, and so on…

PS: Please note that I am one of the authors of wolkenkit, so please take my answer with a grain of salt.

Golo Roden
  • 140,679
  • 96
  • 298
  • 425
1

I would suggest going through the npm modules tagged with ddd:

and tagged with service bus:

There is also a JavaScript Domain-Driven Design book by Philipp Fehre.

rsp
  • 107,747
  • 29
  • 201
  • 177
  • 1
    I have the Javascript Domain Driven Design book. I have gone through some of the sample code(they designed a dungeon based game). Plan to read fully after I finish Patterns, Principles, etc. book. It doesn't go into as much detail as I found in the Patterns, Principles and Practices of Domain Driven Design book, this one is very detailed, almost 750 pages. The issue is that I would like to find some examples that provide similar detail with node.js to clear up some of the confusion I am having in translation. – user1790300 Dec 23 '16 at 23:18
1

This post is a couple of years old, but for anyone still interested there's a DDD framework for Typescript/node at:

https://github.com/node-ts/ddd

As well as an NServiceBus inspired message bus at:

https://node-ts.github.io/bus/

They're designed to work together to build message driven DDD systems with node

Andrew dh
  • 881
  • 9
  • 19