{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P-k3l0I4mFWSzjC4hg-",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "The team decided to move from standard CRUD operations in PostgreSQL to Event Sourcing for the financial transaction audit trail system. The previous approach using CRUD overwrites previous states, making it impossible to provide compliance history (e.g., who changed transaction #8821 status from pending to approved). The alternative of using a history_logs table with database triggers was rejected because triggers only see row changes (e.g., status changed from 1 to 2) and lose business context — why the change happened and user intent behind it. Event Sourcing stores a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) via Kafka, with a materialized view in Postgres for fast frontend reads. This follows Martin Fowler's 'Event Sourcing Pattern' article. Files involved: src/services/transactionService.ts (event producers) and src/events/eventStore.ts (consumer/store logic).",
"summary": "Adopt Event Sourcing with Kafka for immutable event logging instead of CRUD in PostgreSQL for financial transaction audit trails, ensuring compliance requirements are met while preserving business context.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1787512950867,
"updated_at": 1787512950867
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 269
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P-k3l0I4mFWSzjC4hg-",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P-k3l0I4mFWSzjC4hg-",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1787512950867
}
}
]
}