
002 Case study
All workFinance Platform
Ships as MyWay (codebase MoneyFlow)
- Category
- Fintech / Full Stack / Product Engineering
- Year
- 2026
- Role
- Solo · product and engineering
- Status
- Live · PWA
Authorship & scope
- In production
- Live as an installable web app, and not sold yet: a subscription plan is documented, but no plan or billing code exists. Connecting a bank and the Claude chat are limited to allowlisted accounts. My own account has synced through Meu Pluggy since 26 October 2026, and the landing page lists the assistant as coming soon.
Overview
MyWay (codebase: MoneyFlow) is a personal finance app for planning the month ahead: it tracks expenses, goals and bills and lets the user test scenarios before money moves. It targets Brazilians paid as salaried employees (CLT), as micro-entrepreneurs (MEI) or both, and pairs a manual ledger (bank sync through Open Finance is limited to allowlisted accounts) with savings pots, a three-scenario forecast, a loan simulator and a task planner. It is one TypeScript codebase on Expo and Supabase, shipped as an installable web app.
Spec · from the code and docs, not live metrics
- isolation
- RLS on all 20 tables
- bank sync
- pg_cron every 2 h, 90-day window
- dedupe key
- bank providerId + installment
- scenarios
- 3, by income certainty
Problem
The product brief frames MyWay as a month planner rather than an expense tracker: the question is how much will be left on the 30th once salary after INSS and income tax, bills, the card bill and expected client payments are counted. For someone who is both an employee and a micro-entrepreneur, the same money can be counted twice: once as business revenue and again when it moves to the personal account. Bank feeds add noise: Pluggy's transaction ids change when a card bill closes, bill payments and third-party Pix arrive with the wrong category, and a refunded Pix looks like income.
Architecture
The UI, Zustand stores and pure TypeScript domain modules live in one Expo Router codebase (React Native with react-native-web). Its static web export runs on Vercel as an installable PWA. Supabase provides Auth, Postgres with row-level security on every table, and Deno Edge Functions for bank sync, Web Push and a Claude chat. pg_cron calls the sync and push functions through pg_net, authenticating with a secret kept in Supabase Vault.
System map · Finance Platform
Scroll sideways for the whole system →
- sync
- async · queue · cron
- external
- built by me
01 · Client · clock
Three jobs defined in SQL: bank sync every 2 hours and push rules every 5 minutes, both called through pg_net with a bearer secret read from Vault, and a daily cleanup of notification_log rows older than 60 days.
Expo Router and React Native with react-native-web, exported as a static installable PWA on Vercel. Zustand stores write optimistically, cache in AsyncStorage and reload data older than a minute when the app regains focus.
Pure TypeScript for balance, month summary, scenarios, amortization, CLT payroll, the MEI cap and reconciliation. Screens, alerts and the chat context call the same functions, and 28 node:assert scripts test them.
02 · Edge Functions
Pushes due bills, task reminders, a daily digest and incoming money. Each notice key is claimed in notification_log before VAPID Web Push sends it, and released after a transient failure.
Reads Pluggy accounts, transactions, card bills and investments, classifies every movement in a pure mapper and writes through security-definer RPCs that only the service role may execute.
Calls Claude with a cached system prompt, a JSON finance summary and two tools that only propose changes. Access requires a row in chat_users; without an account, a local keyword engine answers instead.
03 · Postgres
Supabase Postgres from a base schema plus 19 idempotent migrations. Owner policies check auth.uid(); three service-role-only tables have no policies at all. apply_bank_sync writes an account, its transactions and its card bills in one SQL transaction.
04 · Providers
Browser push through VAPID; the app's service worker only handles push.
Accounts, transactions, card bills and investments. Bank sync is limited to allowlisted accounts: a new bank connection requires open_finance_allowed().
Its two tools only return proposals: the app shows a confirmation card, applies accepted changes through the same store actions as the UI and refuses bulk edits above 200 rows.
built by me · tap a node to see its role
Connections in Finance Platform architecture:
- pg_cron to notify: asynchronous, every 5 min.
- pg_cron to sync-pluggy: asynchronous, every 2 h.
- MyWay PWA to sync-pluggy: synchronous, Sync · JWT.
- MyWay PWA to Postgres: synchronous, RLS.
- MyWay PWA to chat: synchronous.
- MyWay PWA to Domain modules: synchronous.
- notify to Postgres: synchronous.
- notify to Web Push: external integration.
- sync-pluggy to Postgres: synchronous.
- sync-pluggy to Pluggy: external integration, reads.
- chat to Claude API: external integration.
Layers
Client
Expo (the expo 54 package) with Expo Router 4, React Native 0.77 and react-native-web. Zustand stores write optimistically (the finance store with local ids), cache state in AsyncStorage and reload data older than a minute when the app regains focus. Failed loads retry after 5, 15 and 45 seconds.
Domain logic
Pure TypeScript modules cover balance, month summary, scenarios, amortization, CLT payroll, the MEI cap and reconciliation. Screens, alerts and the chat context call the same functions, and 28 node:assert self-check scripts test them.
Database
Supabase Postgres with 20 tables, all with RLS enabled. Owner policies check auth.uid(); three service-role-only tables have no policies at all. The jsonb settings columns on profiles carry shape CHECK constraints, and the schema is a base file plus 19 idempotent migrations.
Bank ingestion
The sync-pluggy Edge Function reads Pluggy accounts, transactions, card bills and investments and classifies them in a pure mapper. It writes through security-definer RPCs (apply_bank_sync, apply_investments_sync) that only the service role may execute.
Jobs and push
pg_cron calls the sync-pluggy and notify Edge Functions through pg_net with a bearer secret read from Vault (every 2 hours and every 5 minutes); a third job deletes notification_log rows older than 60 days each day. Each notice key is claimed in notification_log before VAPID Web Push sends it, and released after a transient failure.
Assistant
The chat Edge Function calls Claude with a cached system prompt, a JSON finance summary and two tools that only propose changes. Access requires a row in chat_users. Without an account, a local keyword engine answers instead.
Data flow · step by step
pg_cron (every 2 hours) or the Sync button on the app's bank screen calls the sync-pluggy Edge Function, authenticated by the Vault secret or the user's JWT.
The function reads accounts, transactions (12 months on the first run, then at least 90 days), card bills and investments from Pluggy.
A pure mapper classifies each movement: transfers between the user's own tax IDs, MEI income, paired Pix refunds, merchant keys and installments.
apply_bank_sync upserts on the providerId-based key in one SQL transaction, applies learned merchant rules without overriding locked categories, deletes in-window rows the bank no longer returns and recomputes the balance once.
The client loads its rows under RLS, and pure functions derive the balance, month summary, due items and 'Chegou?' matches.
The Futuro tab projects month-end balances in three scenarios, and the notify function pushes due bills, task reminders, a daily digest and incoming money.
Technical decisions
01
Bank writes through guarded RPCs
apply_bank_sync writes one account, its transactions and its card bills in a single SQL transaction; investments go through apply_investments_sync. EXECUTE on both is revoked from public, anon and authenticated and granted only to service_role. A transaction-local flag makes the per-row balance trigger skip during the batch, and the balance is recomputed once at the end.
02
Key on the bank's id, never delete on empty reads
Pluggy's transaction id changes when a card bill closes, so the unique key is the bank's providerId (Pluggy's id only as a fallback) plus the installment number. In-window rows the bank no longer returns are deleted, but only when the read is non-empty: an empty read from expired consent deletes nothing.
03
Store configuration, compute the rest
profiles keeps salary, MEI, fixed expenses, yearly goals, the simulation and onboarding answers as jsonb columns with shape CHECK constraints. Payslips, MEI revenue, projections and due items are computed from them, and the app and the push rules import the same due-date module, so screens, the chat summary and notifications use the same calculations.
04
Integer cents in projections
The scenario simulator and the SAC/Price tables add up in integer cents. The last installment absorbs the rounding residue so the debt ends at exactly zero, and annual rates are converted by compound equivalence, not by dividing by 12.
05
The model proposes, the user confirms
Claude's two tools only return proposals. The app shows a confirmation card and applies accepted changes through the same store actions as the UI. It refuses bulk edits above 200 rows and asks for a narrower filter.
Challenges
Challenge 01
One person, two tax IDs
The sync stores each account holder's tax ID. Money between the user's own IDs becomes a transfer; the one exception is an incoming payment from their own CNPJ into a CPF account, which counts as personal 'mei' income. With a business (PJ) bank connection, which only allowlisted accounts can create, lib/scope.ts builds personal, MEI and combined views and turns the owner's withdrawal on the PJ side into a transfer, so it is not counted twice.
Challenge 02
Bank data that rewrites itself
Besides the stable key, the sync window widens to cover gaps of up to 12 months, and a refunded Pix is paired with its original (same direction, amount and counterparty name) so both become transfers. Accounts that vanish after a consent renewal hand their history and bills to the single remaining account of the same type in that connection.
Challenge 03
Matching plans to the statement
'Chegou?' pairs planned entries with bank movements within date windows that differ for income and expenses, allowing 1% on the amount. It ranks name matches first and pairs one-to-one, auto-confirming only exact, name-matching pairs with no rival. Confirmations can be undone.
Challenge 04
Gating Open Finance per account
The sync uses project-level aggregator credentials, so letting any account insert a bank connection would let a new account pull bank data that is not its own. Inserts now require open_finance_allowed(), a security-definer check against an allowlist, and a column-level grant lets clients update only the scope column.
Implementation
Available balance: with a personal bank account linked, it is the balance of personal bank accounts (PJ excluded) plus synced savings boxes. Otherwise it is the manual ledger, optionally anchored on the balance entered during onboarding, minus savings pots, goal contributions and paid bills.
Goals and savings: goals have a target, a deadline and an active, paused or completed status. Scheduled deposits to savings pots leave the balance without counting as spending, and yearly goals compute the monthly amount needed by the deadline.
Futuro tab: conservative, realistic and optimistic projections, depending on how certain each income is (certain, probable, maybe), starting from real months. A goal check shows the month the goal is reached, the shortfall and the extra needed per month. Saved per account.
Financing simulator: SAC and Price tables with MIP and DFI insurance, admin fees, prepayments that shorten the term or lower the installment, financed IOF under Decree 6.306/2007, and CET solved by bisection.
Brazilian income rules: an estimated CLT payslip from the 2026 INSS and IRRF tables, with 13th salary and a business-day pay calendar. MEI revenue is tracked against the yearly cap, prorated by opening month, with the DAS due on the 20th or the next business day.
Expense analysis in pure functions: monthly subscription detection (median gap of 25–35 days, amount within ±35%), installment grouping, duplicate-charge alerts, per-category limits that warn at 80%, and merchant rules learned when the user recategorizes a bank transaction.
Technologies
- TypeScript
- React
- React Native
- Expo
- Expo Router
- react-native-web
- Zustand
- Supabase
- PostgreSQL
- PL/pgSQL
- Row-Level Security
- Deno Edge Functions
- pg_cron
- pg_net
- Supabase Vault
- Pluggy Open Finance API
- Web Push (VAPID)
- Claude API
- date-fns
- dnd-kit
- Vercel
- PWA
Results
Live at moneyflow-pedro.vercel.app, with the landing page at /lp/ (checked 24 November 2026).
A Postgres schema of 20 tables, all with row-level security enabled, built from a base schema plus 19 versioned, idempotent SQL migrations.
4 Edge Functions in the repo (chat, notify, sync-pluggy and the disabled sync-pierre) and 3 pg_cron jobs defined in SQL: bank sync every 2 hours, push rules every 5 minutes, daily log cleanup.
28 node:assert self-check scripts covering balance, scenarios, amortization, CLT, MEI, reconciliation, push rules and bank mapping.
An installable PWA with a standalone web manifest, a maskable icon and a service worker that only handles push.

003 Next caseLegal Intelligence
Legaltech / AI / Automation
Case 002 of 004