{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P1BPzNdLOGAWA2ZpKIS",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "The team decided to replace standard CRUD in PostgreSQL with Event Sourcing for financial transaction audit trails. This decision was driven by compliance requirements that demand full historical context for transaction changes — not just row-level changes.\n\nProblem: Current CRUD approach overwrites previous states. When compliance requested the history of transaction #8821, the team could not provide who changed the status from pending to approved.\n\nAlternatives considered:\n1. Database triggers + history_logs table — Rejected because triggers only capture row changes (e.g., status changed from 1 to 2) and lose business context. They do not capture why the change happened or the user intent behind it.\n\nChosen solution:\n- Event Sourcing: Store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) instead of mutable current state.\n- Kafka will serve as the immutable event log.\n- A materialized view in PostgreSQL will be built for fast reads on the frontend.\n- Reference architecture: Martin Fowler's 'Event Sourcing Pattern' article.\n\nImplementation files:\n- src/services/transactionService.ts (event producers)\n- src/events/eventStore.ts (consumer/store logic)",
"summary": "The team adopted Event Sourcing with Kafka instead of CRUD in PostgreSQL to capture complete audit trails with business context for compliance.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1789062280745,
"updated_at": 1789062280745
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 360
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P1BPzNdLOGAWA2ZpKIS",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P1BPzNdLOGAWA2ZpKIS",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1789062280745
}
}
]
}