Database Data Model
Relational entity layouts, constraints, indexes, and credentials encryption mappings.
Arbiter uses Drizzle ORM to interface with a relational PostgreSQL database. The schema is optimized for write speeds on log messages and guarantees credentials isolation using unique indexes and cascade deletion rules.
Entity Relation (ER) Diagram
Key Schemas Details
1. Encryption of API Keys
API keys stored in api_credentials are never plaintext. They are encrypted using aes-256-gcm in lib/crypto/aesGcm.ts, producing an encrypted_key, iv (initialization vector), and an auth_tag. These fields are all stored alongside the record to ensure integrity. A unique constraint is declared on the composite key (userId, provider) to prevent duplication.
2. Granular Telemetry Tracking
Notice that message_model_runs is separate from messages. When a fanned message query runs, it creates one client message, but multiple runs (one per selected worker, plus one for the evaluator). This table isolates performance telemetry, logging ttft_ms (time-to-first-token), latency_ms, and cost_usd for each model execution.