README.md

EMSO #

A web-based Event Modeling tool built with Elixir and Phoenix LiveView.

Overview #

Event Modeling is a methodology for designing information systems by mapping out data flows on a single timeline. It uses four core patterns — State Change, State View, Automation, and Translation — to describe how data enters, moves through, and is read from a system.

EMSO provides an interactive canvas for building Event Modeling diagrams. It runs as a standalone web application with no database — boards are stored as JSON files on disk and loaded into ETS for fast access. It also exposes boards to AI coding assistants via MCP tools, prompts, and resources.

Features #

Canvas & Navigation #

  • Interactive board canvas with pan, zoom (0.25x–2.0x), and fit-to-page
  • Keyboard-driven navigation — traverse nodes with j/k/h/l, connect nodes with Space, edit with Enter (see Keyboard Shortcuts)
  • Client-side optimistic navigation with zero server latency
  • Swim lanes — horizontal zones (System, Middle, Event) for vertical organization
  • Slices — vertical columns grouping nodes into work units, with status tracking for implementation progress
  • Spacer slices — empty placeholder slices for visual separation
  • Chapters — logical groupings of consecutive slices with colored header bars, supporting multiple levels

Nodes & Connections #

  • Seven node types: Event (orange), Command (blue), Read Model (green), Screen (grey), External Event (yellow), Processor (blue), Note (white)
  • Flow edges — directed arrows representing data and control flow
  • Master/link nodes — a node can be linked to a master, sharing its label, type, and fields while maintaining its own position across slices. ICC treats the entire family as one logical node with merged connections
  • Cross-slice proxies — configurable “ghost” nodes that replace long-distance arrows when flow edges span multiple slices. Toggle on/off and set distance threshold in board settings
  • Screen wireframes — low-fidelity widgets (input, button, dropdown, table, checkbox, text) with highlight support
  • Inline label editing — press e to edit a node’s label directly on the canvas

Validation & Scenarios #

  • Information Completeness Check (ICC) — validates that every field on each node has a data source on an upstream node and is consumed by a downstream node, checks connectivity, naming conventions, connection types, and pattern conformance
  • Pattern detection — automatically identifies State Change, State View, Automation, and Translation patterns from slice composition
  • Slice templates — generates nodes and flow edges for a chosen pattern in a single operation
  • Given/When/Then scenarios — GWT for state changes, GT for state views, with example data and error cases

Integrations & Storage #

  • MCP integration — AI assistants can read and manipulate boards programmatically via tools, prompts, and resources
  • JSON API — progress tracking and slice status endpoints
  • Markdown CLI interface — boards served as markdown for terminal tools
  • Board versioning — numbered snapshots with optional labels and a side-by-side diff viewer
  • Real-time updates — changes broadcast via PubSub across browser tabs
  • No database — lightweight JSON file storage with zero infrastructure requirements

Keyboard Shortcuts #

All navigation is handled client-side for instant response. Action keys sync the current selection to the server.

Key Action
j / ‘ArrowDown’ Next node (down through lanes, then next slice)
k / ‘ArrowUp’ Previous node
h / ArrowLeft Previous node in same lane
l / ArrowRight Next node in same lane
ArrowDown Next lane in same slice
ArrowUp Previous lane in same slice

Actions #

Key Action
Space Connect mode: 1st press marks source, navigate to target, 2nd press creates connection. Press on same node or Escape to cancel
Enter Open node editor sidebar
Delete Delete selected node (with confirmation)
e Inline edit selected node’s label on canvas
v Detail view overlay for selected node
Key Action
c Open connect menu (searchable list of valid targets)
s Open source menu (searchable list of valid sources)
i Insert slice before current
a Insert slice after current
/ Open slice search/jump menu
g Open chapter jump menu

Global #

Key Action
Escape Close active menu/panel, then exit connect mode, then deselect
Ctrl+Z Undo
Ctrl+Y / Ctrl+Shift+Z Redo

Getting Started #

Prerequisites #

  • Elixir >= 1.18

Setup #

mix setup
mix phx.server

Visit localhost:4000 to create your first board.

Storage #

Boards are persisted at ~/.emso/boards/{board_id}/board.json with version snapshots at ~/.emso/boards/{board_id}/versions/v{n}.json. The storage path is configurable via the :board_storage_path app config.

Event Modeling Patterns #

Each slice on a board typically follows one of these patterns:

  • State Change — Screen → Command → Event. A user action triggers a command that produces a domain event.
  • State View — Event → Read Model → Screen. Events feed a projection that is displayed on a screen.
  • Automation — Event → Processor → Command → Event. An event triggers an automated process that issues a command, producing another event.
  • Translation — External Event → Processor → Command → Event. Data from an external system triggers a process that issues a command.

EMSO can automatically detect which pattern a slice follows based on its node composition and generate template nodes for a chosen pattern in a single operation.

MCP Integration #

EMSO exposes Event Modeling capabilities to AI assistants via the Model Context Protocol. There are two entry points:

  1. Tidewave integration — tools registered with Tidewave at startup, available to any MCP-compatible assistant connected via Tidewave.
  2. Standalone /mcp endpoint — a custom MCP JSON-RPC 2.0 server at /mcp that can be used independently of Tidewave. Restricted to localhost connections for security.

Tools #

Seven tool groups are available:

  • BoardTools — list, get, create, and delete boards
  • NodeTools — add, update, delete, and connect nodes; manage fields
  • SliceTools — add and update slices; add scenarios; move nodes between slices; create pattern-based templates
  • ChapterTools — add, update, delete chapters; assign slices to chapters
  • WidgetTools — add, update, delete, and reorder wireframe widgets on screen nodes
  • AnalysisTools — run ICC validation, inspect connected fields, track board progress
  • GuidanceTools — methodology guidance: suggest next steps, recommend patterns for slices

Prompts #

Five workflow prompts guide AI assistants through common tasks:

  • event_storm — brainstorm domain events for a new board
  • design_slice — design a slice following a specific pattern
  • run_icc_review — review a board’s information completeness
  • write_scenarios — write Given/When/Then scenarios for slices
  • review_board — review overall board design and suggest improvements

Resources #

Eight methodology knowledge resources provide Event Modeling reference material: overview, patterns, ICC, scenarios, naming conventions, workflow, DDD connections, and implementation patterns.

JSON API #

Three endpoints at /api support AI agent workflows for tracking implementation progress. See docs/api.md for details.

Endpoint Method Description
/api/boards GET List boards with progress stats
/api/boards/:id/progress GET Detailed per-slice and per-chapter progress
/api/boards/:id/slices/:slice_id/status PATCH Update slice status and assignee (broadcasts via PubSub)

The status PATCH body requires status (normal, in_progress or done) and accepts an optional status_name and an optional assignee: a username with write access to the board, or ""/null to unassign (omit it to leave the assignee unchanged). An assignee who can't be assigned gets 422 {"error": "Invalid assignee"}.

curl -s -X PATCH -H 'Content-Type: application/json' \
  -d '{"status": "in_progress", "assignee": "alice"}' \
  http://localhost:4000/api/boards/{board_id}/slices/{slice_id}/status

CLI Access #

The same API endpoints also return plain-text markdown when requested with Accept: text/markdown, designed for terminal workflows:

# List all boards
curl -s -H 'Accept: text/markdown' http://localhost:4000/api/boards

# View a board's slices
curl -s -H 'Accept: text/markdown' http://localhost:4000/api/boards/{board_id}/slices

# View a specific slice with its nodes and scenarios
curl -s -H 'Accept: text/markdown' http://localhost:4000/api/boards/{board_id}/slices/{slice_id}

Pipe to glow or bat for rendered output:

curl -s -H 'Accept: text/markdown' http://localhost:4000/api/boards | glow