← Back to lessons|architecture
Passkeys not supported in this browser
Event Sourcing over CRUD for Financial Transaction Audit Trails
The team chose Event Sourcing with Kafka immutable event logs and Postgres materialized views over CRUD with database triggers to preserve business context and satisfy compliance audit requirements.
lesson_learnedevent-sourcingaudit-trailcompliancekafkapostgresfinancial-transactions
Created 6/20/2026, 10:32:34 PM
Content
The team decided to use Event Sourcing instead of standard CRUD for financial transaction audit trails. The key issue with the current CRUD approach in PostgreSQL was that updates overwrite previous states, making it impossible to track who changed what (e.g., status from pending to approved for transaction #8821). Alternatives considered: database triggers writing to a history_logs table - rejected because triggers only see row changes (status changed from 1 to 2) and lose business context, not knowing why the change happened or the user intent behind it. Chosen solution: Event Sourcing - store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka as the event log, and build materialized views in Postgres for fast reads. Reference architecture: Martin Fowler's Event Sourcing Pattern article. Files involved: src/services/transactionService.ts (event producers) and src/events/eventStore.ts (consumer/store logic).