{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-OvWkmEb2FkGZvLhfe05",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "We decided to replace standard CRUD in PostgreSQL with Event Sourcing for financial transaction audit trails. The previous approach overwrote previous states on UPDATE, making it impossible to provide compliance with a complete history of who changed a transaction status (e.g., transaction #8821 pending to approved). An alternative of using database triggers to write to a history_logs table was considered but rejected because triggers only see row-level changes and lose business context -- they don't capture why the change happened or user intent. The chosen approach stores a sequence of immutable domain events (e.g., TransactionCreated, TransactionApproved, StatusUpdated) using Kafka as the immutable event log, with a materialized view in PostgreSQL for fast reads on the frontend. This satisfies compliance requirements while preserving full audit context. Reference: Martin Fowler's Event Sourcing Pattern article. Implementation files: src/services/transactionService.ts (event producers), src/events/eventStore.ts (consumer/store logic).",
"summary": "Moved from standard CRUD to Event Sourcing with Kafka for immutable transaction audit trails, replacing mutable PostgreSQL tables to satisfy compliance requirements for complete history tracking.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgres",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1781904122855,
"updated_at": 1781904122855
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 10
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-OvWkmEb2FkGZvLhfe05",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-OvWkmEb2FkGZvLhfe05",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1781904122855
}
}
]
}