Skip to content
Dark MatterDark Matter
Architecture

Event Sourcing

How ownership state is versioned using event sourcing in DMTR.

Overview

DMTR uses event sourcing to version ownership state. State changes are recorded as immutable events; the current state is derived by applying the event log. This approach provides auditability, replay capability, and temporal queries. This document describes the model at a conceptual level.

Event log

Each position has an associated event log. Events include: creation, status change, transfer, compliance update, valuation update. Events are append-only and immutable. Event order is preserved; events are keyed by position and sequence.

Lifecycle Timeline

Position state transitions over time

registered → registered
active → active
encumbered → active
transferred → active

State derivation

The current Position Object is derived by applying events in order. Derivation happens at read time or via materialized views for performance. Historical state can be reconstructed by replaying events up to a point in time. This supports "as-of" queries and audit trails.

Implications

Event sourcing enables strong auditability and compliance. Integrations receive events via webhooks. The event log is the source of truth; the Position Object is a derived view. Schema evolution is handled through event versioning and migration.

position.status_changed

Event recorded when a position transitions between lifecycle states.

FieldTypeDescription
event_idstringUnique event identifier
position_idstringPosition entity_id
sequenceintegerEvent sequence number for this position
previous_statestringState before transition
new_statestringState after transition
actorstringEntity that triggered the change
timestampdatetimeWhen the event occurred
Edit this page on GitHub

Was this page helpful?