{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-Oy-NgFvmaERYwXkhisV",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "Decision: Replace standard CRUD in PostgreSQL with Event Sourcing for financial transaction audit trails.\n\nContext: Compliance required history of transaction #8821 (who changed status from pending to approved). Standard CRUD overwrites previous states on UPDATE, losing business context. Database triggers were considered but rejected because they only capture row-level changes (e.g., status 1 to 2) without knowing why the change happened or user intent.\n\nSolution: Store immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka as the event log. Build a materialized view in Postgres for fast frontend reads. This satisfies compliance by preserving full audit context.\n\nFiles involved:\n- src/services/transactionService.ts (event producers)\n- src/events/eventStore.ts (consumer/store logic)\n\nReference: Martin Fowler's \"Event Sourcing Pattern\" article.\n\nAlternatives rejected:\n1. Standard CRUD - loses history on UPDATE\n2. Database triggers - loses business context, only sees row changes",
"summary": "Adopt Event Sourcing over CRUD for financial transaction audit trails, using Kafka for immutable event log and Postgres materialized views for reads, per Martin Fowler's Event Sourcing Pattern.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,postgresql,kafka",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1784565384251,
"updated_at": 1784565384251
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 54
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-Oy-NgFvmaERYwXkhisV",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-Oy-NgFvmaERYwXkhisV",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1784565384251
}
}
]
}