← Back to lessons|architecture
Passkeys not supported in this browser

Event Sourcing over CRUD for Audit Trails

Migrated financial transaction processing from CRUD to Event Sourcing using Kafka to ensure full audit trail compliance, with Postgres materialized views for reads.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailcompliancekafkapostgresmartin-fowler
Created 7/30/2026, 1:37:59 PM

Content

The team decided to migrate from standard CRUD operations in PostgreSQL to an Event Sourcing architecture for financial transaction audit compliance. Updates in the current CRUD model overwrite previous states, making it impossible to provide compliance-required history. The rejected alternative was adding a history_logs table with database triggers, which was dismissed because triggers cannot capture business context such as the why or user intent behind a change. The chosen approach uses Kafka to store an immutable event log (TransactionCreated, TransactionApproved, StatusUpdated) with a materialized view in Postgres for fast frontend reads. The decision is based on Martin Fowler's Event Sourcing Pattern article. Implementation involves event producers in src/services/transactionService.ts and consumer/store logic in src/events/eventStore.ts.

Graph Neighborhood