Course contentsShow
← System Design
Lesson 691 of 1,91919. Event Streaming PlatformsFree lesson

Events as First-Class Citizens

Understanding events as immutable facts representing state changes, forming the foundation of event-driven systems.

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: 100."Inevent−drivensystems,weshiftperspective:∗∗eventsbecometheprimarydata∗∗.Aneventisanimmutablerecordthatsomethinghappened:"Userdeposited100." In event-driven systems, we shift perspective: **events become the primary data**. An event is an immutable record that something happened: "User deposited 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.