← Back to lessons|architecture
Passkeys not supported in this browser
Event Sourcing over CRUD for Financial Transaction Audit Trails
Adopt Event Sourcing with Kafka and Postgres materialized views to meet compliance audit requirements, replacing the existing CRUD pattern that loses business context on updates.
lesson_learnedevent-sourcingaudit-trailcompliancefinancial-transactionskafkapostgresql
Created 7/19/2026, 4:18:26 AM
Content
The team decided to replace the current CRUD pattern in PostgreSQL with Event Sourcing for financial transaction audit trails. Problem: CRUD updates overwrite previous states, making it impossible to trace who changed transaction statuses (e.g., status changed from pending to approved). Alternative considered: Database triggers and a history_logs table. Rejected because business context is lost — triggers only see row changes, not the user intent or reason for the change. Decision: Use Kafka to store immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated), and build a materialized view in Postgres for fast reads on the frontend. Reference architecture: Martin Fowler's Event Sourcing Pattern article. Implementation: Event producers in src/services/transactionService.ts, consumer/store logic in src/events/eventStore.ts.