{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P-lF7RutecXwqU6h6SZ",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "The team decided to adopt Event Sourcing instead of standard CRUD in PostgreSQL for financial transaction audit trails. The key driver is compliance: with mutable CRUD tables, we cannot reconstruct the history of state changes (e.g., who changed transaction #8821 from pending to approved and why). Two alternatives were considered: (1) Database triggers writing to a history_logs table - rejected because triggers only capture row-level changes (e.g., status 1 to 2) and lose business context such as user intent and the reason for the change. (2) Event Sourcing - chosen because it stores a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) that preserve full audit context. The architecture uses Kafka as the immutable event log, with a materialized view in PostgreSQL for fast frontend reads. This follows Martin Fowler's Event Sourcing Pattern. Implementation will be in src/services/transactionService.ts (event producers) and src/events/eventStore.ts (consumer/store logic).",
"summary": "Adopted Event Sourcing with Kafka for financial transaction audit trails instead of CRUD or database triggers, ensuring compliance-friendly immutable event history with business context preserved.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-compliance,kafka,postgres,financial-transactions",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1787532707642,
"updated_at": 1787532707642
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 275
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P-lF7RutecXwqU6h6SZ",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P-lF7RutecXwqU6h6SZ",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1787532707642
}
}
]
}