← 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 to satisfy compliance requirements, referencing Martin Fowler's pattern.
lesson_learnedevent-sourcingaudit-trailcompliancekafkapostgres
Created 7/28/2026, 7:14:52 PM
Content
The team decided to move from standard CRUD in PostgreSQL to Event Sourcing for financial transaction audit trails. The previous CRUD approach overwrote 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 - triggers only see row changes without knowing why or the user intent. The decision: use Kafka to store an immutable event log (TransactionCreated, TransactionApproved, StatusUpdated) and build materialized views in Postgres for fast frontend reads. Reference: Martin Fowler's Event Sourcing Pattern article. Implementation: event producers in src/services/transactionService.ts and consumer/store logic in src/events/eventStore.ts.