Session 1: Discovery
The team joins their first Event Flowing session. The goal: understand the checkout flow and identify actors, events, and the data that flows between them.
Setting the Scene
Everyone joins the video call. Alex shares their screen showing the editor with an empty order.flow file on one side and the live diagram on the other. EventFlow runs in watch mode - every change updates the diagram automatically.
$ eventflow watch order.flow
EventFlow v1.0.0
➜ Editor: http://localhost:5173/
➜ Diagram: http://localhost:5173/diagram
➜ Tests: http://localhost:5173/tests
Watching for changes...Writing the First Lines
Alex starts typing. Everyone watches the shared screen as the code and diagram update together.
// order.flow
machine: @ordermachine: @order
// Actors involved:
// @customer - the buyer
// @order - this machine (order management)
// @payment - external payment processing serviceDefining the First Event
machine: @order
scenario: checkout
on :checkout from @customermachine: @order
scenario: checkout
given:
$total: number is calculated
on :checkout from @customer
emit :payment_request to @payment
// Wait point: system pauses here for @payment response
// State will be derived in Session 4The diagram on the screen updates automatically:
Adding the Payment Response
machine: @order
scenario: checkout
given:
$total: number is calculated
on :checkout from @customer
$order_id: string becomes uuid()
emit :payment_request to @payment
with $order_id, $total
// Wait point: awaiting payment response
on :payment_success from @payment
send confirmation email
// Terminal: order completeThe diagram updates again:
on :payment_success from @payment
send confirmation email
emit :order_confirmed to @customer
with $order_id
// Terminal: order successfully completedThe diagram updates instantly:
Making the Event Public
on :checkout from @customer (api)Adding Expectations
machine: @order
scenario: checkout
given:
@customer is logged in
cart has items
$total: number is calculated
on :checkout from @customer (api)
$order_id: string becomes uuid()
emit :payment_request to @payment
with $order_id, $total
// Wait point: system pauses for payment response
expect:
= @payment received :payment_request
on :payment_success from @payment
send confirmation email
emit :order_confirmed to @customer
with $order_id
// Terminal: process complete
expect:
= @customer received :order_confirmedRunning the First Test
$ eventflow test order.flow
@order / checkout
happy path
✓ checkout triggers payment_request (12ms)
✓ payment_success triggers order_confirmed (15ms)
2 passingSession Outcome
What We Built
- Basic checkout flow with customer, order, and payment actors
- Payment request/response cycle
- Confirmation email and event to customer
- Typed context variables ($order_id: string, $total: number)
The Diagram Shows
:checkoutfrom customer to order (public API):payment_requestfrom order to payment:payment_successfrom payment back to order (internal):order_confirmedfrom order to customer
Decisions Made
- Start with happy path only
- Defer inventory checking to later
:checkoutis public (uses(api)suffix):payment_successstays internal (on)
Edge Cases Identified (to clarify, not solve yet)
- What if cart is empty?
- What if customer is not logged in?
- What if payment fails?
These will be systematically addressed in Session 3 with QA.
About States
States are not determined in this session. The event flow we've built contains implicit "wait points" where the system pauses for external events:
| Wait Point | Waiting For |
|---|---|
After :payment_request | Response from @payment |
After :order_confirmed | Process complete (terminal) |
These wait points will become formal states (like #awaiting_payment, #confirmed) in Session 4 using moves to #state syntax.
The Flow So Far
// order.flow v1
machine: @order
scenario: checkout
given:
@customer is logged in
cart has items
$total: number is calculated
on :checkout from @customer (api)
$order_id: string becomes uuid()
emit :payment_request to @payment
with $order_id, $total
// Wait point: system pauses for payment response
expect:
= @payment received :payment_request
on :payment_success from @payment
send confirmation email
emit :order_confirmed to @customer
with $order_id
// Terminal: process complete
expect:
= @customer received :order_confirmed