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

Event Sourcing over CRUD for Audit Trails

Event Sourcing selected over CRUD to preserve business context and satisfy financial compliance audit requirements.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailcompliancepostgresqlkafka
Created 7/26/2026, 1:46:45 PM

Content

The engineering team decided to replace standard CRUD operations in PostgreSQL with Event Sourcing to meet audit trail compliance requirements. The current approach loses business context when updates overwrite previous states (e.g., compliance could not determine who changed transaction #8821 status from pending to approved). The alternative of using database triggers with a history_logs table was considered but rejected because triggers only capture row-level changes without the user intent or business reason behind the change. The chosen approach stores immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka, and builds materialized views in Postgres for fast frontend reads. The team is following Martin Fowler's 'Event Sourcing Pattern' article as the reference architecture. Implementation will be split between src/services/transactionService.ts (producers) and src/events/eventStore.ts (consumer/store).

Graph Neighborhood