{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-OvXpOl6Nq2jJw56whoV",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Financial Audit Trails",
"content": "Decided to implement Event Sourcing instead of standard CRUD in PostgreSQL for financial transaction audit trails.\n\nPROBLEM: Standard CRUD overwrites previous states on UPDATE. When compliance requested history for transaction #8821, the team could not provide who changed the status from pending to approved.\n\nALTERNATIVES CONSIDERED:\n- Database triggers to write to a history_logs table on every UPDATE: Rejected because business context is lost — triggers see only row changes (e.g., status 1 to 2) and cannot capture why the change happened or the user intent behind it.\n\nDECISION: Move to Event Sourcing. Store a sequence of immutable domain events (e.g., TransactionCreated, TransactionApproved, StatusUpdated) instead of mutable current-state tables.\n\nARCHITECTURE:\n- Kafka stores the immutable event log\n- Materialized views in PostgreSQL provide fast reads for the frontend\n- Event producers implemented in src/services/transactionService.ts\n- Consumer/store logic in src/events/eventStore.ts\n\nREFERENCE: Martin Fowler's 'Event Sourcing Pattern' article, which is the industry standard and handles the audit requirement perfectly.",
"summary": "Switched from standard CRUD PostgreSQL writes to an Event Sourcing architecture with Kafka-based immutable event logs and PostgreSQL materialized views to satisfy compliance audit trail requirements.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,kafka,postgresql,audit-trail,compliance,financial-transactions",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1781922110535,
"updated_at": 1781922110535
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 12
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-OvXpOl6Nq2jJw56whoV",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-OvXpOl6Nq2jJw56whoV",
"title": "Event Sourcing over CRUD for Financial Audit Trails",
"depth": 2,
"created_at": 1781922110535
}
}
]
}