Diagram — ERD
Logical data model:
app.*schema (system of record) andledger.*schema (double-entry). The two schemas share UUID identifiers betweenapp.account.idandledger.account.id—ledger.accountis a thin mirror keyed by the same UUID.
Diagram
Section titled “Diagram”LEDGER_ACCOUNTis not a separate concept fromACCOUNT— same UUID, two schemas. The ledger schema can run independently of the app schema (this is the boundary that lets TigerBeetle replaceledger.*later — see ADR-0001).LEDGER_ENTRYis append-only. Voiding never deletes entries; it inserts new ones (compensating). See ADR-0016.LEDGER_ACCOUNT_BALANCE.balance_minoris a cache; the source of truth isSUM(direction='C') - SUM(direction='D')overLEDGER_ENTRYper account. Reconciled bytrg_transfer_balancedat write time and by a nightly job (Plan 7).
Related artifacts
Section titled “Related artifacts”- SRS section: SRS — Telegram Finance Bot §🗄 Data Model
- ADRs: ADR-0002 (PostgreSQL system of record), ADR-0008 (DB-level invariants), ADR-0014 (ledger schema design), ADR-0016 (void via compensating entries), ADR-0018 (domain ↔ ORM boundary)
- Migrations:
migrations/versions/0001_initial_app_user_and_processed_update.py,0002_ledger_schema.py,0003_app_account_category_budget.py,0004_seed_default_categories.py