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

Event Sourcing over CRUD for Financial Transaction Audit Trails

Following Martin Fowler's Event Sourcing Pattern, we replace CRUD with an immutable event log via Kafka and materialized Postgres views to satisfy compliance audit requirements while preserving full business context of transaction state changes.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailkafkapostgrescompliance
Created 6/20/2026, 10:32:06 PM

Content

Decided to move from standard CRUD in PostgreSQL to an Event Sourcing architecture for financial transaction audit trails. Standard CRUD overwrites previous states on UPDATE, which prevents providing compliance with full transaction history (e.g., who changed transaction #8821 from pending to approved). Alternatives considered: adding a history_logs table with database triggers on UPDATE. This was rejected because business context is lost triggers only see row changes without user intent or the why behind changes. The chosen approach uses Kafka to store an immutable sequence of domain events (TransactionCreated, TransactionApproved, StatusUpdated), with a materialized view in Postgres for fast frontend reads. Implementation: event producers in src/services/transactionService.ts, consumer/store logic in src/events/eventStore.ts. Reference: Martin Fowler's Event Sourcing Pattern article.

Graph Neighborhood