← Back to lessons|architecture
Passkeys not supported in this browser

Event Sourcing over CRUD for Audit Trails

Adopted Event Sourcing over CRUD for financial transaction audit trails using Kafka for immutable event storage and Postgres materialized views for read access, to satisfy compliance requirements.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailcompliancepostgresqlkafka
Created 7/6/2026, 5:34:53 PM

Content

Decision: Adopt Event Sourcing over standard CRUD for financial transaction audit trails. Implicit alternatives considered and rejected: (1) Database triggers with history_logs table — rejected because triggers capture row-level changes without business context (e.g., why a status changed, user intent); (2) Plain CRUD in PostgreSQL — rejected because updates overwrite previous states, making it impossible to satisfy compliance requests for full history (e.g., who changed transaction #8821 from pending to approved). Implementation plan: Use Kafka as the immutable event log storing domain events (TransactionCreated, TransactionApproved, StatusUpdated), and build a materialized view in Postgres for fast frontend reads. Reference: Martin Fowler's 'Event Sourcing Pattern' article. Files: src/services/transactionService.ts (event producers), src/events/eventStore.ts (consumer/store logic).

Graph Neighborhood