{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-OvXpeCOMDh_kagoGhWP",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Financial Transaction Audit Trails",
"content": "DECISION: Adopt Event Sourcing instead of standard CRUD for financial transaction audit trails to satisfy compliance requirements.\n\nCONTEXT: The team currently uses standard CRUD in PostgreSQL. A compliance audit request for transaction #8821 history revealed that updates overwrite previous states, making it impossible to trace who changed a status from pending to approved.\n\nALTERNATIVES CONSIDERED:\n- Database triggers writing to a history_logs table: Rejected because triggers only see row changes (e.g., status field changing from 1 to 2) and lose business context.\n\nCHOSEN APPROACH: Event Sourcing — store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated). Use Kafka as the immutable event log. Build materialized views in Postgres for fast reads.\n\nREFERENCE: Martin Fowler's Event Sourcing Pattern article.\n\nFILES INVOLVED:\n- src/services/transactionService.ts — event producers\n- src/events/eventStore.ts — event consumer and store logic",
"summary": "Adopted Event Sourcing over CRUD for financial transaction audit trails to satisfy compliance. Using Kafka as immutable event log with Postgres materialized views for reads.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgres",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1781922177881,
"updated_at": 1781922177881
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 15
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-OvXpeCOMDh_kagoGhWP",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-OvXpeCOMDh_kagoGhWP",
"title": "Event Sourcing over CRUD for Financial Transaction Audit Trails",
"depth": 2,
"created_at": 1781922177881
}
}
]
}