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

Event Sourcing over CRUD for Audit Trails

Team adopted Event Sourcing with Kafka for immutable event logging and Postgres materialized views instead of CRUD with database triggers, to satisfy compliance requirements for full audit trails with business context.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailcompliancekafkapostgresql
Created 7/18/2026, 1:37:13 AM

Content

Decision: Replace standard CRUD in PostgreSQL with Event Sourcing for financial transaction audit trails. Context: Compliance requires full history of transaction state changes with business context. Database triggers were considered but rejected because they only capture row-level changes (e.g., status 1 to 2) without recording why the change occurred or user intent. Event Sourcing stores immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka, providing a complete audit trail with business context. A materialized view in Postgres is built from the event log for fast frontend reads. Reference: Martin Fowler 'Event Sourcing Pattern' article. Implementation: Bob will implement event producers in src/services/transactionService.ts and consumer/store logic in src/events/eventStore.ts. Participants: Alice (Lead), Bob (Eng), Charlie (Security).

Graph Neighborhood