Under the ‘Domain Model' tab in the app, you can view your workflow from a software architecture design perspective. Commands can be grouped by entities or aggregates. You can also see the command parameters and the entities (with data fields) within each aggregate. You can assign one or more aggregates to a Bounded Context and generate the code for a Service API as well as code for unit tests. 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.
First, make sure to have a card type set as ‘Command’ and another set as ‘Aggregate’ in the workflow settings (the cogwheel icon top right).
Add / update cards on Events
Now you can specify commands and aggregates for the events in the diagram.
Now you can view Commands and Events grouped by Aggregate. 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:
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 Warehouse Management Service and by doing so triggers the event: Available inventory for product reserved”
If you have captured Write Models, Read Models and created an ER diagram 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'.
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.
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.