Skip to content

Data Model

eugnmueller-87 edited this page Jun 24, 2026 · 1 revision

Data Model (v2.0)

Canonical source: the ordered migration chain in db/migrations/, run via dbmate. db/schema.sql is a generated snapshot — never hand-edited (see Design-Decisions ADR-007).


32 tables across 10 domains

Domain Tables
Organization branches · cost_centers · users
Suppliers suppliers · legal_documents · compliance_checks
Contracts contracts · contract_changes · contract_clauses
Budget budget_buckets · budget_positions · budget_pools · budget_reallocations
P2I purchase_orders · po_sequences · invoices · payment_instructions · erp_sync_queue
Assets assets · asset_depreciation_log
Licenses license_entitlements · license_assignments
Consumption hyperscaler_positions · llm_api_keys · llm_consumption
Operations tickets · decisions · trace_log · supplier_emails
Intelligence vendor_pricing_benchmarks · trust_settings

Production views

open_tickets_board · purchase_orders_board · catalog_by_supplier · contracts_expiring · po_analytics · invoice_analytics · spend_trend · savings_tracking · supplier_performance · approval_velocity


Budget model

CFO sets annual plan (budget_buckets)
        ↓ Controlling approves → distributed to cost centers
Every PO approved  → budget_positions.committed += amount   (immediate)
Every invoice paid → committed released, spent incremented
        ↓
Pool reserve (budget_pools) — CFO lever, drawn by exception only
        ↓
Every move → budget_reallocations  (immutable audit trail)

Three-tier approval check on every request:

  1. Category bucketbranch × category × quarter headroom?
  2. Branch annual — running above 80% YTD?
  3. Manager authority — within users.spend_authority for this category?

Full column-level detail lives in docs/data-model.md in the repo.

Clone this wiki locally