Description
Persist all credit lifecycle domain events (opened, draw requested/confirmed, repay confirmed, defaulted, suspended) in an append-only domain_events table to support replay, reconciliation, and audits.
Requirements and context
- Must be secure, tested, and documented.
- Must include idempotency keys / unique constraints to prevent duplicates.
Suggested execution
git checkout -b feature/domain-events-store
Implement changes
- Add
domain_events table with type, payload json, aggregate id, created_at.
- Write events from service layer (transactionally if using outbox).
- Tests that assert events are recorded for key operations.
- Document replay strategy.
Test and commit
Example commit message
feat(db): append-only domain event store for credit lifecycle
Guidelines
Description
Persist all credit lifecycle domain events (opened, draw requested/confirmed, repay confirmed, defaulted, suspended) in an append-only
domain_eventstable to support replay, reconciliation, and audits.Requirements and context
Suggested execution
Implement changes
domain_eventstable with type, payload json, aggregate id, created_at.Test and commit
npm testExample commit message
Guidelines