← Back to lessons|architecture
Passkeys not supported in this browser
Event Sourcing over CRUD for Financial Transaction Audit Trails
Team chose Event Sourcing with Kafka over standard CRUD and database triggers for financial transaction audit trails to satisfy compliance requirements
lesson_learnedevent-sourcingaudit-trailcompliancepostgresqlkafkafinancial-transactions
Created 6/16/2026, 10:36:14 PM
Content
Team decided to adopt Event Sourcing instead of standard CRUD with PostgreSQL for financial transaction audit trails. WHAT WAS DECIDED AND WHY: Move from standard CRUD to Event Sourcing for financial transactions. Instead of storing mutable state in a table, store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated). Use Kafka to store the immutable event log, and build a materialized view in Postgres for fast reads. This ensures full compliance with audit requirements, preserving complete history of who changed what and when. ALTERNATIVES CONSIDERED AND REJECTED: Database triggers with a history_logs table: Rejected because business context is lost. Triggers only see row changes (e.g., status changed from 1 to 2) but don't capture why the change happened or the user intent behind it. Standard CRUD updates overwrite previous states, making it impossible to answer compliance questions like who changed transaction #8821 from pending to approved. FILES/CODE INVOLVED: src/services/transactionService.ts event producers; src/events/eventStore.ts consumer/store logic. REFERENCE: Martin Fowler's Event Sourcing Pattern article was cited as the reference architecture.