Local API and storage sync

Fire Tools exposes one REST API (/api/v1, described in OpenAPI) for the app itself and any other client: scripts, other apps, custom frontends and AI agents. Whatever a client writes through it is what the app shows: the database is the source of truth whenever a backend is reachable.

Storage model

Mode Source of truth Renderer storage
Desktop (embedded backend) SQLite in the profile directory Encrypted cache plus outbox
Web or desktop with a custom backend URL That backend's database Encrypted cache plus outbox
Web without a backend Encrypted browser storage Authoritative, as before
Public demo Bundled sample data Read-only

Five domains are synchronized: preferences (settings), FIRE calculator (calculator), Asset Allocation (assetAllocation), Cashflow (expenseTracker) and Net Worth (netWorth). Scenarios, debt payoff plans, the audit log, notifications, questionnaire results and navigation state stay in the renderer. Device settings never leave the device: backend address and token, updater, logging and AI model settings (including API keys).

How a change travels

  1. A page saves through the existing saveXxx() helper. The helper writes the encrypted cache, diffs the new document against the last known one and appends an entity-level changeset to a persisted outbox.
  2. The sync engine (src/utils/backendSync/) sends queued changesets with PATCH /state/{domain}, retrying with backoff while offline. A rejected change (4xx) is listed in Settings with the server's reason and the domain is reloaded from the database.
  3. Every write to a domain table, from any route, bumps that domain's revision through SQLite triggers. The app polls GET /sync/status every three seconds while visible and on focus, reloads changed domains with GET /state/{domain} and refreshes the current page. The refresh waits while a dialog is open or a form field has focus.

First start after upgrading

For each domain the app compares its cache with the database:

Authentication

API access for other clients (desktop)

Settings > API access is off by default. When on, the main process:

{ "schemaVersion": 1, "app": "Fire Tools", "appVersion": "x.y.z",
  "apiBaseUrl": "http://127.0.0.1:47820/api/v1", "token": "<client secret>",
  "stablePort": true, "pid": 12345, "startedAt": "...", "guideUrl": "...", "openapiUrl": "..." }

Copy token writes the token to the clipboard from the main process, so it never enters the renderer. While access is on, any process running as the same OS user that has the token can use the API, including when the database is passphrase-encrypted; the settings copy says so. Code: electron/apiAccess.cjs, EmbeddedServer.openPublicListener(), IPC fire-tools:api-access-*.

Endpoints for clients

Purpose Route
Connection and change detection GET /sync/status
Whole domain as the app sees it GET /state/{domain}
Batch changes in one transaction PATCH /state/{domain}
Replace a domain (destructive) PUT /state/{domain}
Single records the existing domain routes, e.g. POST /expense-tracker/expenses

Changesets have set (singletons), upsert (collections of records keyed by id) and delete (keys). Records use the app's own shapes plus year/month for month-scoped records and position for list order. The full table of collections and a worked onboarding example are in the API reference for agents.

Routes for questionnaire results, notifications, Monte Carlo runs and portfolio metadata are stored in the database but not displayed by the app yet; their OpenAPI descriptions say so.

Agent skill

.github/skills/using-fire-tools is an Agent Skills package for people who want an agent to operate their Fire Tools data. The site publishes it at /agents/using-fire-tools/ and lists it in /llms.txt. Its helper script reads the connection file, adds the token and refuses absolute URLs so the token never leaves the machine. Install steps for users: Use the Fire Tools API.

Try it with curl

file="$HOME/Library/Application Support/Fire Tools/local-api.json"
base=$(node -p "require(process.argv[1]).apiBaseUrl" "$file")
auth="Authorization: Bearer $(node -p "require(process.argv[1]).token" "$file")"
curl -s -H "$auth" "$base/sync/status"
curl -s -H "$auth" "$base/state/netWorth"

Test against a copy of your profile, not your real data: Test a branch with a copy of your data.