---
topic: architecture
author: Crashtech Editorial
published: Nov 17, 2026 · read: 3 min
---

Event Sourcing in Practice: Immutable Logs, Temporal State Replay, and CQRS Projections

Why systems should remember how they got here, not just where they are: exploring Event Sourcing, append-only logs, snapshots, and CQRS projections.

– –

In traditional CRUD (Create, Read, Update, Delete) databases, state is destructive.

When a customer changes their delivery address, cancels an order item, or transfers money from their savings account, the application executes an UPDATE or DELETE statement. The previous state is overwritten on disk.

At that instant, history is permanently erased.

If a fraud investigator asks “What was the exact status of this account at 14:02 on Tuesday?”, or if a financial auditor requires proof of every balance transition, a CRUD database is blind. The table only knows where the record is now; it has zero structural memory of how it got here.

Event Sourcing is the architectural decision to make history the primary source of truth.

Instead of mutating records in place, an application captures every state change as an immutable, append-only domain event. Current state is never stored as ground truth; it is derived dynamically by replaying the event log.

+-------------------------------------------------------------------------------+
|                       CRUD vs EVENT SOURCING DATA MODEL                       |
+-------------------------------------------------------------------------------+

Traditional CRUD Table (Destructive Overwrites):
+------------+--------------------+-----------+--------------------+
| order_id   | shipping_address   | status    | total_amount       |
+------------+--------------------+-----------+--------------------+
| ord_1024   | 456 Elm St, Austin | SHIPPED   | $85.00             |
+------------+--------------------+-----------+--------------------+
* What was the original address? Was an item removed? History is gone!

Event-Sourced Append-Only Log (Immutable Stream of Facts):
Seq  Timestamp    Event Type               Payload
---------------------------------------------------------------------------------
1    10:00:00 UTC OrderCreated             { items: [A, B], addr: "123 Oak St" }
2    10:05:00 UTC ItemRemovedFromOrder     { item_id: B, new_total: $85.00 }
3    10:12:00 UTC ShippingAddressChanged   { new_addr: "456 Elm St, Austin" }
4    10:30:00 UTC PaymentCaptured          { amount: $85.00, tx: "ch_99" }
5    11:00:00 UTC OrderShipped             { carrier: "FedEx", tracking: "..." }

Current State = LeftFold(InitialState, [Event_1, Event_2, Event_3, Event_4, Event_5])

1. The Anatomy of an Event

An event is not an intent or a command. A command is a request (“ChargeCreditCard”) that can be rejected.

An event is an immutable statement of historical fact that has already occurred in the past:

  • Past Tense Verbs: OrderPlaced, AccountDebited, PasswordResetRequested.
  • Immutable: Once written to the event store, an event can never be modified or deleted.
  • Self-Contained: Contains all metadata and context necessary to understand what transpired.
{
  "event_id": "evt_9f8a2b3c",
  "aggregate_id": "acc_4091",
  "aggregate_type": "BankAccount",
  "version": 4,
  "timestamp": "2026-11-16T08:12:00.124Z",
  "event_type": "FundsWithdrawn",
  "data": {
    "amount": 150.00,
    "currency": "USD",
    "atm_id": "atm_sf_04"
  }
}

2. Rehydrating State: Aggregates and Snapshots

To execute business logic (e.g., verifying whether a customer has sufficient funds to withdraw $50), the system must reconstruct the Aggregate (the current in-memory domain object).

This is achieved via a Left Fold function:

# Rehydrating an Account Aggregate from raw events
class BankAccount:
    def __init__(self):
        self.balance = 0.0
        self.is_closed = False
        
    def apply(self, event):
        if event.type == "AccountOpened":
            self.balance = event.data["initial_deposit"]
        elif event.type == "FundsDeposited":
            self.balance += event.data["amount"]
        elif event.type == "FundsWithdrawn":
            self.balance -= event.data["amount"]
        elif event.type == "AccountClosed":
            self.is_closed = True
        return self

def load_account(aggregate_id, event_store):
    events = event_store.get_events_for_aggregate(aggregate_id)
    account = BankAccount()
    for e in events:
        account.apply(e)
    return account

The Snapshot Optimization

If an account has been active for 5 years and contains 50,000 transactions, replaying all 50,000 events on every single API request destroys read latency.

Production systems generate Periodic Snapshots:

[Event 1..1000] ---> [Snapshot at Version 1000: Balance = $4,250.00]
                                |
                                v (Next read starts here!)
                     [Event 1001] -> [Event 1002] -> Current State!

The system loads the latest snapshot from disk and replays only the few events that occurred after the snapshot version, keeping aggregate rehydration under 2 milliseconds.


3. Pairing Event Sourcing with CQRS Projections

A pure event-sourced log is optimized exclusively for writing events and replaying a single aggregate by its ID.

It is completely useless for querying:

-- An append-only event log CANNOT efficiently execute:
SELECT * FROM orders WHERE customer_id = 'c_42' AND status = 'SHIPPED';

To enable complex queries, Event Sourcing is almost universally paired with CQRS (Command Query Responsibility Segregation):

+-------------------------------------------------------------------------------+
|                       EVENT SOURCING WITH CQRS PROJECTIONS                    |
+-------------------------------------------------------------------------------+

[Client Command: "Place Order"]
       |
       v
[Command Handler] ---> Verifies Business Invariants
       |
       v
[Event Store (The Single Source of Truth)]
(Appends: OrderPlacedEvent to PostgreSQL / EventStoreDB / Kafka)
       |
       +=== (Asynchronous Event Streaming via CDC / Outbox) ===+
       |                                                       |
       v                                                       v
[Projection Worker A]                                   [Projection Worker B]
Updates Relational SQL Read DB:                         Updates Elasticsearch Index:
INSERT INTO order_summary VALUES (...)                  INDEX JSON document for search
       |                                                       |
       v                                                       v
[Frontend Dashboard Reads from SQL]                     [Full-Text Search Reads]

Projection workers subscribe to the event stream, transforming raw event sequences into highly denormalized read-optimized tables. If you need a new analytics view, you deploy a new projection worker and replay the historical event log from beginning of time.


4. The Engineering Trade-Offs of Event Sourcing

DimensionTraditional CRUDEvent Sourcing + CQRS
AuditabilityPoor (Requires manual shadow audit tables)Native (The event stream IS the audit log)
Temporal QueryingImpossible (Cannot view past states)Native (Replay events up to any timestamp T)
Operational ComplexityLow (Standard relational databases)High (Event store, projectors, snapshotting)
Schema EvolutionALTER TABLE migrationsComplex (Requires event upcasting / versioning)
Read ConsistencyImmediate strong consistencyEventual consistency on read projections

Summary and Key Takeaways

  1. Remember how you got here: Stop destroying history with UPDATE and DELETE; capture business state as an immutable sequence of domain facts.
  2. Derive state dynamically: Rehydrate aggregates by folding events sequentially over an initial state.
  3. Amortize replay with snapshots: Save periodic aggregate checkpoints to prevent long event chains from degrading load times.
  4. Use CQRS for queries: Decouple the append-only event store from read models; use asynchronous projectors to populate search engines and relational caches.
  5. Accept eventual consistency: Read projections lag the event store by milliseconds; design applications and user interfaces to accommodate asynchronous synchronization.
Advertisement

/* Comments */