Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-cqrs-es-domain-module

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-cqrs-es-domain-module

An example domain module to help describe implementation guidelines when leveraging js-cqrs-es.

  • 0.0.1-beta.2
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

js-cqrs-es-domain-module

This is an example domain module to help describe implementation guidelines when leveraging the js-cqrs-es framework.

Structure

The structure of the domain module is defined below. This is the general structure that the Producer, Consumer, and Stream Processor services follow by default. Again, this is a suggested structure to keep domain logic separate from application/infrastructure logic because it makes the code more far more portable than it would have otherwise been. This is fine for smaller domain models. To manage complex domain models, see the advanced use cases below.

module
    |- projection
    |   |- Projections
    |   `- (etc.)
    `- domain
        |- schema
        |   `- Schemas
        |- model
        |   |- Entities
        |   |- Value Objects
        |   `- (etc.)
        `- aggregate
            |- Aggregate namespaces { class, commands, events, handlers }
            `- (etc.)

Advanced Use Cases

For larger domain models, an even greater degree of separation with multiple domain modules is strongly recommended. Teams will maintain their own domain modules in their area of responsibility for the overall domain model.

Another strong recommendation is to separate the domain module into multiple modules to manage dependencies and portability better. Commands should be put in their own module so that they can be reused in the UI layer. Projections should also be split out into their own module as well because of the extra DB dependencies. Here is an example of how these multiple modules would be defined:

commands-module
    |- Commands
    |
    `- dependencies
        `- js-cqrs-es

domain-module
    |- Schemas
    |- Entities
    |- Value Objects
    |- Aggregate namespaces { class, events, handlers }
    |
    |- dependencies
        `- commands-module

projections-module
    |- Denormalizers
    |- Projections
    |
    `- dependencies
        |- domain-module
        `- odm-framework
  • NOTE: This approach will require you to use the Hive Stack starter kits rather than the Docker base images.

Example

The example provided here is an attempt to showcase as much of the features of the js-cqrs-es framework as possible. It is a contrived representation of a Twitter Tweet Content aggregate and an analytics View value object to track views over time. This is also the default domain module applied to the Hive Stack for testing implementation details. I've provided a diagram for the domain model below.

contrived example domain model

  • NOTE: To be clear, the Content aggregate handles a small amount of denormalization to track views on the Consumer. This is NOT the recommended approach! It is there to make development and testing easier. Separate Denormalizers should be written that should extend the Aggregate class and reuse existing Schemas to define the denormalized structure for Hive Stack Consumers. Read more about why.

FAQs

Package last updated on 03 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc