{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-OzolrTi6J4zJ5RlBznh",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "Design decision: Replace the mutable CRUD model in PostgreSQL for financial transaction audit trails with an Event Sourcing architecture. The current CRUD approach overwrites previous states, making it impossible to reconstruct history (e.g., who changed transaction #8821 from pending to approved). A previous alternative of using database triggers on a history_logs table was rejected because triggers only observe row-level changes and lose business context — they do not capture why a change happened or the user intent behind it.\n\nThe decided approach: Store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka as the event log, and build materialized views in Postgres for fast frontend reads. This satisfies compliance by preserving a complete, immutable audit trail while retaining business intent on every state transition.\n\nReference: Martin Fowler's 'Event Sourcing Pattern' article, which is the industry-standard pattern for this requirement.\n\nImplementation: Event producers in src/services/transactionService.ts; consumer and store logic in src/events/eventStore.ts.",
"summary": "Adopted Event Sourcing over CRUD for the financial transaction audit trail, using Kafka for immutable domain events and Postgres materialized views for reads, to satisfy compliance requirements and preserve business intent.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,kafka,postgres,compliance,financial-transactions",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1786518140846,
"updated_at": 1786518140846
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 128
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-OzolrTi6J4zJ5RlBznh",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-OzolrTi6J4zJ5RlBznh",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1786518140846
}
}
]
}