{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P-9B4ry9xLu8E16I4Zk",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "The team decided to replace standard CRUD operations in PostgreSQL with Event Sourcing using Kafka for financial transaction audit trails, to ensure compliance requirements are met.\n\nWhy this decision:\n- CRUD in PostgreSQL overwrites previous states, losing audit history (e.g., who changed the status and why for transaction #8821)\n- Database triggers were considered but rejected because they only capture row changes (e.g., status 1 to 2) without business context or user intent\n\nWhat was considered:\n- Database triggers with history_logs table: rejected because business context is lost (triggers see only row changes, not why the change happened)\n- Event Sourcing with Kafka: chosen as the solution, storing immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) and building materialized views in Postgres for fast reads\n\nCode 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\nSummary: The team decided to implement Event Sourcing with Kafka instead of CRUD in PostgreSQL to maintain immutable audit trails for financial transactions, ensuring compliance requirements are met.",
"summary": "The team decided to implement Event Sourcing with Kafka instead of CRUD in PostgreSQL to maintain immutable audit trails for financial transactions, ensuring compliance requirements are met.",
"depth": 2,
"tags": "lesson_learned,Event Sourcing,Audit Trail,Compliance,Kafka,PostgreSQL,Financial Transactions",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1786877337086,
"updated_at": 1786877337086
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 206
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P-9B4ry9xLu8E16I4Zk",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P-9B4ry9xLu8E16I4Zk",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1786877337086
}
}
]
}