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

Event Sourcing over CRUD for Financial Transaction Audit Trails

The team chose Event Sourcing with Kafka over standard CRUD and database triggers for financial transaction audit trails to satisfy compliance requirements for full history tracking.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailkafkafinancial-transactionscompliancepostgresql
Created 6/20/2026, 2:22:10 AM

Content

DECISION: Move from standard CRUD in PostgreSQL to Event Sourcing for financial transactions.

PROBLEM: Standard CRUD overwrites previous states. When compliance requested the history of transaction #8821, the team could not provide who changed the status from pending to approved.

ALTERNATIVES CONSIDERED:
1. Database triggers on a history_logs table — REJECTED because business context is lost. A trigger only sees row changes (e.g., status changed from 1 to 2), it doesn't know why the change happened or the user intent behind it.

CHOSEN APPROACH: Event Sourcing with Kafka. Store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in an immutable event log via Kafka. Build a materialized view in PostgreSQL for fast reads on the frontend.

FILES AFFECTED:
- src/services/transactionService.ts — event producers
- src/events/eventStore.ts — consumer and store logic

REFERENCE: Martin Fowler's 'Event Sourcing Pattern' article.

Graph Neighborhood