← 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 PostgreSQL CRUD and database triggers to maintain immutable audit trails for financial transactions, ensuring compliance can trace every state change with full business context.
lesson_learnedevent-sourcingaudit-trailcompliancekafkapostgresain-architecture
Created 6/19/2026, 9:20:37 PM
Content
Decision: Adopt Event Sourcing pattern instead of standard CRUD for financial transaction audit trails. WHY: The current PostgreSQL CRUD approach overwrites previous states on every update. During a compliance audit for transaction #8821, the team could not determine who changed the status from pending to approved because update history was lost. ALTERNATIVES CONSIDERED: 1. Database triggers writing to a history_logs table — REJECTED because triggers only see row-level changes (e.g., status 1→2) and lose business context and user intent behind the change. 2. Staying with CRUD — REJECTED because it inherently cannot provide full audit history. IMPLEMENTATION: - Immutable domain events stored via Kafka (e.g., TransactionCreated, TransactionApproved, StatusUpdated) - Materialized views in PostgreSQL for fast frontend reads - Event producers in src/services/transactionService.ts - Event consumer/store logic in src/events/eventStore.ts REFERENCE: Martin Fowler's 'Event Sourcing Pattern' article — provides the industry-standard reference architecture for this approach. This satisfies compliance requirements by preserving complete event history with full context.