Events as First-Class Citizens
What You'll Learn
You'll understand how treating events as immutable facts that capture state changes forms the bedrock of event-driven architectures.
The Core Idea
In traditional systems, we store the current state of entities in a database—like "User balance: 50 at 10:15 AM."
When we call events "first-class citizens," we mean:
- Events are the source of truth, not derived data
- They're stored permanently, never updated or deleted
- Current state is computed from the sequence of events
Think of it like a bank statement versus your account balance. Your balance is just a summary—the real truth is in the chronological list of deposits and withdrawals. You can always reconstruct your balance by replaying those transactions.
Why This Matters
Treating events as immutable facts gives you:
- Complete audit trail: You know why something is in its current state
- Time travel: Replay events to see what state was at any point in the past
- Flexibility: Build new views or reports by reprocessing the same events differently
For example, rather than updating order_status = 'SHIPPED', you emit an OrderShipped event containing all relevant details (order ID, timestamp, carrier). The current status becomes a projection derived from the event history.
This isn't just philosophical—it's practical. Events become durable building blocks that multiple systems can consume, react to, and reason about independently.
Key Takeaway:
Events as first-class citizens means treating immutable historical facts as your primary data, making state a computed view rather than something you directly modify.