An AI finance assistant without a server database

Most teams assume adding an AI assistant to a personal-finance app requires moving user ledgers to a server database, executing tools in the cloud, and maintaining a dedicated backend for auth, streaming, quotas, and billing.

For a local-first iPhone app, that assumption breaks on contact. The moment you copy a couple’s expenses, incomes, and savings pots to a server just so a language model can answer questions about them, you throw away the privacy guarantee people chose the app for. Worse, you still burn weeks building device auth, spend caps, streaming parsers, and eval harnesses before the assistant answers a single real question.

In Justa 1.2, I shipped Justina, an in-app household finance assistant, by splitting the problem the other way around: every tool runs on the iPhone against the local SwiftData store, and the entire server side is a tenant document pushed to my open-source ai-platform.

Keep the ledger and the math on the iPhone

Justina never reads a server database because Justa does not have one. The household ledger lives in SwiftData on the iPhone (optionally synced peer-to-peer through a shared Files folder). When a user asks Justina a question, the app sends the message, the household’s currency, locale, and member first names, and the tool definitions to the runtime. When the model wants data, it emits a tool call—and the iPhone executes it locally, then sends only that tool result back for the next turn.

The client exposes seven tools under contract v3 (contracts/ask-justa/v3/tools.json), all routed through CompanionTools over the same IntentLedger and calculators that power Home, widgets, and Siri:

ToolKindWhat it does on the iPhone
householdReadReturns people, monthly plan, savings pots, goals, and currency
findReadSearches expenses, monthly costs, contracts, To confirm drafts, and saved scenarios
summarizeReadAggregates totals by category, person, or period using the app’s own Decimal math
month_reportReadReads a full month’s plan, extras, settlement balance, and sobra
projectReadRuns multi-change look-ahead projections through ScenarioProjection.report (never saves a scenario)
openActionRenders an in-app button to jump straight to a screen (e.g. Settle, Month, Contracts)
proposeWriteBuilds one confirmation card for up to 10 changes—applied only after the user taps Save

Keeping the tools on the device solved three hard problems at once:

What Justina supports in the app

Inside Justa, Justina is designed to feel like part of the app rather than a webview bolted onto a tab:

Why it lives on ai-platform

A month ago, in Evaluating the Justa agent, Justa had its own bespoke Cloudflare Worker (justa-ask) serving /ask for the website and /chat for early TestFlight builds. When I built a second AI product—the exam tutor for Ensino—I realized I was about to duplicate gateway auth, spend pools, streaming, circuit breakers, and eval passes for the second time.

Instead, I extracted the shared infrastructure into aacnsilva/ai-platform: a multi-tenant TypeScript runtime on Cloudflare Workers backed by Durable Objects. The platform holds the mechanisms; zero product logic lives in it. Every product is a JSON tenant document pushed through an admin API.

Moving Justina onto ai-platform (as the justa-companion tenant, alongside justa-ask for the website) changed how fast I could iterate and scale:

Auth and metering without user accounts

Justa has no accounts, no emails, and no login screen. Running a paid AI tier without accounts meant solving two problems at the gateway: proving the request came from a real copy of Justa, and proving the user holds an active Justa Max subscription.

ai-platform’s app_attest authenticator handles both:

  1. On first use, CompanionDeviceCredentials generates an Apple App Attest key on the iPhone and attests it against the tenant’s challenge endpoint.
  2. Every chat request signs SHA-256(rawBody + "\n" + jws) with that hardware-backed key (X-Justa-Assertion) and attaches the StoreKit 2 signed transaction JWS (X-Store-Transaction).
  3. The runtime verifies the App Attest assertion, checks the Apple certificate chain on the JWS, and meters usage per subscriber—300 messages per UTC month—inside a Durable Object, backed by a tenant-wide monthly EUR pool with reserve-and-settle accounting.

The economics that keep it sustainable

AI features in indie apps die quietly when a handful of power users burn through the subscription margin. Before setting Justa Max’s price (€5.99/month or €49.99/year, which also includes everything in Justa Pro), I modeled the worst-case ceiling against ai-platform’s limits:

Evaluating the whole loop

Because Justina chains live tools, prompt-only evals are not enough. Justa ships a 53-case companion eval suite (scripts/run-companion-evals.sh) that runs against the real dev tenant on ai-platform with a seeded household, executing the real Swift CompanionTools on every round. That caught real issues before release: multi-round language drift, overly eager write proposals, and edge cases around financial-guidance boundaries.

Putting the ledger on the iPhone and the shared gateway in ai-platform meant I could ship a full tool-using, photo-reading, chart-drawing assistant as a solo developer—without compromising local-first privacy and without rebuilding AI infrastructure for every app I build next.