{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P1KfqXIA7aNiu4hLNdB",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "Decision: Adopt Event Sourcing instead of standard CRUD for financial transaction audit trails. Our current PostgreSQL CRUD approach overwrites previous states, making it impossible to provide compliance with full change history (e.g., who changed transaction #8821 from pending to approved and why). Alternatives considered: (1) Database triggers with a history_logs table — rejected because triggers only capture row-level changes (status 1→2) without business context or user intent. (2) Continue with CRUD + manual logging — rejected because it is error-prone and does not guarantee immutability. Chosen approach: Event Sourcing with Kafka storing the immutable event log (TransactionCreated, TransactionApproved, StatusUpdated, etc.) and a materialized view in PostgreSQL for fast frontend reads. This satisfies compliance requirements by maintaining a complete, immutable audit trail with full business context. Reference: Martin Fowler's Event Sourcing Pattern article. Files involved: src/services/transactionService.ts (event producers), src/events/eventStore.ts (consumer/store logic).",
"summary": "Replacing CRUD with Event Sourcing (Kafka + materialized Postgres views) for financial transaction audit trails to satisfy compliance requirements for immutable, context-rich change history.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql,financial-transactions",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1789217695891,
"updated_at": 1789217695891
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 379
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P1KfqXIA7aNiu4hLNdB",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P1KfqXIA7aNiu4hLNdB",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1789217695891
}
}
]
}