# arabindakabiraj/moneyflow architecture

> Architecture diagram of the GitHub repository arabindakabiraj/moneyflow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arabindakabiraj/moneyflow
- Repository: https://github.com/arabindakabiraj/moneyflow

## Overview

1. **What the repo is**
   - MoneyFlow V.2 is a **single-page React application** built with **Vite** and styled with **Tailwind CSS**.
   - Architecturally, it is a **client-heavy finance dashboard** backed by **Supabase** for auth, data, and policy enforcement, with a few external services for AI and OTP verification.

2. **Top-level runtime boundaries**
   - The browser app is the main runtime.
   - Supabase provides the durable backend: **Postgres, Auth, RLS, triggers, and realtime/data APIs**.
   - Additional external services are implied by the UI: an **LLM endpoint** for finance chat/smart parsing and a **separate OTP service** for sensitive verification flows.
   - The app also ships as a **PWA** and has **Capacitor** support for mobile packaging.

3. **App shell and navigation**
   - `src/main.jsx` mounts `App.jsx`, which acts as the layout/router shell.
   - The visible shell is composed of `Header`, `BottomNav`, `DesktopSidebar`, `SplashScreen`, `OnboardingModal`, and `ErrorBoundary`.
   - The UI is organized for **mobile-first finance workflows**, with alternate desktop navigation.

4. **Global state and shared concerns**
   - `context/AppContext.jsx` is the central state hub for finance data, UI state, and CRUD coordination.
   - `context/ThemeContext.jsx` manages the theme system, which is driven by CSS variables and HSL-based palettes.
   - Hooks such as `useNetwork`, `useNotifications`, and `useInstallPrompt` provide app-wide concerns: connectivity awareness, local notifications, and PWA install behavior.

5. **Data access layer**
   - `src/supabase.js` is the primary client boundary for all persisted data operations.
   - `authUtils.js` handles client-side auth-related hashing/derivation logic before interacting with Supabase-based auth flows.
   - The app appears to keep most domain logic on the frontend, while Supabase enforces persistence and access control.

6. **Core finance domains**
   - The app is centered around transaction and portfolio management components:
     - `Accounts`, `AddTransaction`, `Transactions`, `Ledger`
     - `Dashboard`, `Charts`, `BudgetVsActual`, `CashFlow`, `NetWorthTracker`
     - `SavingsGoals`, `DebtTracker`, `BillReminders`, `RecurringTransactions`
   - These screens all consume the same underlying user financial state but present it in different operational views.

7. **AI and automation pipeline**
   - `AIChat.jsx` is the conversational assistant surface.
   - `SmartAdd.jsx` is the transaction entry automation path: natural language or voice-like input is transformed into structured transaction data.
   - Utilities such as `autoCategory.js` and `spendingPredictor.js` support automated categorization and forecast-style insights.
   - The data flow is: user text/context → parser/LLM helper → normalized transaction/insight → state update → Supabase persistence.

8. **Import, cleanup, and statement generation**
   - `SMSImport.jsx` plus `utils/smsParser.js` handle pasted bank/SMS transaction ingestion.
   - `csvExport.js` and `pdfExport.js` generate downloadable reporting artifacts from transaction history.
   - This is a distinct reporting/export boundary: raw financial events are transformed into user-shareable documents rather than only being displayed in-app.

9. **Shared finance and collaboration features**
   - `FamilyMode.jsx` and `GroupExpenses.jsx` implement the multi-user/collaborative financial layer.
   - `DebtTracker`, `RecurringTransactions`, and the family-linking UI imply multiple shared bookkeeping models:
     - linked household finances
     - group expense settlement
     - individual debts and recurring obligations
   - These features depend on database rules that allow selective visibility across linked users.

10. **Security and access control**
   - Authentication and protected actions are surfaced through `AuthScreen`, `AppLock`, and `OtpGuardModal`.
   - The repository and README indicate layered security: local app lock, account auth, and secondary OTP verification for sensitive operations.
   - The important architectural point is that security is not just UI-level; it is backed by database rules and server-side Supabase auth.

11. **Supabase schema and policy boundary**
   - The schema lives in `supabase/migrations/` and is the authoritative backend model.
   - Core tables include `profiles`, `settings`, `transactions`, `debts`, `goals`, `bills`, `recurring`, `groups`, `family_links`, and `phone_index`.
   - Row Level Security is central: users can usually only access their own records, with special read access for linked family members where intended.
   - Triggers provision new users and keep the phone lookup index synchronized.

12. **Offline/PWA/mobile delivery**
   - `public/manifest.json`, `public/sw.js`, and `useInstallPrompt.js` show the app is designed as a **PWA**.
   - The app can be installed like a mobile app, and the service worker provides the offline caching boundary.
   - Capacitor-related support and `vercel.json` indicate multiple deployment targets: web hosting plus mobile packaging.

13. **Build and operational tooling**
   - The frontend build stack is standard modern web tooling: **Vite, PostCSS, Tailwind, ESLint, Prettier**.
   - The repo also includes Supabase local dev configuration and migrations for reproducible backend setup.
   - There are Firebase configuration files present, but the main architecture in the codebase is centered on **React + Supabase**, not Firebase.

14. **How the main data flow works**
   - User authenticates → app shell loads global state → Supabase queries hydrate accounts/transactions/settings → dashboard and analytics render.
   - User actions like adding transactions, splitting bills, or updating goals go through context/state handlers and then persist to Supabase.
   - AI, import, export, and notification features all sit on top of that same core financial data model.

Main entry points: [`src/context/AppContext.jsx`](https://github.com/arabindakabiraj/moneyflow/blob/main/src/context/AppContext.jsx) (App state), [`src/App.jsx`](https://github.com/arabindakabiraj/moneyflow/blob/main/src/App.jsx) (App shell), [`src/supabase.js`](https://github.com/arabindakabiraj/moneyflow/blob/main/src/supabase.js) (Supabase client), [`src/components/AIChat.jsx`](https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/AIChat.jsx) (AI assistant)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_frontend["Frontend app"]
  node_node_main(("main.jsx<br/>entrypoint<br/>[main.jsx]"))
  node_node_app["App shell<br/>shell/router<br/>[App.jsx]"]
  node_node_context[("App state<br/>state hub<br/>[AppContext.jsx]")]
  node_node_theme[("Theme context<br/>ui theme<br/>[ThemeContext.jsx]")]
  node_node_shell_ui["Shell UI<br/>navigation chrome"]
  node_node_guard{{"Access guard<br/>security ui"}}
end

subgraph group_group_domains["Finance domains"]
  node_node_dashboard["Dashboard<br/>overview screen<br/>[Dashboard.jsx]"]
  node_node_accounts["Accounts<br/>portfolio view<br/>[Accounts.jsx]"]
  node_node_transactions["Transactions<br/>ledger view<br/>[Transactions.jsx]"]
  node_node_add_tx["Add transaction<br/>entry flow<br/>[AddTransaction.jsx]"]
  node_node_planning["Planning<br/>budgeting tools"]
  node_node_shared["Shared finance<br/>collaboration<br/>[FamilyMode.jsx]"]
end

subgraph group_group_automation["Automation"]
  node_node_ai(("AI assistant<br/>[AIChat.jsx]"))
  node_node_smart_add["Smart add<br/>nlp parser<br/>[SmartAdd.jsx]"]
  node_node_import_export["Import/export<br/>data transform"]
  node_node_predict{{"Forecasting<br/>insight engine"}}
end

subgraph group_group_backend["Backend boundary"]
  node_node_supabase_client[("Supabase client<br/>data client<br/>[supabase.js]")]
  node_node_schema[("Schema & RLS<br/>backend model")]
  node_node_chat_schema[("Chat messages<br/>backend extension")]
end

subgraph group_group_delivery["Delivery"]
  node_node_pwa["PWA layer<br/>delivery<br/>[manifest.json]"]
  node_node_mobile["Mobile packaging<br/>deployment<br/>[vercel.json]"]
end

node_node_main -->|"mounts"| node_node_app
node_node_app -->|"composes"| node_node_shell_ui
node_node_app -->|"protects"| node_node_guard
node_node_app -->|"hydrates"| node_node_context
node_node_app -->|"themes"| node_node_theme
node_node_context -->|"syncs"| node_node_supabase_client
node_node_guard -->|"authenticates"| node_node_supabase_client
node_node_supabase_client -->|"persists to"| node_node_schema
node_node_supabase_client -->|"stores"| node_node_chat_schema
node_node_schema -.->|"extends"| node_node_chat_schema
node_node_context -->|"feeds"| node_node_dashboard
node_node_context -->|"feeds"| node_node_accounts
node_node_context -->|"feeds"| node_node_transactions
node_node_context -->|"updates"| node_node_add_tx
node_node_context -->|"feeds"| node_node_planning
node_node_context -->|"coordinates"| node_node_shared
node_node_ai -->|"drives"| node_node_smart_add
node_node_smart_add -->|"writes"| node_node_context
node_node_ai -->|"persists"| node_node_supabase_client
node_node_import_export -->|"transforms"| node_node_transactions
node_node_import_export -->|"reads"| node_node_context
node_node_predict -->|"analyzes"| node_node_context
node_node_pwa -->|"supports"| node_node_app
node_node_mobile -.->|"packages"| node_node_pwa

click node_node_main "https://github.com/arabindakabiraj/moneyflow/blob/main/src/main.jsx"
click node_node_app "https://github.com/arabindakabiraj/moneyflow/blob/main/src/App.jsx"
click node_node_context "https://github.com/arabindakabiraj/moneyflow/blob/main/src/context/AppContext.jsx"
click node_node_theme "https://github.com/arabindakabiraj/moneyflow/blob/main/src/context/ThemeContext.jsx"
click node_node_dashboard "https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/Dashboard.jsx"
click node_node_accounts "https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/Accounts.jsx"
click node_node_transactions "https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/Transactions.jsx"
click node_node_add_tx "https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/AddTransaction.jsx"
click node_node_shared "https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/FamilyMode.jsx"
click node_node_ai "https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/AIChat.jsx"
click node_node_smart_add "https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/SmartAdd.jsx"
click node_node_predict "https://github.com/arabindakabiraj/moneyflow/blob/main/src/utils/spendingPredictor.js"
click node_node_supabase_client "https://github.com/arabindakabiraj/moneyflow/blob/main/src/supabase.js"
click node_node_schema "https://github.com/arabindakabiraj/moneyflow/blob/main/supabase/migrations/20260524000000_schema.sql"
click node_node_chat_schema "https://github.com/arabindakabiraj/moneyflow/blob/main/supabase/migrations/20260524000001_chat_messages.sql"
click node_node_pwa "https://github.com/arabindakabiraj/moneyflow/blob/main/public/manifest.json"
click node_node_mobile "https://github.com/arabindakabiraj/moneyflow/blob/main/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_main,node_node_app,node_node_context,node_node_theme,node_node_shell_ui,node_node_guard toneBlue
class node_node_dashboard,node_node_accounts,node_node_transactions,node_node_add_tx,node_node_planning,node_node_shared toneAmber
class node_node_ai,node_node_smart_add,node_node_import_export,node_node_predict toneMint
class node_node_supabase_client,node_node_schema,node_node_chat_schema toneRose
class node_node_pwa,node_node_mobile toneIndigo
```

## Components

### Frontend app

Browser-facing React SPA, shell, state, and UI surfaces.

- [main.jsx](https://github.com/arabindakabiraj/moneyflow/blob/main/src/main.jsx): entrypoint · Bootstraps the React app. · `src/main.jsx`
- [App shell](https://github.com/arabindakabiraj/moneyflow/blob/main/src/App.jsx): shell/router · Top-level layout, routing, and app composition. · `src/App.jsx`
- [App state](https://github.com/arabindakabiraj/moneyflow/blob/main/src/context/AppContext.jsx): state hub · Central finance and UI state coordination. · `src/context/AppContext.jsx`
- [Theme context](https://github.com/arabindakabiraj/moneyflow/blob/main/src/context/ThemeContext.jsx): ui theme · Theme and color system management. · `src/context/ThemeContext.jsx`
- **Shell UI**: navigation chrome · Header, navigation, onboarding, splash, and error handling surfaces.
- **Access guard**: security ui · Auth, app lock, and OTP gating for protected actions.

### Finance domains

Primary finance workflows and dashboards exposed in the app.

- [Dashboard](https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/Dashboard.jsx): overview screen · High-level financial summary and KPIs. · `src/components/Dashboard.jsx`
- [Accounts](https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/Accounts.jsx): portfolio view · Account balances and linked financial sources. · `src/components/Accounts.jsx`
- [Transactions](https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/Transactions.jsx): ledger view · Transaction browsing, editing, and bookkeeping. · `src/components/Transactions.jsx`
- [Add transaction](https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/AddTransaction.jsx): entry flow · Manual transaction creation and update flow. · `src/components/AddTransaction.jsx`
- **Planning**: budgeting tools · Budget, cash flow, net worth, goals, debt, and bills.
- [Shared finance](https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/FamilyMode.jsx): collaboration · Family and group expense coordination. · `src/components/FamilyMode.jsx`

### Automation

AI-assisted entry, import, export, and forecasting helpers.

- [AI assistant](https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/AIChat.jsx): assistant · Conversational finance helper and smart entry surface. · `src/components/AIChat.jsx`
- [Smart add](https://github.com/arabindakabiraj/moneyflow/blob/main/src/components/SmartAdd.jsx): nlp parser · Turns natural language into structured transactions. · `src/components/SmartAdd.jsx`
- **Import/export**: data transform · SMS ingestion and report generation.
- [Forecasting](https://github.com/arabindakabiraj/moneyflow/blob/main/src/utils/spendingPredictor.js): insight engine · Categorization and spending prediction helpers. · `src/utils/spendingPredictor.js`

### Backend boundary

Supabase persistence, auth, schema, and policy layer.

- [Supabase client](https://github.com/arabindakabiraj/moneyflow/blob/main/src/supabase.js): data client · Primary client boundary for persistence and auth. · `src/supabase.js`
- [Schema & RLS](https://github.com/arabindakabiraj/moneyflow/blob/main/supabase/migrations/20260524000000_schema.sql): backend model · Migrations, tables, triggers, and row-level security policies. · `supabase/migrations/20260524000000_schema.sql`
- [Chat messages](https://github.com/arabindakabiraj/moneyflow/blob/main/supabase/migrations/20260524000001_chat_messages.sql): backend extension · Supabase chat message storage. · `supabase/migrations/20260524000001_chat_messages.sql`

### Delivery

PWA and mobile packaging support.

- [PWA layer](https://github.com/arabindakabiraj/moneyflow/blob/main/public/manifest.json): delivery · Manifest, service worker, and install prompt support. · `public/manifest.json`
- [Mobile packaging](https://github.com/arabindakabiraj/moneyflow/blob/main/vercel.json): deployment · Capacitor and hosting configuration for app delivery. · `vercel.json`

## Connections

- main.jsx → App shell: mounts · Entry point renders the application shell.
- App shell → Shell UI: composes · The shell assembles header, nav, onboarding, splash, and error surfaces.
- App shell → Access guard: protects · Auth and lock gating wrap sensitive app flows.
- App shell → App state: hydrates · Shell depends on global finance and UI state.
- App shell → Theme context: themes · App uses shared theme state for styling.
- App state → Supabase client: syncs · Central state reads and writes persisted finance data.
- Access guard → Supabase client: authenticates · Protected flows depend on Supabase auth and verification.
- Supabase client → Schema & RLS: persists to · Client operates against the Supabase schema and RLS boundary.
- Supabase client → Chat messages: stores · Chat-related data uses a dedicated backend table.
- Schema & RLS → Chat messages: extends · Chat messages are part of the backend data model.
- App state → Dashboard: feeds · Global state powers dashboard summaries.
- App state → Accounts: feeds · Account views consume shared finance state.
- App state → Transactions: feeds · Ledger and transaction screens consume shared transaction state.
- App state → Add transaction: updates · Entry flow writes new or edited transactions into state.
- App state → Planning: feeds · Budgeting and goals features reuse the same financial model.
- App state → Shared finance: coordinates · Family and group finance features coordinate through shared state.
- AI assistant → Smart add: drives · Assistant and smart entry form the AI-assisted input path.
- Smart add → App state: writes · Structured transaction output updates global state.
- AI assistant → Supabase client: persists · AI-assisted actions eventually save through the data client.
- Import/export → Transactions: transforms · Imports and exports operate on transaction history.
- Import/export → App state: reads · Reporting and ingestion use shared app data.
- Forecasting → App state: analyzes · Forecasting and categorization derive insights from app state.
- PWA layer → App shell: supports · Manifest, service worker, and install behavior support the shell.
- Mobile packaging → PWA layer: packages · Delivery configuration enables web and mobile distribution.
