{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-OvWksfwVYht1lFQE_mo",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "Decision: Migrate from standard CRUD (PostgreSQL) to Event Sourcing with Kafka as the immutable event log, plus a materialized view in Postgres for fast reads. Why: In the current CRUD model, updates overwrite previous states. When compliance requested the history of transaction #8821 (who changed status from pending to approved), the team could not provide the audit trail. Event Sourcing stores a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) so full history with business context is always available. Alternatives considered: 1) Database triggers writing to a history_logs table on every UPDATE - REJECTED because triggers only see row-level changes (e.g., status changed from 1 to 2) and lose business context/user intent behind the change. Files involved: src/services/transactionService.ts (event producers), src/events/eventStore.ts (consumer/store logic). Reference: Martin Fowler's Event Sourcing Pattern article.",
"summary": "Team decided to adopt Event Sourcing with Kafka and a Postgres materialized view instead of CRUD with database triggers, to satisfy compliance audit requirements by preserving immutable domain events with full business context.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql,immutability",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1781904149244,
"updated_at": 1781904149244
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 11
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-OvWksfwVYht1lFQE_mo",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-OvWksfwVYht1lFQE_mo",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1781904149244
}
}
]
}