Event-driven · Simple example

Event-driven order notifications specification example

A small event-driven flow for placed, shipped and delivered orders. The spec defines customer emails, staff visibility, retries and duplicate-event behaviour before choosing infrastructure.

event-driven architectureorder notificationsemail retrydeduplication

spec.md Requirements and edge cases

The requirements focus on observable delivery behaviour, including failure cases.

# Order events — spec

## Requirements

- [ ] The shop records an event when an order is placed, shipped or delivered.
- [ ] Each event sends the customer an email that names the order and what happened.
- [ ] The shipped email includes the tracking link.
- [ ] Staff see the list of events for an order, newest first.
- [ ] A failed email is retried three times before it is marked failed.

## Edge Cases

- The same event is recorded twice → only one email is sent.
- Delivered arrives before shipped → both emails are sent, in the order the events happened.
- The customer's email address bounces → the event is marked "not delivered" for staff.

tasks.md Build order

The transactional event record comes before the worker and delivery views.

# Order events — tasks

## Build order

- [ ] Data model: orders, order events, messages
- [ ] Record events in the same transaction as the order change
- [ ] Worker that sends one email per event, with retries
- [ ] Email templates: placed, shipped (with tracking), delivered
- [ ] Staff view of an order's events