{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-OzmffiZ_ItkYLbfssLz",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "The team decided to adopt Event Sourcing over standard CRUD for the audit trail of financial transactions. Under CRUD, updates overwrite previous states in a mutable Postgres table, so when compliance requested the history of transaction #8821, the team could not determine who changed the status from pending to approved. A database-trigger-based history table was considered but rejected because triggers only see row-level changes (e.g., status 1 to 2) and lose the business context, user intent, and reason behind the change. With Event Sourcing, the team stores a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in an immutable event log via Kafka, and builds a materialized view in Postgres for fast frontend reads. Implementation work is split between event producers in src/services/transactionService.ts and the consumer/store logic in src/events/eventStore.ts. The design follows Martin Fowler's Event Sourcing Pattern article, which is the industry-standard reference for satisfying audit requirements.",
"summary": "The team adopted Event Sourcing over CRUD with Kafka as the immutable event log and Postgres materialized views for reads, to satisfy compliance audit-trail requirements for financial transactions.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql,crud,financial-transactions",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1786482965412,
"updated_at": 1786482965412
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 127
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-OzmffiZ_ItkYLbfssLz",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-OzmffiZ_ItkYLbfssLz",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1786482965412
}
}
]
}