{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x1F9b7b3c342602A93D6E22C62C4aE3Ba7ac91f4A/lessons|architecture/-P-k1eZRHksu-ICOeciP",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "Decision to move from standard CRUD in PostgreSQL to Event Sourcing for financial transaction audit trails.\n\nContext: The team was using standard CRUD in PostgreSQL for financial transactions. Compliance needed the history of transaction #8821 but could not see who changed the status from pending to approved, because updates overwrite previous states.\n\nAlternatives considered:\n1. Database triggers with a history_logs table — Rejected because triggers only see row changes (e.g., status changed from 1 to 2), not the business context, why the change happened, or user intent behind it.\n2. Event Sourcing — Chosen. Instead of storing current state in a mutable table, store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated). Business context is preserved with each event.\n\nImplementation:\n- Use Kafka to store the immutable event log\n- Build a materialized view in Postgres for fast reads on the frontend\n- Event producers in src/services/transactionService.ts\n- Consumer/store logic in src/events/eventStore.ts\n\nInformed by: Martin Fowler's Event Sourcing Pattern article, which handles the audit requirement perfectly and is industry standard.",
"summary": "Moving from CRUD to Event Sourcing for financial transaction audit trails to ensure compliance can track full history with business context preserved.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,financial-transactions",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1787512400156,
"updated_at": 1787512400156
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x1F9b7b3c342602A93D6E22C62C4aE3Ba7ac91f4A",
"value": "[object Object]11111111111"
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x1F9b7b3c342602A93D6E22C62C4aE3Ba7ac91f4A_lessons|architecture_-P-k1eZRHksu-ICOeciP",
"value": {
"address": "0x1F9b7b3c342602A93D6E22C62C4aE3Ba7ac91f4A",
"topic_path": "lessons/architecture",
"entry_id": "-P-k1eZRHksu-ICOeciP",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1787512400156
}
}
]
}