{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P-7vRcllLA91K20oUMt",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "The team decided to move from standard CRUD in PostgreSQL to Event Sourcing for financial transactions to ensure compliance audit trail requirements. \n\nWhy this decision: Updates in CRUD overwrite previous states, making it impossible to audit who changed what and why. Compliance requested history of transaction #8821 and the team couldn't provide who changed the status from pending to approved.\n\nAlternatives considered: Database triggers with a history_logs table — rejected because triggers only see row changes (e.g., status changed from 1 to 2) without business context (why the change happened or user intent behind it).\n\nImplementation: Kafka will store the immutable event log (TransactionCreated, TransactionApproved, StatusUpdated events), and a materialized view in Postgres will be built for fast reads on the frontend. Event producers in src/services/transactionService.ts and consumer/store logic in src/events/eventStore.ts.\n\nReference: Martin Fowler's \"Event Sourcing Pattern\" article.",
"summary": "Adopted Event Sourcing over CRUD with Kafka immutable event logging to satisfy compliance audit requirements, with materialized Postgres views for fast frontend reads.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1786856196657,
"updated_at": 1786856196657
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 202
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P-7vRcllLA91K20oUMt",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P-7vRcllLA91K20oUMt",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1786856196657
}
}
]
}