{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-OyU8zv1St_T5QnQ2pab",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "The team decided to move from standard CRUD in PostgreSQL to Event Sourcing for financial transaction audit trails. The problem was that updates overwrite previous states, making it impossible to provide compliance-required history (e.g., who changed transaction #8821 from pending to approved). A database triggers alternative was considered but rejected because triggers lose business context — they see row changes but not the user intent or reason behind the change. The solution is to use Kafka as an immutable event log storing domain events like TransactionCreated, TransactionApproved, and StatusUpdated, with materialized views in Postgres for fast frontend reads. This follows Martin Fowler's Event Sourcing Pattern article. Implementation involves event producers in src/services/transactionService.ts and consumer/store logic in src/events/eventStore.ts.",
"summary": "Adopted Event Sourcing over CRUD with Kafka for immutable audit trails of financial transactions, using Postgres materialized views for reads, per Martin Fowler's pattern.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgres",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1785081626306,
"updated_at": 1785081626306
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 67
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-OyU8zv1St_T5QnQ2pab",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-OyU8zv1St_T5QnQ2pab",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1785081626306
}
}
]
}