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

Event Sourcing over CRUD for Financial Transaction Audit Trails

Adopted Event Sourcing with Kafka for immutable audit trails instead of CRUD or database triggers, ensuring compliance with full business context preservation.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailcompliancekafkapostgresqlfinancial-transactions
Created 7/18/2026, 2:39:56 AM

Content

Decision: Use Event Sourcing over CRUD for financial transaction audit trails. Context: The team currently uses standard CRUD in PostgreSQL, but updates overwrite previous states, losing business context needed for compliance. Alternative considered — database triggers with a history_logs table — was rejected because triggers only capture row-level changes (e.g., status changed from 1 to 2) without the reason for the change or user intent. Decision: Store immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka as the event log, and build a materialized view in Postgres for fast frontend reads. Reference architecture: Martin Fowler's Event Sourcing Pattern article. Implementation files: src/services/transactionService.ts (event producers) and src/events/eventStore.ts (consumer/store logic).

Graph Neighborhood