Skip to content

Event-Sourced Architecture

Event-Sourced Architecture

Every state change is recorded as an immutable event, enabling replay and audit.

Every state change in your workflow is recorded as an immutable event:

export default defineWorkflow('document approval', async (flow) => {
// Each action is recorded as an event
await flow.do('submit document', async () => {
await submitDocument(flow.params);
// Event: DocumentSubmitted
});
// State changes are derived from events
await flow.do('request approval', async () => {
await requestApproval(flow.params);
// Event: ApprovalRequested
});
// Events can be replayed to reconstruct state
await flow.do('process approval', async () => {
await processApproval(flow.params);
// Event: ApprovalProcessed
});
});

Key Benefits:

  • Full Auditability: A complete, unchangeable history of every action and state transition.
  • State Reconstruction: Replay events to understand the state of a workflow at any point in time.
  • Debugging and Diagnostics: Easily trace what happened leading up to an issue.
  • Temporal Queries: Analyze process evolution over time.

This foundational pattern ensures that IdentityFlow workflows are transparent, traceable, and resilient.

Learn more about advanced concepts in our Deep Dive section.