How tnguyen14/ledge works
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: index.jsx Application shell · store.js Central store · selectors/transactions.js Financial selectors · slices/transactions.js Transaction state
Components 19
React client
Browser SPA composition and finance views.
- Browser entry
src/index.jsx - Application shell · Coordinates authenticated layout, navigation, and feature views.
src/components/App/index.jsx - Login and user controls
src/components/Login/index.jsx - Header menu
src/components/Header/index.jsx - Notifications
src/components/Notification/index.jsx - Transactions · Browsable transaction detail with weekly grouping and rows.
src/components/Transactions/index.jsx - Stats and budget · Aggregate statistics, cashflow chart, and budget status.
src/components/GlobalStats/index.jsx - Cashflow and recurring
src/components/Cashflow/index.jsx
State and data
Central state, derived views, and API boundary.
- Central store · Holds application, form, metadata, and transaction domains.
src/store.js - Transaction state
src/slices/transactions.js - Metadata state
src/slices/meta.js - Financial selectors · Derives transactions, weekly groups, and statistics.
src/selectors/transactions.js - Authenticated API client · Fetches finance data from the JWT-authenticated backend.
src/util/api.js - Transaction domain logic · Shapes transactions and handles merchant behavior.
src/util/transaction.js - Budget context
src/contexts/budget.js
Delivery and operations
Build, deployment, CI, and backend maintenance.
- Build and deployment · Builds the SPA and supports containerized and hosted deployment.
vite.config.js - CI/CD · Runs delivery and production testing workflows.
.github/workflows/cicd.yml - Backend maintenance scripts · Query and update backend transactions and metadata.
bin/find_transactions.js
Other components
- Authenticated API server · Separate backend serving financial data.
Connections 20
- 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