# zhengjason0814/bread architecture

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

- Interactive diagram: https://gitdiagram.com/zhengjason0814/bread
- Repository: https://github.com/zhengjason0814/bread
- Video tour (about a minute): https://gitdiagram.com/zhengjason0814/bread/video

## Overview

Bread is a personal-finance application: users sign in or enter demo mode, then manage imported and manual transactions, accounts, budgets, receipts and spending insights. The browser calls the Node API, which owns persistence and brokers external services; a separate stateless ML service provides forecasting, classification, anomaly detection and recurring-transaction detection. The graph preserves these documented capabilities, but several unsampled routes are represented only at the subsystem level; dashed links indicate relationships not verified in the excerpts.

Main entry points: [`backend/src/app.js`](https://github.com/zhengjason0814/bread/blob/main/backend/src/app.js) (API router), [`ml-service/app/main.py`](https://github.com/zhengjason0814/bread/blob/main/ml-service/app/main.py) (ML endpoints), [`frontend/src/main.jsx`](https://github.com/zhengjason0814/bread/blob/main/frontend/src/main.jsx) (React application), [`backend/src/routes/plaid.js`](https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/plaid.js) (Bank connections)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Browser experience"]
  node_webapp["React application<br/>[main.jsx]"]
  node_authui["Sign-in and demo<br/>[AuthForm.jsx]"]
  node_layout["App data workspace<br/>[AppLayout.jsx]"]
  node_financepages["Finance pages"]
  node_api_client["API client<br/>[client.js]"]
end

subgraph group_api["Backend API"]
  node_express["API router<br/>[app.js]"]
  node_authroutes["Authentication<br/>[auth.js]"]
  node_expense_routes["Transactions and receipts<br/>[expenses.js]"]
  node_plaid_routes["Bank connections<br/>[plaid.js]"]
  node_insight_routes["Spending insights<br/>[insights.js]"]
  node_budget_routes["Budgets<br/>[budgets.js]"]
  node_account_routes["Accounts<br/>[accounts.js]"]
  node_admin_demo["Admin and demo"]
  node_mlclient["ML service client<br/>[mlClient.js]"]
end

subgraph group_domain["Finance data"]
  node_user_model["User profile<br/>[User.js]"]
  node_expense_model["Expense records<br/>[Expense.js]"]
  node_bank_models["Linked accounts<br/>[Account.js]"]
  node_mongodb[("MongoDB<br/>[db.js]")]
end

subgraph group_integrations["External services"]
  node_plaid["Plaid"]
  node_s3["Private receipt storage<br/>[receiptStorage.js]"]
  node_google["Google identity"]
end

subgraph group_ml["Machine learning"]
  node_mlapi["ML endpoints<br/>[main.py]"]
  node_forecast["Spend forecasting<br/>[prediction.py]"]
  node_classify["Purchase classification<br/>[classification.py]"]
  node_anomaly["Anomaly detection<br/>[anomalies.py]"]
  node_recurring["Recurring detection<br/>[recurring.py]"]
end

node_person(("Finance user"))

node_person -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_authui
node_webapp -->|"routes to"| node_layout
node_webapp -->|"routes to"| node_financepages
node_authui -->|"submits credentials"| node_api_client
node_layout -->|"loads finance data"| node_api_client
node_api_client -->|"calls API"| node_express
node_express -->|"routes to"| node_authroutes
node_express -->|"routes to"| node_expense_routes
node_express -->|"routes to"| node_plaid_routes
node_express -->|"routes to"| node_insight_routes
node_express -->|"routes to"| node_budget_routes
node_express -->|"routes to"| node_account_routes
node_express -->|"routes to"| node_admin_demo
node_authroutes -->|"reads and writes"| node_user_model
node_expense_routes -->|"reads and writes"| node_expense_model
node_expense_routes -->|"stores receipts"| node_s3
node_plaid_routes -->|"exchanges and syncs"| node_plaid
node_plaid_routes -->|"persists accounts"| node_bank_models
node_plaid_routes -->|"imports transactions"| node_expense_model
node_authroutes -->|"verifies identity"| node_google
node_insight_routes -.->|"requests calculations"| node_mlclient
node_mlclient -->|"sends features"| node_mlapi
node_mlapi -->|"dispatches prediction"| node_forecast
node_mlapi -->|"dispatches classification"| node_classify
node_mlapi -->|"dispatches detection"| node_anomaly
node_mlapi -->|"dispatches detection"| node_recurring
node_user_model -.->|"persists profile"| node_mongodb
node_expense_model -.->|"persists expenses"| node_mongodb

click node_webapp "https://github.com/zhengjason0814/bread/blob/main/frontend/src/main.jsx"
click node_authui "https://github.com/zhengjason0814/bread/blob/main/frontend/src/components/AuthForm.jsx"
click node_layout "https://github.com/zhengjason0814/bread/blob/main/frontend/src/layout/AppLayout.jsx"
click node_financepages "https://github.com/zhengjason0814/bread/tree/main/frontend/src/pages"
click node_api_client "https://github.com/zhengjason0814/bread/blob/main/frontend/src/api/client.js"
click node_express "https://github.com/zhengjason0814/bread/blob/main/backend/src/app.js"
click node_authroutes "https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/auth.js"
click node_expense_routes "https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/expenses.js"
click node_plaid_routes "https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/plaid.js"
click node_insight_routes "https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/insights.js"
click node_budget_routes "https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/budgets.js"
click node_account_routes "https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/accounts.js"
click node_admin_demo "https://github.com/zhengjason0814/bread/tree/main/backend/src/routes"
click node_user_model "https://github.com/zhengjason0814/bread/blob/main/backend/src/models/User.js"
click node_expense_model "https://github.com/zhengjason0814/bread/blob/main/backend/src/models/Expense.js"
click node_bank_models "https://github.com/zhengjason0814/bread/blob/main/backend/src/models/Account.js"
click node_mongodb "https://github.com/zhengjason0814/bread/blob/main/backend/src/config/db.js"
click node_s3 "https://github.com/zhengjason0814/bread/blob/main/backend/src/services/receiptStorage.js"
click node_mlclient "https://github.com/zhengjason0814/bread/blob/main/backend/src/services/mlClient.js"
click node_mlapi "https://github.com/zhengjason0814/bread/blob/main/ml-service/app/main.py"
click node_forecast "https://github.com/zhengjason0814/bread/blob/main/ml-service/app/prediction.py"
click node_classify "https://github.com/zhengjason0814/bread/blob/main/ml-service/app/classification.py"
click node_anomaly "https://github.com/zhengjason0814/bread/blob/main/ml-service/app/anomalies.py"
click node_recurring "https://github.com/zhengjason0814/bread/blob/main/ml-service/app/recurring.py"

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_webapp,node_authui,node_layout,node_financepages,node_api_client,node_person toneBlue
class node_express,node_authroutes,node_expense_routes,node_plaid_routes,node_insight_routes,node_budget_routes,node_account_routes,node_admin_demo,node_mlclient toneAmber
class node_user_model,node_expense_model,node_bank_models,node_mongodb toneMint
class node_plaid,node_s3,node_google toneRose
class node_mlapi,node_forecast,node_classify,node_anomaly,node_recurring toneIndigo
```

## Components

### Browser experience

- [React application](https://github.com/zhengjason0814/bread/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Sign-in and demo](https://github.com/zhengjason0814/bread/blob/main/frontend/src/components/AuthForm.jsx): `frontend/src/components/AuthForm.jsx`
- [App data workspace](https://github.com/zhengjason0814/bread/blob/main/frontend/src/layout/AppLayout.jsx): `frontend/src/layout/AppLayout.jsx`
- [Finance pages](https://github.com/zhengjason0814/bread/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/zhengjason0814/bread/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### Backend API

- [API router](https://github.com/zhengjason0814/bread/blob/main/backend/src/app.js): `backend/src/app.js`
- [Authentication](https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Transactions and receipts](https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/expenses.js): `backend/src/routes/expenses.js`
- [Bank connections](https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/plaid.js): `backend/src/routes/plaid.js`
- [Spending insights](https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/insights.js): `backend/src/routes/insights.js`
- [Budgets](https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/budgets.js): `backend/src/routes/budgets.js`
- [Accounts](https://github.com/zhengjason0814/bread/blob/main/backend/src/routes/accounts.js): `backend/src/routes/accounts.js`
- [Admin and demo](https://github.com/zhengjason0814/bread/tree/main/backend/src/routes): `backend/src/routes`
- [ML service client](https://github.com/zhengjason0814/bread/blob/main/backend/src/services/mlClient.js): `backend/src/services/mlClient.js`

### Finance data

- [User profile](https://github.com/zhengjason0814/bread/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Expense records](https://github.com/zhengjason0814/bread/blob/main/backend/src/models/Expense.js): `backend/src/models/Expense.js`
- [Linked accounts](https://github.com/zhengjason0814/bread/blob/main/backend/src/models/Account.js): `backend/src/models/Account.js`
- [MongoDB](https://github.com/zhengjason0814/bread/blob/main/backend/src/config/db.js): `backend/src/config/db.js`

### External services

- **Plaid**
- [Private receipt storage](https://github.com/zhengjason0814/bread/blob/main/backend/src/services/receiptStorage.js): `backend/src/services/receiptStorage.js`
- **Google identity**

### Machine learning

- [ML endpoints](https://github.com/zhengjason0814/bread/blob/main/ml-service/app/main.py): `ml-service/app/main.py`
- [Spend forecasting](https://github.com/zhengjason0814/bread/blob/main/ml-service/app/prediction.py): `ml-service/app/prediction.py`
- [Purchase classification](https://github.com/zhengjason0814/bread/blob/main/ml-service/app/classification.py): `ml-service/app/classification.py`
- [Anomaly detection](https://github.com/zhengjason0814/bread/blob/main/ml-service/app/anomalies.py): `ml-service/app/anomalies.py`
- [Recurring detection](https://github.com/zhengjason0814/bread/blob/main/ml-service/app/recurring.py): `ml-service/app/recurring.py`

### Other components

- **Finance user**

## Connections

- Finance user → React application: uses
- React application → Sign-in and demo: routes to (evidence: `frontend/src/main.jsx`)
- React application → App data workspace: routes to (evidence: `frontend/src/main.jsx`)
- React application → Finance pages: routes to (evidence: `frontend/src/main.jsx`)
- Sign-in and demo → API client: submits credentials (evidence: `frontend/src/components/AuthForm.jsx`)
- App data workspace → API client: loads finance data (evidence: `frontend/src/layout/AppLayout.jsx`)
- API client → API router: calls API
- API router → Authentication: routes to (evidence: `backend/src/app.js`)
- API router → Transactions and receipts: routes to (evidence: `backend/src/app.js`)
- API router → Bank connections: routes to (evidence: `backend/src/app.js`)
- API router → Spending insights: routes to (evidence: `backend/src/app.js`)
- API router → Budgets: routes to (evidence: `backend/src/app.js`)
- API router → Accounts: routes to (evidence: `backend/src/app.js`)
- API router → Admin and demo: routes to (evidence: `backend/src/app.js`)
- Authentication → User profile: reads and writes (evidence: `backend/src/routes/auth.js`)
- Transactions and receipts → Expense records: reads and writes (evidence: `backend/src/routes/expenses.js`)
- Transactions and receipts → Private receipt storage: stores receipts (evidence: `backend/src/routes/expenses.js`)
- Bank connections → Plaid: exchanges and syncs
- Bank connections → Linked accounts: persists accounts (evidence: `backend/src/routes/plaid.js`)
- Bank connections → Expense records: imports transactions (evidence: `backend/src/routes/plaid.js`)
- Authentication → Google identity: verifies identity
- Spending insights → ML service client: requests calculations
- ML service client → ML endpoints: sends features
- ML endpoints → Spend forecasting: dispatches prediction (evidence: `ml-service/app/main.py`)
- ML endpoints → Purchase classification: dispatches classification (evidence: `ml-service/app/main.py`)
- ML endpoints → Anomaly detection: dispatches detection (evidence: `ml-service/app/main.py`)
- ML endpoints → Recurring detection: dispatches detection (evidence: `ml-service/app/main.py`)
- User profile → MongoDB: persists profile
- Expense records → MongoDB: persists expenses
