# mim-2001/budgetbuddy_v2 architecture

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

- Interactive diagram: https://gitdiagram.com/mim-2001/budgetbuddy_v2
- Repository: https://github.com/mim-2001/budgetbuddy_v2

## Overview

BudgetBuddy is a local browser-based budgeting app. A purchase check enters through the HTTP server and app controller, is interpreted by the affordability view, then flows through ServiceHub into affordability, spending, and recurring-bill calculations; the result returns to the view as HTML. Other branches cover setup, transactions, budgets, recurring schedules, dashboard, and challenges. Persistence uses DAOs over one local JSON file. The README documents the broader page flows; unsampled controller and view details are represented at subsystem level.

Main entry points: [`account.js`](https://github.com/mim-2001/budgetbuddy_v2/blob/main/account.js) (Account models), [`service-hub.js`](https://github.com/mim-2001/budgetbuddy_v2/blob/main/service-hub.js) (Service hub), [`calendar.js`](https://github.com/mim-2001/budgetbuddy_v2/blob/main/calendar.js) (Financial calendar), [`helpers.js`](https://github.com/mim-2001/budgetbuddy_v2/blob/main/helpers.js) (Date and money helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_server["HTTP server<br/>[server.js]"]
  node_app["App controller<br/>[controllers.js]"]
  node_views["Page views<br/>[views.js]"]
end

subgraph group_domain["Budgeting domain"]
  node_hub["Service hub<br/>[service-hub.js]"]
  node_affordability["Affordability rules<br/>[services.js]"]
  node_spending["Spending service<br/>[services.js]"]
  node_calculators["Monthly calculators<br/>[services.js]"]
  node_recurring["Recurring service<br/>[services.js]"]
  node_challenges["Challenge service<br/>[challenges.js]"]
  node_account["Account models<br/>[account.js]"]
  node_calendar["Financial calendar<br/>[calendar.js]"]
end

subgraph group_persistence["Saved data"]
  node_dao_manager["DAO manager<br/>[daos.js]"]
  node_record_daos["Record and account DAOs<br/>[daos.js]"]
  node_storage["JSON storage<br/>[storage.js]"]
  node_json_file["Budget data file"]
end

subgraph group_shared["Shared utilities"]
  node_helpers["Date and money helpers<br/>[helpers.js]"]
end

node_browser(("Browser user"))

node_browser -->|"submits forms"| node_server
node_server -->|"routes requests"| node_app
node_app -->|"reads and renders"| node_views
node_app -->|"requests data"| node_hub
node_hub -->|"evaluates purchase"| node_affordability
node_affordability -->|"checks summary"| node_spending
node_affordability -->|"checks unpaid bills"| node_recurring
node_spending -->|"calculates totals"| node_calculators
node_calculators -->|"queries records"| node_account
node_calculators -->|"estimates income"| node_calendar
node_recurring -->|"processes schedules"| node_calendar
node_recurring -->|"records payments"| node_account
node_hub -->|"requests recommendations"| node_challenges
node_challenges -->|"reads and adjusts budgets"| node_account
node_hub -->|"persists changes"| node_dao_manager
node_dao_manager -->|"loads and commits"| node_record_daos
node_record_daos -->|"rebuilds models"| node_account
node_record_daos -->|"rebuilds schedules"| node_calendar
node_dao_manager -->|"commits data"| node_storage
node_storage -->|"reads and writes"| node_json_file
node_views -->|"formats values"| node_helpers
node_account -->|"validates dates and amounts"| node_helpers
node_calendar -->|"calculates dates"| node_helpers
node_challenges -->|"calculates date ranges"| node_helpers

click node_server "https://github.com/mim-2001/budgetbuddy_v2/blob/main/server.js"
click node_app "https://github.com/mim-2001/budgetbuddy_v2/blob/main/controllers.js"
click node_views "https://github.com/mim-2001/budgetbuddy_v2/blob/main/views.js"
click node_hub "https://github.com/mim-2001/budgetbuddy_v2/blob/main/service-hub.js"
click node_affordability "https://github.com/mim-2001/budgetbuddy_v2/blob/main/services.js"
click node_spending "https://github.com/mim-2001/budgetbuddy_v2/blob/main/services.js"
click node_calculators "https://github.com/mim-2001/budgetbuddy_v2/blob/main/services.js"
click node_recurring "https://github.com/mim-2001/budgetbuddy_v2/blob/main/services.js"
click node_challenges "https://github.com/mim-2001/budgetbuddy_v2/blob/main/challenges.js"
click node_account "https://github.com/mim-2001/budgetbuddy_v2/blob/main/account.js"
click node_calendar "https://github.com/mim-2001/budgetbuddy_v2/blob/main/calendar.js"
click node_dao_manager "https://github.com/mim-2001/budgetbuddy_v2/blob/main/daos.js"
click node_record_daos "https://github.com/mim-2001/budgetbuddy_v2/blob/main/daos.js"
click node_storage "https://github.com/mim-2001/budgetbuddy_v2/blob/main/storage.js"
click node_helpers "https://github.com/mim-2001/budgetbuddy_v2/blob/main/helpers.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_server,node_app,node_views,node_browser toneBlue
class node_hub,node_affordability,node_spending,node_calculators,node_recurring,node_challenges,node_account,node_calendar toneAmber
class node_dao_manager,node_record_daos,node_storage,node_json_file toneMint
class node_helpers toneRose
```

## Components

### Web interface

- [HTTP server](https://github.com/mim-2001/budgetbuddy_v2/blob/main/server.js): `server.js`
- [App controller](https://github.com/mim-2001/budgetbuddy_v2/blob/main/controllers.js): `controllers.js`
- [Page views](https://github.com/mim-2001/budgetbuddy_v2/blob/main/views.js): `views.js`

### Budgeting domain

- [Service hub](https://github.com/mim-2001/budgetbuddy_v2/blob/main/service-hub.js): `service-hub.js`
- [Affordability rules](https://github.com/mim-2001/budgetbuddy_v2/blob/main/services.js): `services.js`
- [Spending service](https://github.com/mim-2001/budgetbuddy_v2/blob/main/services.js): `services.js`
- [Monthly calculators](https://github.com/mim-2001/budgetbuddy_v2/blob/main/services.js): `services.js`
- [Recurring service](https://github.com/mim-2001/budgetbuddy_v2/blob/main/services.js): `services.js`
- [Challenge service](https://github.com/mim-2001/budgetbuddy_v2/blob/main/challenges.js): `challenges.js`
- [Account models](https://github.com/mim-2001/budgetbuddy_v2/blob/main/account.js): `account.js`
- [Financial calendar](https://github.com/mim-2001/budgetbuddy_v2/blob/main/calendar.js): `calendar.js`

### Saved data

- [DAO manager](https://github.com/mim-2001/budgetbuddy_v2/blob/main/daos.js): `daos.js`
- [Record and account DAOs](https://github.com/mim-2001/budgetbuddy_v2/blob/main/daos.js): `daos.js`
- [JSON storage](https://github.com/mim-2001/budgetbuddy_v2/blob/main/storage.js): `storage.js`
- **Budget data file**

### Shared utilities

- [Date and money helpers](https://github.com/mim-2001/budgetbuddy_v2/blob/main/helpers.js): `helpers.js`

### Other components

- **Browser user**

## Connections

- Browser user → HTTP server: submits forms (evidence: `README.md`)
- HTTP server → App controller: routes requests (evidence: `server.js`)
- App controller → Page views: reads and renders (evidence: `README.md`)
- App controller → Service hub: requests data (evidence: `README.md`)
- Service hub → Affordability rules: evaluates purchase (evidence: `service-hub.js`)
- Affordability rules → Spending service: checks summary (evidence: `services.js`)
- Affordability rules → Recurring service: checks unpaid bills (evidence: `services.js`)
- Spending service → Monthly calculators: calculates totals (evidence: `services.js`)
- Monthly calculators → Account models: queries records (evidence: `services.js`)
- Monthly calculators → Financial calendar: estimates income (evidence: `services.js`)
- Recurring service → Financial calendar: processes schedules (evidence: `services.js`)
- Recurring service → Account models: records payments
- Service hub → Challenge service: requests recommendations (evidence: `service-hub.js`)
- Challenge service → Account models: reads and adjusts budgets (evidence: `challenges.js`)
- Service hub → DAO manager: persists changes (evidence: `service-hub.js`)
- DAO manager → Record and account DAOs: loads and commits (evidence: `daos.js`)
- Record and account DAOs → Account models: rebuilds models (evidence: `daos.js`)
- Record and account DAOs → Financial calendar: rebuilds schedules (evidence: `daos.js`)
- DAO manager → JSON storage: commits data (evidence: `daos.js`)
- JSON storage → Budget data file: reads and writes (evidence: `README.md`)
- Page views → Date and money helpers: formats values (evidence: `views.js`)
- Account models → Date and money helpers: validates dates and amounts (evidence: `account.js`)
- Financial calendar → Date and money helpers: calculates dates (evidence: `calendar.js`)
- Challenge service → Date and money helpers: calculates date ranges (evidence: `challenges.js`)
