Work

Side project · Nov 2026

Folio, a portfolio app with a contract between app and API

Folio tracks a stock portfolio and explains it in plain language: performance against a benchmark, risk, allocation, dividends and what-if experiments. The Flutter app is built in Clean Architecture with BLoC, and the analytics run on a FastAPI backend. The part I am most pleased with is not a screen; it is how the app and the API are kept honest with each other.

Role
Sole engineer
Status
In development, pre-launch
Platforms
iOS, Android, macOS, Web
Stack
Flutter, Dart, BLoC, go_router, get_it, FastAPI, PostgreSQL, Redis, Celery, RevenueCat, Sign in with Apple, Google Sign-In, local_auth
feature modules
18feature modules
recorded API responses in widget tests
206recorded API responses in widget tests
test files across app and backend
140test files across app and backend

The app

Eighteen feature modules: overview, holdings, analysis, risk, dividends, broker import, a what-if lab, subscriptions and more. Fifteen have their own domain, data and presentation layers. Routing is go_router; dependencies are registered in get_it; repositories return a sealed Result instead of throwing, so failure is part of every call’s type.

A few details that matter in a finance app:

  • Release builds refuse to start without an https:// API URL. A misconfigured build fails at launch on my machine, not in a user’s hands.
  • App lock with Face ID, Touch ID or device PIN, and secure storage for the session token.
  • Copy guardrails. The app explains; it does not advise. A shared list of banned phrases is checked by a test in Dart and another in Python, so neither the app nor the API can ship wording like an instruction to buy.

Keeping app and API honest

The backend started as a mock written in Dart and was then ported to FastAPI. Porting an API without breaking the app that reads it is a contract problem, so I built the contract first.

Folio contract testsA written contract sits between the Dart parsers and the FastAPI backend. Widget tests run the parsers against 206 recorded responses. A live contract test drives the app's own repositories against a running backend. Backend pytest checks assert every field the Dart parsers read. A diff script compares the JSON key and type trees of two backends.staging vs localDart parsersfeatures/*/data/modelswhat the screens readbackend_contract.mdshapes, error envelope,units, status codesFastAPI backendPostgres · Redis · Celerythe only implementationWidget testsfake backend serves206 recorded responsesLive contract testapp repositories vs arunning API, new accountpytest shape checksevery field the Dartparser reads, typedcontract_diff.pytwo backends, sametrades; exit = # diffsend to end through the app's own HTTP client and parserswritten spec both sides follow
Four checks, one contract. Each catches a different kind of drift between app and API.
  1. A written contract. One document defines every endpoint, the error envelope, units (percentages are 12.5, not 0.125) and status codes: 401 signs the user out, 404 for ids the caller does not own so ids cannot be probed, 422 when a metric cannot be computed yet.
  2. Widget tests on recorded responses. A fake backend serves 206 recorded JSON responses, so every screen is tested against real payload shapes without a network.
  3. Backend shape checks. Pytest helpers assert that every field the Dart parser reads is present and has the type the parser casts to.
  4. A live contract test. Opt-in with an environment variable, it drives the app’s own repositories (the same HTTP client, parsers and error mapping the screens use) against a running backend: register, create a portfolio, add trades, call every analytics endpoint, then delete the account.
  5. A diff tool between deployments. It creates the same account and trades on two running backends, say staging and local, and compares every response’s key and type tree. Its exit code is the number of differences, so zero means parity.