{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x767692F9a88e7157d95fE4F183B16980D1eE97b9/lessons|architecture/-P1BQWA9P6ejH5WRVv_q",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "Decision: Replace standard CRUD operations in PostgreSQL with Event Sourcing for financial transaction audit trails.\n\nContext: Compliance requested full history of transaction #8821, but current CRUD implementation overwrites previous states with no audit trail. Database triggers were considered but rejected because they only capture row-level changes (status 1 to 2) and lose business context — who initiated the change and the user intent behind it.\n\nSolution: Store a sequence of immutable domain events (TransactionCreated, TransactionApproved, StatusUpdated) in Kafka. Build a materialized view in PostgreSQL for fast frontend reads. This satisfies compliance by preserving full history with business context.\n\nReference: Martin Fowler's 'Event Sourcing Pattern' article.\n\nFiles:\n- src/services/transactionService.ts (event producers)\n- src/events/eventStore.ts (consumer/store logic)",
"summary": "Team adopted Event Sourcing over CRUD to capture full audit trail with business context for compliance, using Kafka for immutable events and Postgres materialized view for reads.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgresql,martin-fowler",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1789062419146,
"updated_at": 1789062419146
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x767692F9a88e7157d95fE4F183B16980D1eE97b9",
"value": 7
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x767692F9a88e7157d95fE4F183B16980D1eE97b9_lessons|architecture_-P1BQWA9P6ejH5WRVv_q",
"value": {
"address": "0x767692F9a88e7157d95fE4F183B16980D1eE97b9",
"topic_path": "lessons/architecture",
"entry_id": "-P1BQWA9P6ejH5WRVv_q",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1789062419146
}
}
]
}