{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P-5aHmbeCa1pVxpbsZo",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trail Compliance",
"content": "The team decided to replace standard CRUD operations in PostgreSQL with an Event Sourcing pattern using Kafka for the financial transactions audit trail. CRUD overwrites previous states, making it impossible to provide compliance with full change history. Database triggers with a history_logs table were considered but rejected because they only capture row-level changes (e.g., status from 1 to 2) without capturing business context (why the change happened, user intent). Event Sourcing stores immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka, with a materialized view in Postgres for fast frontend reads. This satisfies compliance requirements for full audit history. Implementation: event producers in src/services/transactionService.ts, consumer/store logic in src/events/eventStore.ts. Reference: Martin Fowler's Event Sourcing Pattern article.",
"summary": "Migrated from CRUD to Event Sourcing with Kafka to maintain full immutable audit trails for financial transactions, satisfying compliance requirements while preserving business context that database triggers lose.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1786817096871,
"updated_at": 1786817096871
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 196
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P-5aHmbeCa1pVxpbsZo",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P-5aHmbeCa1pVxpbsZo",
"title": "Event Sourcing over CRUD for Audit Trail Compliance",
"depth": 2,
"created_at": 1786817096871
}
}
]
}