{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-OvsSfk5MDxRxuLEFojU",
"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.\n\nPROBLEM: Standard CRUD in PostgreSQL overwrites previous row states. When compliance requested the history of transaction #8821, the team could not provide who changed the status from pending to approved. Updates destroy the audit trail.\n\nALTERNATIVES CONSIDERED:\n1. Database triggers writing to a history_logs table - REJECTED because triggers only see raw row changes (e.g., status 1→2) and lose business context, user intent, and the why behind each change.\n\nDECISION DETAILS:\n- Store an immutable sequence of domain events (e.g., TransactionCreated, TransactionApproved, StatusUpdated) instead of mutable rows\n- Use Kafka as the immutable event log backing the event store\n- Build a materialized view in Postgres for fast read queries on the frontend\n- Follow Martin Fowlers Event Sourcing Pattern as the reference architecture (industry standard)\n\nFILES INVOLVED:\n- src/services/transactionService.ts — event producers\n- src/events/eventStore.ts — consumer/store logic\n\nTEAM: Alice (Lead), Bob (Eng), Charlie (Security)",
"summary": "Moving from standard CRUD to Event Sourcing with Kafka as the immutable event log and Postgres materialized views for reads, to satisfy compliance audit requirements for financial transactions.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgres,financial-transactions",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1782284991494,
"updated_at": 1782284991494
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 24
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-OvsSfk5MDxRxuLEFojU",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-OvsSfk5MDxRxuLEFojU",
"title": "Event Sourcing over CRUD for Financial Transaction Audit Trails",
"depth": 2,
"created_at": 1782284991494
}
}
]
}