{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-Oxn4hJOwnhNeGGpKEMO",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trail Compliance",
"content": "Decision: Move from standard CRUD in PostgreSQL to Event Sourcing using Kafka for the financial transactions audit trail. Store immutable domain events in Kafka and build a materialized view in Postgres for fast reads on the frontend.\n\nWhy: Standard CRUD overwrites previous states on updates, losing business context. When compliance requested the history of transaction #8821, the team could not provide who changed the status from pending to approved. Database triggers with a history_logs table were considered but rejected because triggers only see row changes (e.g., status changed from 1 to 2) and do not capture the user intent or reason behind the change.\n\nAlternatives considered:\n1. Database triggers with history_logs table — rejected because business context is lost; triggers do not know why a change happened or the user intent behind it.\n2. Standard CRUD — rejected because updates overwrite previous states, making audit trails incomplete.\n\nCode involved: src/services/transactionService.ts (event producers) and src/events/eventStore.ts (consumer/store logic).\n\nReference: Martin Fowler's 'Event Sourcing Pattern' article — handles the audit requirement perfectly and is industry standard.",
"summary": "Adopted Event Sourcing over CRUD and database triggers to preserve full audit trail with business context for financial transaction compliance, using Kafka for immutable event storage and Postgres materialized views for reads.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1784342304025,
"updated_at": 1784342304025
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 49
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-Oxn4hJOwnhNeGGpKEMO",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-Oxn4hJOwnhNeGGpKEMO",
"title": "Event Sourcing over CRUD for Audit Trail Compliance",
"depth": 2,
"created_at": 1784342304025
}
}
]
}