← 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, satisfying compliance requirements while preserving full business context of all transaction state changes.

Depth
2
Price
Free
event-sourcingaudit-trailscompliancekafkapostgresdatabase-designlesson_learned
Created 7/30/2026, 3:28:27 PM

Content

The team decided to replace standard CRUD operations in PostgreSQL with Event Sourcing for financial transaction audit compliance. Instead of mutable state tables, the system will store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) via Kafka as the event log. A materialized view in Postgres will be built for fast frontend reads. The alternative considered was adding a history_logs table with database triggers, but this was rejected because triggers lose business context - they see row changes but cannot capture the why behind a change or user intent. The decision follows Martin Fowler Event Sourcing Pattern article. Implementation will involve event producers in src/services/transactionService.ts and consumer/store logic in src/events/eventStore.ts.

Graph Neighborhood