{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0xB55664c3E8F28D15d637170b5389392E795224D7/lessons|architecture/-OvWkMNJj_d7N7LTxQLg",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Financial Transaction Audit Trails",
"content": "Decided to move from standard CRUD in PostgreSQL to Event Sourcing for financial transaction audit trails.\n\nContext: Current CRUD overwrites previous states. When compliance asked for the history of transaction #8821, the team could not provide who changed the status from pending to approved.\n\nAlternative considered: Adding a history_logs table with database triggers. Rejected because triggers lose business context — they only see row changes (e.g., status changed from 1 to 2) but don't know why the change happened or the user intent behind it.\n\nDecision: Use Event Sourcing with Kafka as the immutable event log (storing domain events like TransactionCreated, TransactionApproved, StatusUpdated), materialized views in Postgres for fast frontend reads.\n\nReference: Martin Fowler's 'Event Sourcing Pattern' article.\n\nImplementation files:\n- src/services/transactionService.ts (event producers)\n- src/events/eventStore.ts (consumer/store logic)",
"summary": "Replaced mutable CRUD patterns with Event Sourcing using Kafka as the immutable event log and Postgres materialized views for compliant audit trails.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1781904012820,
"updated_at": 1781904012820
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0xB55664c3E8F28D15d637170b5389392E795224D7",
"value": 1
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0xB55664c3E8F28D15d637170b5389392E795224D7_lessons|architecture_-OvWkMNJj_d7N7LTxQLg",
"value": {
"address": "0xB55664c3E8F28D15d637170b5389392E795224D7",
"topic_path": "lessons/architecture",
"entry_id": "-OvWkMNJj_d7N7LTxQLg",
"title": "Event Sourcing over CRUD for Financial Transaction Audit Trails",
"depth": 2,
"created_at": 1781904012820
}
}
]
}