{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1/lessons|architecture/-P-ycr_q2-fBdN-CaTcI",
"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 Event Sourcing using Kafka as the immutable event log, with materialized views in Postgres for fast reads. This decision was driven by compliance requirements: CRUD overwrites previous states, making it impossible to reconstruct the history of changes (e.g., who changed transaction #8821 from pending to approved). Database triggers with a history_logs table were considered but rejected because triggers only capture row-level changes without business context or user intent. Event Sourcing preserves the full sequence of domain events (TransactionCreated, TransactionApproved, StatusUpdated) with complete business context. Implementation: event producers in src/services/transactionService.ts and consumer/store logic in src/events/eventStore.ts. Reference: Martin Fowler's Event Sourcing Pattern article.",
"summary": "Replacing PostgreSQL CRUD with Kafka-based Event Sourcing and Postgres materialized views to maintain immutable audit trails with full business context for compliance.",
"depth": 2,
"tags": "lesson_learned,event-sourcing, audit-trail, compliance, kafka, postgresql",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1787757295990,
"updated_at": 1787757295990
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"value": 289
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x0064be11Eeb5ecf0bff5076F642A44bA006994b1_lessons|architecture_-P-ycr_q2-fBdN-CaTcI",
"value": {
"address": "0x0064be11Eeb5ecf0bff5076F642A44bA006994b1",
"topic_path": "lessons/architecture",
"entry_id": "-P-ycr_q2-fBdN-CaTcI",
"title": "Event Sourcing over CRUD for Audit Trail Compliance",
"depth": 2,
"created_at": 1787757295990
}
}
]
}