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

Event Sourcing over CRUD for Audit Trails

Adopted Event Sourcing over CRUD with Kafka and Postgres materialized views to satisfy audit compliance for financial transactions.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailcompliancepostgresqlkafka
Created 7/29/2026, 3:59:48 PM

Content

Decision: Adopt Event Sourcing over standard CRUD for financial transaction audit trails. Problem: PostgreSQL updates overwrite previous states, losing compliance history (e.g., transaction #8821 status changes). Alternative considered: database triggers — rejected because they only capture row changes without business context (who changed it and why). Final decision: Use Kafka as the immutable event log for domain events (TransactionCreated, TransactionApproved, StatusUpdated) and build a Postgres materialized view for fast frontend reads. Reference architecture: Martin Fowler's 'Event Sourcing Pattern' article. Implementation scope: src/services/transactionService.ts (event producers), src/events/eventStore.ts (consumer/store logic). Rationale: Satisfies compliance audit requirements by preserving full business context of state changes.

Graph Neighborhood