Skip to content

Event Modeling Diagram #5860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
schicks opened this issue Sep 14, 2024 · 4 comments · May be fixed by #6440 or #5861
Open

Event Modeling Diagram #5860

schicks opened this issue Sep 14, 2024 · 4 comments · May be fixed by #6440 or #5861
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request Type: New Diagram

Comments

@schicks
Copy link

schicks commented Sep 14, 2024

Proposal

Current tools for event modeling are effectively just virtual whiteboards. Being able to embed event models in markdown would make them much more widely useful for documentation as well as brainstorming. See the event modeling cheat sheet for more explanation of the format.

Use Cases

  • documenting the expected behavior of an application
  • illustrating how data moves between multiple systems and what can cause it to be created

Screenshots

cheatsheet

Syntax

Building blocks

Event models break down into several sections shown as swim lanes; triggers, commands and queries, and facts.

Triggers

Triggers come in two forms. They can either be automated, in which case they just need a name, or they can be manual, in which case they need a pattern and a role.

pattern "auditing records" {
   role auditor {
      auditUI["auditing UI"]
      flagErrors["Flag errors"]
   }
  role author {
    authorUI["author UI"]
    write["write records"]
    authorUpdateUI["Update UI"]
    update["update records"]
  }
}
processStale["mark unaudited records as good after X days"]

This would declare an "auditing records" pattern with two roles.

  • The auditor role would have an "audit UI" trigger and a "flag errors" trigger.
  • The author role would have 4 triggers.

Separately, processStale would be created as an automated trigger, outside the context of the pattern. The syntax here is chosen to be relatively similar to the syntax in flowcharts.

Queries and Commands

Queries and commands do not have any additional context, and so are easy to declare. All that is necessary is the keyword query or command before the name, to clarify which you are declaring.

query showRecords["show records"]
command flagErrors
Facts

Facts need to be stored in some system which are drawn on the diagram as swimlanes.

system records {
  goodRecord["a complete history of the world"]
  badRecord["how to spel gud"]
}
system audits {
  auditGood["ACHOTW approved"]
  auditBad["HTSG needs revision"]
}

Organization

Any of the chunks above could be placed in any order in a diagram block. They will be connected by edges declared similarly to flowchart graphs.

goodRecord & badRecord --> showRecords
flagErrors --> auditGood & auditBad

Unlike in flowcharts, only certain transitions are allowed. Any other transitions will lead to an error.

flowchart LR

fact --> query
command --> fact
trigger --> command
query --> trigger
Loading

Edges that reference undeclared variables will also lead to an error, as we can't know what kind a variable is or where to put it otherwise.

Variables will be placed on the graph in their appropriate section, with an X coordinate related to their rank in the graph. If two variables have the same rank, they will be placed in the order that they were declared. No two variables should have the same X coordinate.

Complete Example

eventModel

pattern "auditing records" {
   role auditor {
      auditUI["auditing UI"]
      flagErrors["Flag errors"]
   }
  role author {
    authorUI["author UI"]
    write["write records"]
    authorUpdateUI["Update UI"]
    update["update records"]
  }
}
processStale["mark unaudited records as good after X days"]

query showRecords["show records"]
command flagErrors

system records {
  goodRecord["a complete history of the world"]
  badRecord["how to spel gud"]
}
system audits {
  auditGood["ACHOTW approved"]
  auditBad["HTSG needs revision"]
}

goodRecord & badRecord --> showRecords
flagErrors --> auditGood & auditBad

Implementation

I will try and implement it myself.

@schicks schicks added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request Type: New Diagram labels Sep 14, 2024
@schicks schicks linked a pull request Sep 14, 2024 that will close this issue
4 tasks
@schicks
Copy link
Author

schicks commented Dec 19, 2024

I think this remains a good idea but given that I haven't been able to work on it in months I should probably admit that I'm unlikely to be the one to implement it. 😢 . I'd love to see this happen and would be happy to give feedback, but I apparently don't have the time to actually do the implementation.

@lgazo
Copy link

lgazo commented Mar 23, 2025

Hi @schicks,

I've independently started a work on EM text DSL / language and diagram support for Mermaid. I realized there might be a similar effort just lately and I found your ticket. I took a slightly different approach to the language I put in place. My changes are here at the moment.

https://github.com/lgazo/mermaid/tree/feature/event-modeling-diagram

It contains basic entity rendering. Working on the arrows support and other fancy stuff.
I'll take a look also to your version afterwards as well.

@schicks
Copy link
Author

schicks commented Mar 23, 2025

I never really got past the parser. I'm glad someone is working on this! Let me know if a second pair of eyes can be useful.

@lgazo lgazo linked a pull request Mar 30, 2025 that will close this issue
4 tasks
@lgazo
Copy link

lgazo commented Mar 30, 2025

Hi @schicks, I've implemented the version of the diagram. Feel free to check the PR - #6440.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request Type: New Diagram
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants