{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P1I8nOb0fdiAzBLoFNd",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Financial Transaction Audit Trails",
"content": "Decision: Adopt Event Sourcing instead of standard CRUD with database triggers for financial transaction audit trails.\n\nProblem: With CRUD in PostgreSQL, updates overwrite previous states, making it impossible to provide compliance teams with a full history of who changed what and why (e.g., transaction #8821 status change from pending to approved had no traceable audit trail).\n\nWhy Event Sourcing: Instead of storing mutable current state, we store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka as the event log. A materialized view in Postgres provides fast reads for the frontend. This preserves full business context including user intent behind each state change.\n\nWhy not database triggers: Triggers only capture row-level changes (e.g., status changed from 1 to 2) and lose business context — they cannot capture why a change happened or the user intent behind it.\n\nImplementation files: src/services/transactionService.ts (event producers), src/events/eventStore.ts (consumer/store logic).\n\nReference: Martin Fowler's Event Sourcing Pattern article — industry standard approach for audit requirements.",
"summary": "Adopting Event Sourcing with Kafka for immutable event logs and Postgres materialized views for financial transaction audit trails, replacing CRUD + triggers which lost business context needed for compliance.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1789175215719,
"updated_at": 1789175215719
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 373
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P1I8nOb0fdiAzBLoFNd",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P1I8nOb0fdiAzBLoFNd",
"title": "Event Sourcing over CRUD for Financial Transaction Audit Trails",
"depth": 2,
"created_at": 1789175215719
}
}
]
}