How tofi-app/tofi works
ToFi is a personal budgeting app: users sign in, link financial accounts, review and categorize transactions, set budgets, and follow household cash flow, reimbursements, net worth, and investments. Mobile screens and hooks drive authenticated tRPC requests; the backend handles Plaid access and user-defined metadata, while raw Plaid financial data is relayed to the device rather than persisted server-side. Apple FinanceKit provides a separate on-device account-sync path. Evidence is limited to the README, tree, and sampled excerpts; unsampled subsystem links are included only where documented capabilities support them.
Main entry points: index.tsx Finance screens · router.ts tRPC procedures · repositories Domain repositories · syncEngine.ts Apple account sync
Components 26
Mobile experience
- App routing
frontend/app/_layout.tsx - Sign-in
frontend/app/(auth)/login.tsx - Onboarding
frontend/app/onboarding/index.tsx - Finance screens
frontend/app/(tabs)/index.tsx - Authenticated API client
frontend/lib/api/client.ts
Account ingestion
- Plaid Link flow
frontend/hooks/useLinkSession.ts - Plaid Link session
frontend/lib/plaid/createLinkSession.ts - Apple account sync
frontend/lib/financekit/syncEngine.ts
Financial insights
- Transaction feed
frontend/hooks/useTransactionFeed.ts - Budget tracking
frontend/hooks/useBudgets.ts - Cash flow
frontend/lib/cashflow/householdFlow.ts - Net worth
frontend/lib/accounts/netWorth.ts - Investment views
frontend/components/accounts/HoldingRows.tsx
Backend API
- Fastify server
backend/src/server.ts - tRPC procedures
backend/src/trpc/router.ts - Plaid link service
backend/src/services/plaidLinkService.ts - Transaction routes
backend/src/routers/transactions.ts - Budget routes
backend/src/routers/budgets.ts - Investment routes
backend/src/routers/investments.ts - Domain repositories
backend/src/repositories
Storage and providers
- Metadata database
backend/src/lib/db/client.ts - Plaid API
- Supabase Auth
frontend/lib/supabase/auth.ts - Apple FinanceKit
- On-device cache
frontend/lib/financekit/store.ts
Other components
- App user
Connections 34
- App user → App routing: opens
- App routing → Sign-in: routes unauthenticated
- App routing → Onboarding: routes signed-in
- Sign-in → Supabase Auth: authenticates
- Onboarding → Plaid Link flow: starts linking
- Finance screens → Plaid Link flow: requests connection
- Plaid Link flow → Authenticated API client: requests link token
- Plaid Link flow → Plaid Link session: opens Link
- Plaid Link session → Plaid API: links account
- Authenticated API client → Fastify server: sends authenticated tRPC
- Fastify server → tRPC procedures: dispatches procedures
- tRPC procedures → Plaid link service: dispatches link calls
- tRPC procedures → Transaction routes: dispatches transaction calls
- tRPC procedures → Budget routes: dispatches budget calls
- tRPC procedures → Investment routes: dispatches investment calls
- Plaid link service → Plaid API: creates and exchanges tokens
- Plaid link service → Domain repositories: stores connection metadata
- Transaction routes → Plaid API: fetches financial data
- Transaction routes → Domain repositories: reads and writes metadata
- Budget routes → Domain repositories: reads and writes budgets
- Investment routes → Plaid API: fetches holdings and activity
- Investment routes → Domain repositories: reads connection metadata
- Domain repositories → Metadata database: persists user metadata
- Transaction routes → Transaction feed: returns transaction data
- Budget routes → Budget tracking: returns budget data
- Investment routes → Investment views: returns investment data
- Transaction feed → Finance screens: renders transactions
- Budget tracking → Finance screens: renders budgets
- Finance screens → Cash flow: builds household view
- Finance screens → Net worth: builds net worth view
- App user → Apple account sync: grants account access
- Apple account sync → Apple FinanceKit: reads accounts and activity
- Apple account sync → On-device cache: merges synced transactions
- Apple account sync → Finance screens: provides account data