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.
- A written contract. One document defines every endpoint, the error envelope, units (percentages are
12.5, not0.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. - 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.
- Backend shape checks. Pytest helpers assert that every field the Dart parser reads is present and has the type the parser casts to.
- 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.
- 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.