Skip to content

Data loading

EstimateIQ’s Durable Object starts empty. There is no auto-seed and nothing is baked into the Worker image — the DO creates its tables on first run and waits to be loaded. Data goes in explicitly, through the API, from an external dataset. This keeps the deployed artifact free of demo data and lets you load the same dataset (or real data) into any environment.

The admin endpoints

All are guarded by Authorization: Bearer <REVSRC_SECRET_KEY> and handled at the Worker edge before the Access gate, so automation reaches them without a browser session.

MethodPathEffect
POST/api/admin/clearEmpties every table (FK-safe order).
POST/api/admin/loadClears, then bulk-inserts the posted dataset in FK order. Returns per-table counts.
POST/api/admin/seedRebuilds the built-in demo generator (dev convenience only).
POST/api/admin/reindexRe-embeds every estimate into Vectorize for semantic search.

clear and load each write an entry to the audit log (admin.clear, admin.load).

The dataset

The data lives outside the app in infra/data/dataset.json — a map of table name → rows (carriers, estimators, estimates, revisions, line items, follow-ups, events, emails, config…), inserted in dependency order by /api/admin/load. Replace this file with real data, or regenerate it from the demo generator:

Terminal window
bun run export-dataset # rewrites infra/data/dataset.json

Loading with Ansible

The load is automated by the Ansible playbook infra/ansible/load.yml, which clears the DO, POSTs the dataset to /api/admin/load, prints the loaded counts, and verifies estimates came back live:

Terminal window
export REVSRC_ADMIN_TOKEN=<worker REVSRC_SECRET_KEY>
bun run load # → esb.guru
ansible-playbook infra/ansible/load.yml -e api_base=http://localhost:3000

bun run load is the shortcut for ansible-playbook infra/ansible/load.yml. Point api_base at any environment to load the same data anywhere — prod, staging, or local dev.

Reindex search after a load

Semantic search reads a Vectorize index that is not touched by load. After a bulk load (or a large batch of updates), rebuild it:

Terminal window
curl -X POST https://esb.guru/api/admin/reindex \
-H "Authorization: Bearer $REVSRC_ADMIN_TOKEN"

This embeds the full content of every estimate and upserts the vectors, returning { indexed: N }. See Search.