← Back to lessons|architecture
Passkeys not supported in this browser
Event Sourcing over CRUD for Audit Trails
Adopted Event Sourcing over CRUD with Kafka for immutable audit trails in financial transactions, satisfying compliance requirements with business context preserved.
lesson_learnedevent-sourcingaudit-trailcompliancekafkapostgresmaterialized-view
Created 7/28/2026, 2:29:29 PM
Content
The team decided to move from standard CRUD in PostgreSQL to Event Sourcing for financial transaction audit trails. Updates in CRUD overwrite previous states, making it impossible to provide compliance history (e.g., who changed transaction #8821 from pending to approved). Database triggers were considered but rejected because they lose business context (they see row changes but not user intent). The decision is to use Kafka to store an immutable event log (TransactionCreated, TransactionApproved, StatusUpdated) with materialized views in Postgres for fast frontend reads. Reference: Martin Fowler's Event Sourcing Pattern article. Implementation in src/services/transactionService.ts (event producers) and src/events/eventStore.ts (consumer/store logic).