top of page

How to use Aggregates

Aggregates and Systems Overview

Under the 'Aggregates' tab in the app, you can view your workflow from an aggregate/system perspective. Commands are grouped by aggregate/system. You can also see the command parameters and the entities (with data fields) within each aggregate/system. You can assign one or more aggregates to a Bounded Context and generate the code for a Service API. This approach is effective when you want to gradually break down a monolith and replace it with well-designed Service APIs. It is also useful when designing new APIs.
 

Configuration

First, make sure to have a card type set as ‘COMMAND’ and another set as ‘AGGR.’ (Aggregate) in the workflow settings (the cogwheel icon top right).

help-aggregates-2.e742e73d.png

Add / update cards on Events

Now you can specify commands and aggregates/systems for the events in the diagram.

  • Put the names of commands in cards of the type set as ‘COMMAND’

  • Put the names of aggregates/systems in cards of the type set as ‘AGGR.’

  • Note: Only add ONE command and ONE aggregate/system per Event. Additional cards will be ignored.

  • Hint: When modeling, consider each event as one command executed on a specific system. For example, 'Create Order'. If 'Create Order' can be accomplished in two steps, such as creating a new customer just before the new order, consider breaking up the event into two (or more) events.

help-aggregates-4.7cf1ab6d.png

Sign up to for free to test aggregates

View Aggregates/Systems

Now you can view Commands and Events grouped by Aggregate/System. The names and descriptions can be updated directly in the diagram. In the example below we see a “Warehouse Management Service” that has 3 methods:

  • Print picking list

  • Confirm picked products

  • Confirm packaging checklist

Commands and events belong together if they are positioned at the same height. The first row can be read as: “The actor Inventory Manager executes the command Print a picking list on the aggregate/system Warehouse Management Service and by doing so triggers the event: Available inventory for product reserved
 

help-aggregates-1.ef244009.png

Data Fields

If you have captured Event Stories and Dimensions/Entities under the tab Data Models you can also view the data fields and associated entities by clicking the checkboxes 'Show data fields' and 'Show entities'.

help-aggregates-3.a3646648.png

Bounded Contexts

The next step is to assign one or several aggregates to a bounded context. This is done by clicking a button on the aggregate or entity. Related entities can belong to the same bounded context or to another bounded context. If a related entity belongs to another bounded context, a label with the text 'Integration with other bounded contexts' indicates that we have an integration point.

help-aggregates-6.a1f3e221.png

Service API / Code Generation

Code can be generated for a Bounded Context, such as a full Service API or an OpenAPI/Swagger Specification. You can select from various programming languages, databases, and testing frameworks. Additionally, there is an option to generate only the OpenAPI Specification. If you wish to use a different technology stack, you can manually update the YAML specification used for AI code generation by clicking on 'Customize specification.' For example, you could choose to generate code in TypeScript instead of JavaScript. After finalizing the specification, click the 'Generate API' button. Wait for the generation to complete, then download the source code as a ZIP file.

help-aggregates-7.52dade3e.png
bottom of page