Tutorial
In this tutorial, we will build a small architecture model from scratch and see it visually.
You have two options to follow this tutorial:
- Open the EventCatalog Compass Playground
- This will give you a blank canvas to work on.
- Use the EventCatalog VSCode Extension
- You will need to install the plugin and create your first
main.ecfile. - You can run the
EventCatalog: Open Previewcommand to see your model visually.
- You will need to install the plugin and create your first
Creating your first model
In this example we will create a simple model of an order processing system.
-
Create a visualizer
The
visualizerblock is your canvas. Everything you want to see in the diagram goes inside it.- Start by creating a visualizer block.
visualizer main {name "Order Processing"} -
Add a service
A service is a runtime capability in your system, for example a microservice or application.
- Add a service inside the visualizer block.
visualizer main {name "Order Processing"service OrdersService {version 1.0.0name "Orders Service"summary "Handles order lifecycle"}} -
Publish an event from the service
Services can
send(publish) messages. These can be events, commands, or queries. These messages can be senttoa channel (e.g. Kafka, MQTT, HTTP, SQS, etc.).- Add a
sendsstatement to the service to publish an event. - Add a channel to send the event to (this is optional).
visualizer main {name "Order Processing"service OrdersService {version 1.0.0name "Orders Service"summary "Handles order lifecycle"sends event OrderCreated@1.0.0 to KafkaOrdersTopic}event OrderCreated {version 1.0.0name "Order Created"summary "Raised when an order is created"}channel KafkaOrdersTopic {version 1.0.0name "Kafka Orders Topic"summary "Primary channel for order events"address "orders.events"protocol "kafka"}} - Add a
-
Consume messages
Services can also
receive(consume) messages. These can be events, commands, or queries. These messages can be receivedfroma channel (e.g. Kafka, MQTT, HTTP, SQS, etc.).- Add a
receivesstatement to consume a command. - This time we don’t specify a version and latest version is used.
visualizer main {name "Order Processing"service OrdersService {version 1.0.0name "Orders Service"summary "Handles order lifecycle"sends event OrderCreated@1.0.0 to KafkaOrdersTopicreceives command ProcessOrder}event OrderCreated {version 1.0.0name "Order Created"summary "Raised when an order is created"}channel KafkaOrdersTopic {version 1.0.0name "Kafka Orders Topic"summary "Primary channel for order events"address "orders.events"protocol "kafka"}command ProcessOrder {version 1.0.0name "Process Order"summary "Processes an order"}} - Add a
-
Add more services
Add as many services as you need. When multiple services produce or consume the same event through the same channel, the diagram connects them automatically.
visualizer main {name "Order Processing"service OrdersService {version 1.0.0name "Orders Service"summary "Handles order lifecycle"sends event OrderCreated@1.0.0 to KafkaOrdersTopicreceives command ProcessOrder}service PaymentService {version 1.0.0summary "Processes payments for orders"receives event OrderCreated from KafkaOrdersTopicsends event PaymentProcessed to KafkaOrdersTopic {version 1.0.0summary "Payment completed successfully"}}service InventoryService {version 1.0.0summary "Manages product stock levels"receives event OrderCreated from KafkaOrdersTopicsends event InventoryReserved {version 1.0.0summary "Stock reserved for an order"}}service NotificationService {version 1.0.0summary "Sends notifications to users"receives event OrderCreated from KafkaOrdersTopicreceives event PaymentProcessed from KafkaOrdersTopic}event OrderCreated {version 1.0.0name "Order Created"summary "Raised when an order is created"}channel KafkaOrdersTopic {version 1.0.0name "Kafka Orders Topic"summary "Primary channel for order events"address "orders.events"protocol "kafka"}command ProcessOrder {version 1.0.0name "Process Order"summary "Processes an order"}} -
Wrap it in a domain
Domains group related services together. Wrap your services inside a
domainblock to show ownership and boundaries.visualizer main {name "Order Processing"domain Orders {version 1.0.0summary "Everything related to order processing"service OrdersService {version 1.0.0name "Orders Service"summary "Handles order lifecycle"sends event OrderCreated@1.0.0 to KafkaOrdersTopicreceives command ProcessOrder}service PaymentService {version 1.0.0summary "Processes payments for orders"receives event OrderCreated from KafkaOrdersTopicsends event PaymentProcessed to KafkaOrdersTopic {version 1.0.0summary "Payment completed successfully"}}service InventoryService {version 1.0.0summary "Manages product stock levels"receives event OrderCreated from KafkaOrdersTopicsends event InventoryReserved {version 1.0.0summary "Stock reserved for an order"}}}service NotificationService {version 1.0.0summary "Sends notifications to users"receives event OrderCreated from KafkaOrdersTopicreceives event PaymentProcessed from KafkaOrdersTopic}event OrderCreated {version 1.0.0name "Order Created"summary "Raised when an order is created"}channel KafkaOrdersTopic {version 1.0.0name "Kafka Orders Topic"summary "Primary channel for order events"address "orders.events"protocol "kafka"}command ProcessOrder {version 1.0.0name "Process Order"summary "Processes an order"}} -
Next steps
- Learn about domains, services, messages, and channels
- Import from AsyncAPI or OpenAPI specs
- Import from an existing EventCatalog
- Export your model to EventCatalog
- Use the VSCode extension or CLI for a local workflow