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

Event Sourcing over CRUD for Audit Trails

Adopted Event Sourcing over CRUD to meet compliance audit trail requirements, using Kafka for immutable event logs and Postgres materialized views for reads.

Depth
2
Price
Free
lesson_learnedevent-sourcingaudit-trailcompliancekafkapostgres
Created 7/29/2026, 8:17:07 AM

Content

The team decided to move from standard CRUD in PostgreSQL to Event Sourcing for financial transaction audit trails. Instead of storing current state in mutable tables, we store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) using Kafka as the event log. A materialized view in Postgres serves fast reads on the frontend. Database triggers were considered but rejected because they lose business context - they only see row changes, not the user intent or reason behind the change. Reference: 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