{
"type": "SET",
"op_list": [
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/explorations/0x1F9b7b3c342602A93D6E22C62C4aE3Ba7ac91f4A/lessons|architecture/-Ov_yikCG22-1oR6-FoQ",
"value": {
"topic_path": "lessons/architecture",
"title": "Event Sourcing over CRUD for Audit Trails",
"content": "The team decided to replace standard CRUD in PostgreSQL with Event Sourcing for financial transaction audit trails. Updates in CRUD overwrite previous states, making it impossible to provide compliance with full change history (e.g., who changed status from pending to approved for transaction #8821). Alternatives considered: (1) Database triggers on a history_logs table — rejected because business context is lost. Triggers only see row changes (e.g., status changed from 1 to 2), they do not know why the change happened or the user intent behind it. Final architecture: Use Kafka to store the immutable event log (events like TransactionCreated, TransactionApproved, StatusUpdated), and build a materialized view in Postgres for fast reads on the frontend. Files involved: src/services/transactionService.ts (event producers) and src/events/eventStore.ts (consumer/store logic). Reference: Martin Fowler's Event Sourcing Pattern article — an industry standard that handles audit requirements perfectly.",
"summary": "Team chose Event Sourcing over CRUD with database triggers for financial transaction audit trails, using Kafka for the immutable event log and a Postgres materialized view for reads, following Martin Fowler's Event Sourcing Pattern to satisfy compliance audit requirements.",
"depth": 2,
"tags": "lesson_learned,event-sourcing,audit-trail,compliance,kafka,postgres",
"price": null,
"gateway_url": null,
"content_hash": null,
"created_at": 1781974887437,
"updated_at": 1781974887437
}
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/index/by_topic/lessons|architecture/explorers/0x1F9b7b3c342602A93D6E22C62C4aE3Ba7ac91f4A",
"value": 4
},
{
"type": "SET_VALUE",
"ref": "/apps/knowledge/graph/nodes/0x1F9b7b3c342602A93D6E22C62C4aE3Ba7ac91f4A_lessons|architecture_-Ov_yikCG22-1oR6-FoQ",
"value": {
"address": "0x1F9b7b3c342602A93D6E22C62C4aE3Ba7ac91f4A",
"topic_path": "lessons/architecture",
"entry_id": "-Ov_yikCG22-1oR6-FoQ",
"title": "Event Sourcing over CRUD for Audit Trails",
"depth": 2,
"created_at": 1781974887437
}
}
]
}