# tnguyen14/ledge architecture

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

- Interactive diagram: https://gitdiagram.com/tnguyen14/ledge
- Repository: https://github.com/tnguyen14/ledge

## Overview

#### Purpose and Runtime

Ledge is a personal-finance client for viewing and managing transactions, budgets, cashflow, recurring spending, categories, and user settings. It is a Vite/React single-page application, packaged for Docker and deployable through Vercel. The app relies on a separate authenticated API server; operational scripts also query and update that backend using a JWT.

Primary client entry points: `src/index.html`, `src/index.jsx`, and `src/components/App/index.jsx`.

#### Application Composition

`App` is the shell that coordinates authenticated application state, global layout, navigation, notifications, and feature views. The header includes user controls; login is a distinct unauthenticated surface.

Key boundaries:
- Application shell and routing/view coordination: `src/components/App/index.jsx`
- Authentication UI and user menu: `src/components/Login/index.jsx`, `src/components/Header/index.jsx`, `src/components/Header/UserMenu.jsx`
- Global feedback: `src/components/Notification/index.jsx`

#### State, Context, and Derived Data

Redux-style centralized state holds application, form, metadata, and transaction domains. Feature components consume normalized/raw state through selectors that derive time, transaction, and aggregate views. Contexts provide cross-cutting budget and GitHub/Octokit integrations.

- Store and state domains: `src/store.js`, `src/slices/transactions.js`, `src/slices/meta.js`
- Derived financial/time views: `src/selectors/transactions.js`, `src/selectors/stats.js`, `src/selectors/week.js`
- Cross-cutting contexts: `src/contexts/budget.js`, `src/contexts/octokit.js`

#### Transaction and Metadata Flow

The core flow fetches transaction and metadata data from the API, stores it in state, then derives transaction lists, weekly groupings, statistics, and category summaries for presentation. Form state supports transaction editing or filtering workflows; utility modules encapsulate API access, fetch behavior, transaction shaping, merchant logic, and calculations.

- API/data boundary: `src/util/api.js`, `src/util/fetch.js`
- Transaction transformation and merchant handling: `src/util/transaction.js`, `src/util/merchants.js`
- Domain calculations/constants: `src/util/calculate.js`, `src/util/constants.js`

#### Financial Presentation Features

Transactions are the operational detail view, with search results, individual/compact transaction rows, and weekly/category rollups. Dashboard-style components expose aggregate global statistics, budget status, cashflow, category breakdowns, and weekly averages. Recurring transactions and cashflow are separate feature surfaces.

- Transaction browsing/grouping: `src/components/Transactions/index.jsx`, `src/components/Transactions/Week.jsx`, `src/components/Transactions/Transaction.jsx`
- Aggregate reporting and budget views: `src/components/GlobalStats/index.jsx`, `src/components/GlobalStats/CashflowChart.jsx`, `src/components/GlobalStats/Budget.jsx`
- Other finance views: `src/components/Cashflow/index.jsx`, `src/components/Recurring/index.jsx`

#### Infrastructure and External Services

Vite provides the browser build/development pipeline; Docker Compose supports containerized execution. Vercel configuration indicates hosted deployment. GitHub Actions provides CI/CD and production testing. The application’s principal external dependency is its JWT-authenticated API server; GitHub/Octokit is also represented as an integration context.

- Build/deployment: `vite.config.js`, `Dockerfile`, `compose.yml`, `vercel.json`
- CI/CD: `.github/workflows/cicd.yml`, `.github/workflows/production-test.yml`
- Backend maintenance scripts: `bin/find_transactions.js`, `bin/update_transaction.js`, `bin/get_metadata.sh`

Main entry points: [`src/components/App/index.jsx`](https://github.com/tnguyen14/ledge/blob/main/src/components/App/index.jsx) (Application shell), [`src/store.js`](https://github.com/tnguyen14/ledge/blob/main/src/store.js) (Central store), [`src/selectors/transactions.js`](https://github.com/tnguyen14/ledge/blob/main/src/selectors/transactions.js) (Financial selectors), [`src/slices/transactions.js`](https://github.com/tnguyen14/ledge/blob/main/src/slices/transactions.js) (Transaction state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_entry["Browser entry<br/>Vite entry<br/>[index.jsx]"]
  node_app["Application shell<br/>React shell<br/>[index.jsx]"]
  node_auth["Login and user controls<br/>auth UI<br/>[index.jsx]"]
  node_header["Header menu<br/>navigation UI<br/>[index.jsx]"]
  node_notifications["Notifications<br/>feedback UI<br/>[index.jsx]"]
  node_transactions_view["Transactions<br/>finance view<br/>[index.jsx]"]
  node_reporting["Stats and budget<br/>finance dashboard<br/>[index.jsx]"]
  node_cashflow_recurring["Cashflow and recurring<br/>finance views<br/>[index.jsx]"]
end

subgraph group_data["State and data"]
  node_store[("Central store<br/>Redux state<br/>[store.js]")]
  node_transaction_state["Transaction state<br/>state slice<br/>[transactions.js]"]
  node_metadata_state["Metadata state<br/>state slice<br/>[meta.js]"]
  node_selectors["Financial selectors<br/>derived data<br/>[transactions.js]"]
  node_api{{"Authenticated API client<br/>data gateway<br/>[api.js]"}}
  node_transaction_domain["Transaction domain logic<br/>transformations<br/>[transaction.js]"]
  node_budget_context["Budget context<br/>cross-cutting context<br/>[budget.js]"]
end

subgraph group_ops["Delivery and operations"]
  node_delivery["Build and deployment<br/>Vite, Docker, Vercel<br/>[vite.config.js]"]
  node_ci["CI/CD<br/>GitHub Actions<br/>[cicd.yml]"]
  node_maintenance["Backend maintenance scripts<br/>JWT operations"]
end

node_api_server{{"Authenticated API server<br/>external backend"}}

node_entry -->|"mounts"| node_app
node_app -->|"unauthenticated access"| node_auth
node_app -->|"renders"| node_header
node_app -->|"renders"| node_notifications
node_app -->|"coordinates"| node_transactions_view
node_app -->|"coordinates"| node_reporting
node_app -->|"coordinates"| node_cashflow_recurring
node_app -->|"uses"| node_store
node_store -->|"contains"| node_transaction_state
node_store -->|"contains"| node_metadata_state
node_transaction_state -->|"source state"| node_selectors
node_metadata_state -->|"source state"| node_selectors
node_selectors -->|"transaction and week views"| node_transactions_view
node_selectors -->|"statistics and summaries"| node_reporting
node_budget_context -->|"budget data"| node_reporting
node_api -->|"JWT requests"| node_api_server
node_api -->|"loads data"| node_store
node_transaction_domain -->|"shapes records"| node_transaction_state
node_maintenance -->|"JWT query and updates"| node_api_server
node_ci -->|"builds and deploys"| node_delivery

click node_entry "https://github.com/tnguyen14/ledge/blob/main/src/index.jsx"
click node_app "https://github.com/tnguyen14/ledge/blob/main/src/components/App/index.jsx"
click node_auth "https://github.com/tnguyen14/ledge/blob/main/src/components/Login/index.jsx"
click node_header "https://github.com/tnguyen14/ledge/blob/main/src/components/Header/index.jsx"
click node_notifications "https://github.com/tnguyen14/ledge/blob/main/src/components/Notification/index.jsx"
click node_transactions_view "https://github.com/tnguyen14/ledge/blob/main/src/components/Transactions/index.jsx"
click node_reporting "https://github.com/tnguyen14/ledge/blob/main/src/components/GlobalStats/index.jsx"
click node_cashflow_recurring "https://github.com/tnguyen14/ledge/blob/main/src/components/Cashflow/index.jsx"
click node_store "https://github.com/tnguyen14/ledge/blob/main/src/store.js"
click node_transaction_state "https://github.com/tnguyen14/ledge/blob/main/src/slices/transactions.js"
click node_metadata_state "https://github.com/tnguyen14/ledge/blob/main/src/slices/meta.js"
click node_selectors "https://github.com/tnguyen14/ledge/blob/main/src/selectors/transactions.js"
click node_api "https://github.com/tnguyen14/ledge/blob/main/src/util/api.js"
click node_transaction_domain "https://github.com/tnguyen14/ledge/blob/main/src/util/transaction.js"
click node_budget_context "https://github.com/tnguyen14/ledge/blob/main/src/contexts/budget.js"
click node_delivery "https://github.com/tnguyen14/ledge/blob/main/vite.config.js"
click node_ci "https://github.com/tnguyen14/ledge/blob/main/.github/workflows/cicd.yml"
click node_maintenance "https://github.com/tnguyen14/ledge/blob/main/bin/find_transactions.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_entry,node_app,node_auth,node_header,node_notifications,node_transactions_view,node_reporting,node_cashflow_recurring toneBlue
class node_store,node_transaction_state,node_metadata_state,node_selectors,node_api,node_transaction_domain,node_budget_context toneAmber
class node_delivery,node_ci,node_maintenance toneMint
class node_api_server toneNeutral
```

## Components

### React client

Browser SPA composition and finance views.

- [Browser entry](https://github.com/tnguyen14/ledge/blob/main/src/index.jsx): Vite entry · `src/index.jsx`
- [Application shell](https://github.com/tnguyen14/ledge/blob/main/src/components/App/index.jsx): React shell · Coordinates authenticated layout, navigation, and feature views. · `src/components/App/index.jsx`
- [Login and user controls](https://github.com/tnguyen14/ledge/blob/main/src/components/Login/index.jsx): auth UI · `src/components/Login/index.jsx`
- [Header menu](https://github.com/tnguyen14/ledge/blob/main/src/components/Header/index.jsx): navigation UI · `src/components/Header/index.jsx`
- [Notifications](https://github.com/tnguyen14/ledge/blob/main/src/components/Notification/index.jsx): feedback UI · `src/components/Notification/index.jsx`
- [Transactions](https://github.com/tnguyen14/ledge/blob/main/src/components/Transactions/index.jsx): finance view · Browsable transaction detail with weekly grouping and rows. · `src/components/Transactions/index.jsx`
- [Stats and budget](https://github.com/tnguyen14/ledge/blob/main/src/components/GlobalStats/index.jsx): finance dashboard · Aggregate statistics, cashflow chart, and budget status. · `src/components/GlobalStats/index.jsx`
- [Cashflow and recurring](https://github.com/tnguyen14/ledge/blob/main/src/components/Cashflow/index.jsx): finance views · `src/components/Cashflow/index.jsx`

### State and data

Central state, derived views, and API boundary.

- [Central store](https://github.com/tnguyen14/ledge/blob/main/src/store.js): Redux state · Holds application, form, metadata, and transaction domains. · `src/store.js`
- [Transaction state](https://github.com/tnguyen14/ledge/blob/main/src/slices/transactions.js): state slice · `src/slices/transactions.js`
- [Metadata state](https://github.com/tnguyen14/ledge/blob/main/src/slices/meta.js): state slice · `src/slices/meta.js`
- [Financial selectors](https://github.com/tnguyen14/ledge/blob/main/src/selectors/transactions.js): derived data · Derives transactions, weekly groups, and statistics. · `src/selectors/transactions.js`
- [Authenticated API client](https://github.com/tnguyen14/ledge/blob/main/src/util/api.js): data gateway · Fetches finance data from the JWT-authenticated backend. · `src/util/api.js`
- [Transaction domain logic](https://github.com/tnguyen14/ledge/blob/main/src/util/transaction.js): transformations · Shapes transactions and handles merchant behavior. · `src/util/transaction.js`
- [Budget context](https://github.com/tnguyen14/ledge/blob/main/src/contexts/budget.js): cross-cutting context · `src/contexts/budget.js`

### Delivery and operations

Build, deployment, CI, and backend maintenance.

- [Build and deployment](https://github.com/tnguyen14/ledge/blob/main/vite.config.js): Vite, Docker, Vercel · Builds the SPA and supports containerized and hosted deployment. · `vite.config.js`
- [CI/CD](https://github.com/tnguyen14/ledge/blob/main/.github/workflows/cicd.yml): GitHub Actions · Runs delivery and production testing workflows. · `.github/workflows/cicd.yml`
- [Backend maintenance scripts](https://github.com/tnguyen14/ledge/blob/main/bin/find_transactions.js): JWT operations · Query and update backend transactions and metadata. · `bin/find_transactions.js`

### Other components

- **Authenticated API server**: external backend · Separate backend serving financial data.

## Connections

- Browser entry → Application shell: mounts
- Application shell → Login and user controls: unauthenticated access
- Application shell → Header menu: renders
- Application shell → Notifications: renders
- Application shell → Transactions: coordinates
- Application shell → Stats and budget: coordinates
- Application shell → Cashflow and recurring: coordinates
- Application shell → Central store: uses
- Central store → Transaction state: contains
- Central store → Metadata state: contains
- Transaction state → Financial selectors: source state
- Metadata state → Financial selectors: source state
- Financial selectors → Transactions: transaction and week views
- Financial selectors → Stats and budget: statistics and summaries
- Budget context → Stats and budget: budget data
- Authenticated API client → Authenticated API server: JWT requests
- Authenticated API client → Central store: loads data
- Transaction domain logic → Transaction state: shapes records
- Backend maintenance scripts → Authenticated API server: JWT query and updates
- CI/CD → Build and deployment: builds and deploys
