# splitwisee/frontend architecture

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

- Interactive diagram: https://gitdiagram.com/splitwisee/frontend
- Repository: https://github.com/splitwisee/frontend

## Overview

Splitwise is a localized personal-finance platform. Its main workflow is profile completion, budgeting data entry and prediction, dashboard review, then investment planning and portfolio tracking. Authentication and the Drizzle-backed database support these flows. The README also describes shared expenses and PWA support; the tree has PWA assets, but no clearly identifiable shared-expense implementation, so that capability is not expanded into an unsupported subsystem. Connections below rely on shown excerpts, SOURCE INDEX references, or README statements; unsampled feature internals are represented at their directory paths.

Main entry points: [`lib/auth.ts`](https://github.com/splitwisee/frontend/blob/main/lib/auth.ts) (Auth sessions), [`lib/db/db.ts`](https://github.com/splitwisee/frontend/blob/main/lib/db/db.ts) (Database client), [`app/api/budgeting/route.ts`](https://github.com/splitwisee/frontend/blob/main/app/api/budgeting/route.ts) (Budget API), [`app/api/investment-portfolios/lib.ts`](https://github.com/splitwisee/frontend/blob/main/app/api/investment-portfolios/lib.ts) (Portfolio operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and localization"]
  node_login["Login flow<br/>[page.tsx]"]
  node_profile["Profile completion<br/>[route.ts]"]
  node_auth["Auth sessions<br/>[auth.ts]"]
  node_localization["Locale routing<br/>[routing.ts]"]
end

subgraph group_budgeting["Budgeting"]
  node_budgeting_ui["Budget onboarding and audit"]
  node_budget_handler["Budget request handler<br/>[handler.ts]"]
  node_financial_estimates["Financial estimates"]
  node_budget_api["Budget API<br/>[route.ts]"]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard_view["Dashboard view"]
  node_dashboard_chart["Interactive chart"]
end

subgraph group_investing["Investment"]
  node_investment_ui["Investment screens"]
  node_investment_calcs["Investment calculations"]
  node_investment_plan_api["Investment plan API<br/>[route.ts]"]
  node_portfolio_api["Portfolio API<br/>[route.ts]"]
  node_portfolio_detail_api["Portfolio detail API<br/>[route.ts]"]
  node_portfolio_logic["Portfolio operations<br/>[lib.ts]"]
  node_instrument_api["Instrument catalog API<br/>[route.ts]"]
end

subgraph group_platform["Platform state"]
  node_db_client["Database client<br/>[db.ts]"]
  node_db_schema[("Finance and user tables<br/>[schema.ts]")]
  node_pwa_worker["PWA service worker<br/>[sw.js]"]
end

node_person(("User"))

node_person -->|"signs in"| node_login
node_login -.->|"authenticates"| node_auth
node_auth -->|"uses adapter"| node_db_client
node_auth -->|"reads profile"| node_db_schema
node_person -->|"completes profile"| node_profile
node_profile -->|"checks session"| node_auth
node_profile -->|"updates profile"| node_db_client
node_person -->|"enters finances"| node_budgeting_ui
node_budgeting_ui -->|"submits audit"| node_budget_handler
node_budget_handler -->|"estimates profile"| node_financial_estimates
node_budget_handler -->|"sends request"| node_budget_api
node_budget_api -->|"checks session"| node_auth
node_budget_api -->|"reads and writes"| node_db_client
node_budget_api -->|"queries budget"| node_db_schema
node_budget_api -->|"builds prediction"| node_financial_estimates
node_budget_api -.->|"returns audit data"| node_budgeting_ui
node_dashboard_view -->|"loads budget"| node_budget_handler
node_dashboard_view -->|"loads investment"| node_investment_ui
node_dashboard_view -->|"renders chart"| node_dashboard_chart
node_person -->|"plans investments"| node_investment_ui
node_investment_ui -.->|"manages plan"| node_investment_plan_api
node_investment_plan_api -->|"projects returns"| node_investment_calcs
node_investment_plan_api -->|"checks session"| node_auth
node_investment_plan_api -->|"reads and writes"| node_db_client
node_portfolio_api -->|"uses operations"| node_portfolio_logic
node_portfolio_api -->|"checks session"| node_auth
node_portfolio_api -->|"stores portfolio"| node_db_client
node_portfolio_detail_api -->|"loads details"| node_portfolio_logic
node_portfolio_logic -->|"calculates values"| node_investment_calcs
node_portfolio_logic -->|"queries holdings"| node_db_client
node_instrument_api -->|"uses catalog logic"| node_portfolio_logic
node_db_client -->|"configures schema"| node_db_schema
node_person -->|"chooses language"| node_localization
node_person -->|"installs app"| node_pwa_worker

click node_login "https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/(auth)/login/page.tsx"
click node_profile "https://github.com/splitwisee/frontend/blob/main/app/api/user/complete-profile/route.ts"
click node_auth "https://github.com/splitwisee/frontend/blob/main/lib/auth.ts"
click node_localization "https://github.com/splitwisee/frontend/blob/main/i18n/routing.ts"
click node_budgeting_ui "https://github.com/splitwisee/frontend/tree/main/app/%5Blocale%5D/feature/budgeting/components"
click node_budget_handler "https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/feature/budgeting/utils/handler.ts"
click node_financial_estimates "https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/feature/budgeting/lib/financial-estimates.ts"
click node_budget_api "https://github.com/splitwisee/frontend/blob/main/app/api/budgeting/route.ts"
click node_dashboard_view "https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/(routes)/app/components/dashboard-client.tsx"
click node_dashboard_chart "https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/(routes)/app/components/chart-interactive.tsx"
click node_investment_ui "https://github.com/splitwisee/frontend/tree/main/app/%5Blocale%5D/feature/investment"
click node_investment_calcs "https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/feature/investment/lib/investment-calculations.ts"
click node_investment_plan_api "https://github.com/splitwisee/frontend/blob/main/app/api/investment-plan/route.ts"
click node_portfolio_api "https://github.com/splitwisee/frontend/blob/main/app/api/investment-portfolios/route.ts"
click node_portfolio_detail_api "https://github.com/splitwisee/frontend/blob/main/app/api/investment-portfolios/%5Bid%5D/route.ts"
click node_portfolio_logic "https://github.com/splitwisee/frontend/blob/main/app/api/investment-portfolios/lib.ts"
click node_instrument_api "https://github.com/splitwisee/frontend/blob/main/app/api/investment-instruments/route.ts"
click node_db_client "https://github.com/splitwisee/frontend/blob/main/lib/db/db.ts"
click node_db_schema "https://github.com/splitwisee/frontend/blob/main/lib/db/schema.ts"
click node_pwa_worker "https://github.com/splitwisee/frontend/blob/main/public/sw.js"

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_login,node_profile,node_auth,node_localization,node_person toneBlue
class node_budgeting_ui,node_budget_handler,node_financial_estimates,node_budget_api toneAmber
class node_dashboard_view,node_dashboard_chart toneMint
class node_investment_ui,node_investment_calcs,node_investment_plan_api,node_portfolio_api,node_portfolio_detail_api,node_portfolio_logic,node_instrument_api toneRose
class node_db_client,node_db_schema,node_pwa_worker toneIndigo
```

## Components

### Identity and localization

- [Login flow](https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/(auth)/login/page.tsx): `app/[locale]/(auth)/login/page.tsx`
- [Profile completion](https://github.com/splitwisee/frontend/blob/main/app/api/user/complete-profile/route.ts): `app/api/user/complete-profile/route.ts`
- [Auth sessions](https://github.com/splitwisee/frontend/blob/main/lib/auth.ts): `lib/auth.ts`
- [Locale routing](https://github.com/splitwisee/frontend/blob/main/i18n/routing.ts): `i18n/routing.ts`

### Budgeting

- [Budget onboarding and audit](https://github.com/splitwisee/frontend/tree/main/app/%5Blocale%5D/feature/budgeting/components): `app/[locale]/feature/budgeting/components`
- [Budget request handler](https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/feature/budgeting/utils/handler.ts): `app/[locale]/feature/budgeting/utils/handler.ts`
- [Financial estimates](https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/feature/budgeting/lib/financial-estimates.ts): `app/[locale]/feature/budgeting/lib/financial-estimates.ts`
- [Budget API](https://github.com/splitwisee/frontend/blob/main/app/api/budgeting/route.ts): `app/api/budgeting/route.ts`

### Dashboard

- [Dashboard view](https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/(routes)/app/components/dashboard-client.tsx): `app/[locale]/(routes)/app/components/dashboard-client.tsx`
- [Interactive chart](https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/(routes)/app/components/chart-interactive.tsx): `app/[locale]/(routes)/app/components/chart-interactive.tsx`

### Investment

- [Investment screens](https://github.com/splitwisee/frontend/tree/main/app/%5Blocale%5D/feature/investment): `app/[locale]/feature/investment`
- [Investment calculations](https://github.com/splitwisee/frontend/blob/main/app/%5Blocale%5D/feature/investment/lib/investment-calculations.ts): `app/[locale]/feature/investment/lib/investment-calculations.ts`
- [Investment plan API](https://github.com/splitwisee/frontend/blob/main/app/api/investment-plan/route.ts): `app/api/investment-plan/route.ts`
- [Portfolio API](https://github.com/splitwisee/frontend/blob/main/app/api/investment-portfolios/route.ts): `app/api/investment-portfolios/route.ts`
- [Portfolio detail API](https://github.com/splitwisee/frontend/blob/main/app/api/investment-portfolios/%5Bid%5D/route.ts): `app/api/investment-portfolios/[id]/route.ts`
- [Portfolio operations](https://github.com/splitwisee/frontend/blob/main/app/api/investment-portfolios/lib.ts): `app/api/investment-portfolios/lib.ts`
- [Instrument catalog API](https://github.com/splitwisee/frontend/blob/main/app/api/investment-instruments/route.ts): `app/api/investment-instruments/route.ts`

### Platform state

- [Database client](https://github.com/splitwisee/frontend/blob/main/lib/db/db.ts): `lib/db/db.ts`
- [Finance and user tables](https://github.com/splitwisee/frontend/blob/main/lib/db/schema.ts): `lib/db/schema.ts`
- [PWA service worker](https://github.com/splitwisee/frontend/blob/main/public/sw.js): `public/sw.js`

### Other components

- **User**

## Connections

- User → Login flow: signs in
- Login flow → Auth sessions: authenticates
- Auth sessions → Database client: uses adapter (evidence: `lib/auth.ts`)
- Auth sessions → Finance and user tables: reads profile (evidence: `lib/auth.ts`)
- User → Profile completion: completes profile
- Profile completion → Auth sessions: checks session (evidence: `app/api/user/complete-profile/route.ts`)
- Profile completion → Database client: updates profile (evidence: `app/api/user/complete-profile/route.ts`)
- User → Budget onboarding and audit: enters finances
- Budget onboarding and audit → Budget request handler: submits audit (evidence: `app/[locale]/feature/budgeting/components/budgeting-audit-review.tsx`)
- Budget request handler → Financial estimates: estimates profile (evidence: `app/[locale]/feature/budgeting/utils/handler.ts`)
- Budget request handler → Budget API: sends request (evidence: `app/[locale]/feature/budgeting/utils/handler.ts`)
- Budget API → Auth sessions: checks session (evidence: `app/api/budgeting/route.ts`)
- Budget API → Database client: reads and writes (evidence: `app/api/budgeting/route.ts`)
- Budget API → Finance and user tables: queries budget (evidence: `app/api/budgeting/route.ts`)
- Budget API → Financial estimates: builds prediction (evidence: `app/api/budgeting/route.ts`)
- Budget API → Budget onboarding and audit: returns audit data
- Dashboard view → Budget request handler: loads budget (evidence: `app/[locale]/(routes)/app/components/dashboard-client.tsx`)
- Dashboard view → Investment screens: loads investment (evidence: `app/[locale]/(routes)/app/components/dashboard-client.tsx`)
- Dashboard view → Interactive chart: renders chart (evidence: `app/[locale]/(routes)/app/components/dashboard-client.tsx`)
- User → Investment screens: plans investments
- Investment screens → Investment plan API: manages plan (evidence: `app/api/investment-plan/route.ts`)
- Investment plan API → Investment calculations: projects returns (evidence: `app/api/investment-plan/route.ts`)
- Investment plan API → Auth sessions: checks session (evidence: `app/api/investment-plan/route.ts`)
- Investment plan API → Database client: reads and writes (evidence: `app/api/investment-plan/route.ts`)
- Portfolio API → Portfolio operations: uses operations (evidence: `app/api/investment-portfolios/route.ts`)
- Portfolio API → Auth sessions: checks session (evidence: `app/api/investment-portfolios/route.ts`)
- Portfolio API → Database client: stores portfolio (evidence: `app/api/investment-portfolios/route.ts`)
- Portfolio detail API → Portfolio operations: loads details (evidence: `app/api/investment-portfolios/[id]/route.ts`)
- Portfolio operations → Investment calculations: calculates values (evidence: `app/api/investment-portfolios/lib.ts`)
- Portfolio operations → Database client: queries holdings (evidence: `app/api/investment-portfolios/lib.ts`)
- Instrument catalog API → Portfolio operations: uses catalog logic (evidence: `app/api/investment-instruments/route.ts`)
- Database client → Finance and user tables: configures schema (evidence: `lib/db/db.ts`)
- User → Locale routing: chooses language
- User → PWA service worker: installs app
