ENGINEERING DOCUMENTATION · CURRENT IMPLEMENTATION

Understand the system from browser screen to settlement result.

This page describes the code that exists today. It explains the application layers, browser data lifecycle, finance calculation, export behavior, quality checks and the limits of the current release.

Architecture boundary: Bachelor Finance Manager is a static, browser-only application. GitHub Pages serves the files; workspace data and financial calculations run in the user's browser. There is no backend, account system, server database or cloud synchronization.

01 · SYSTEM CONTEXT

How the parts fit together

The browser is the runtime boundary. The development-time test pipeline is separate and does not run when a visitor uses the app.

Bachelor Finance Manager system architecture GitHub Pages delivers static files to the browser. In the browser, the HTML and CSS interface calls app.js, which coordinates the settlement domain, CSV serializer, localStorage and browser file and print APIs. GitHub Actions and Node tests form a separate quality pipeline. GitHub Pages Static file delivery only BROWSER RUNTIME · UI, data and calculations stay on the user's device Presentation index.html styles.css Application app.js state · events · validation Browser platform FileReader · Blob · URL print · confirm Finance domain src/domain/settlement.js pure paise calculations CSV serializer src/infrastructure/csv.js escaping · formula defense Local persistence localStorage · BFM V5 all saved workspaces app.js also owns JSON backup/import, browser downloads and print orchestration Separate development-time quality pipeline GitHub Actions → Node.js 20 → syntax checks + Node tests Tests cover settlement and CSV modules; this is not a browser runtime service.
Source-verified module boundaries. The dashed browser boundary is intentional: no server-side application or database is part of the current deployment.
02 · MODULE RESPONSIBILITIES

What each layer owns

LayerFiles / APIsResponsibilitiesMust not own
Presentationindex.html, styles.cssLanding screen, dashboard controls, forms, tables, reports, responsive and print stylesFinancial calculations or data persistence rules
Applicationapp.jsApp state, event delegation, validation, workspaces, migration, localStorage, filtering, rendering, import/export and printDuplicating the settlement algorithm
Domainsrc/domain/settlement.jsPaise arithmetic, allocation, paid/owed/net balances, transfer generation and result validationDOM, browser storage, files or network access
Export serializationsrc/infrastructure/csv.jsCSV quoting and spreadsheet-formula prefix neutralizationDownloading files or managing UI events
Browser platformlocalStorage, FileReader, Blob, URL, print, confirmPersistence, file reading/download, print dialog and confirmationsServer-side durability or identity

Important implementation detail: storage is not yet extracted into its own adapter. The application layer calls localStorage directly. Likewise, app.js creates the CSV download; the CSV module only serializes rows.

03 · USER WORKFLOWS

How data moves through the application

01

Load the browser workspace

app.js reads the V5 localStorage key, normalizes the saved state, attempts the V3 legacy migration when needed, then renders the landing screen or active workspace.

02

Validate and record a bill

The form is normalized. Rupees are converted to integer paise, the date and payer are checked, and at least one workspace participant is required before saving.

03

Filter and calculate

Search, month and category filters produce the current expense set. That set feeds the settlement domain and the dashboard summaries.

04

Review and export

The UI renders the ledger, category totals, payer contributions, balances and transfers. CSV exports filtered rows; JSON backs up the complete active workspace.

04 · FINANCIAL DOMAIN

How the settlement calculation works

Money is stored as integer paise. For each expense, the payer is credited with the full amount, while the obligation is divided among the selected participants. The base share is the floor of amount divided by participant count; remaining paise are assigned one each to the first participants in the saved participant order.

Member net position

Net = amount paid − share obligation. A positive result means the member should receive money; a negative result means the member should pay.

Transfer matching

Debtors and creditors are sorted by balance, with member name as a deterministic tie-breaker. The engine repeatedly transfers the smaller outstanding balance.

Filter-aware totals: total spend, paid/owed balances, charts and suggested transfers all use the current filtered expense set. The “Average spend / member” KPI divides filtered spend by all members in the workspace; it is a reference figure only and does not influence settlement.

Money invariant: participant shares must sum to each expense amount, and all member net balances must sum to zero. The app does not execute payments; it only calculates suggested transfers.

05 · DATA MODEL

Workspace and expense records

Root state

One localStorage item holds schema version 5, activeWorkspaceId and a map of all saved workspaces for the current browser profile.

Workspace

A workspace stores its ID, name, owner label, timestamps, ordered member-name list and expense list. Member names act as identifiers; there are no separate member IDs.

Expense

An expense stores its ID, date, payer name, category, description, integer amountMinor and participant-name array.

Calculated results

Paid, owed, net balances, category totals and transfer suggestions are derived in memory. Suggested payments are not stored as ledger entries.

The current schema and migration behavior are documented in the data model document.

06 · PERSISTENCE AND FILES

What gets saved, backed up and exported

OperationScopeBehavior
localStorageAll browser workspacesOne versioned JSON state object under BFM_DATA_SESSION_V5
CSV downloadActive workspace, filtered expensesRows include date, payer, category, description, amount in INR and participants
JSON backupComplete active workspace onlyIncludes workspace details, members and all its expenses plus backup metadata; not every workspace
JSON importOne imported workspaceParsed and normalized in the browser, assigned a new ID and added without overwriting the existing workspace
PrintCurrent visible reportOpens the browser print dialog and uses print-specific CSS

CSV cells beginning with spreadsheet formula characters are prefixed before quoting. JSON backups may contain names and household spending details, so exported files should be kept private.

Import limitation: JSON import normalizes a workspace-shaped file rather than enforcing a signed or strict versioned schema. Newly submitted expense dates are calendar-validated; a non-empty date in a hand-edited import is currently passed through. Do not rely on the importer as a validator for untrusted financial records.

07 · SECURITY AND LIMITS

What this architecture does—and does not—guarantee

Local, not encrypted

Workspace records remain in browser localStorage. It is not encrypted secure storage, and anyone using the same unlocked browser profile may be able to access the records.

No accounts or collaboration

The owner name is a label, not a login. The current version has no access roles, remote database, live multi-user editing or cloud backup.

Backups are important

Browser cleanup, profile loss or storage failure can remove data. JSON export is the user's recovery path; there is no server-side restore service.

Not a payment system

Transfers are recommendations calculated from expense records. No bank connection, payment execution, receipt verification or settlement confirmation exists.

08 · QUALITY AND DEPLOYMENT

How the code is checked and published

The project uses native browser JavaScript modules and has no runtime npm dependencies. Node.js 20+ runs the syntax checks and Node built-in tests. The GitHub Actions workflow runs these checks on pushes to main/refactor branches and pull requests targeting main.

Current automated tests focus on settlement invariants, participant splits, paise remainders, transfer validation, CSV quoting and spreadsheet-formula neutralization. They are not browser end-to-end tests. Responsive behavior, actual localStorage lifecycle, file picker/download and print output still require browser verification.

GitHub Pages serves static files; there is no compile/bundle stage, web server process or database deployment. The site.webmanifest is metadata only: the current repository does not include a service worker or offline cache implementation.

09 · FEATURE TRACEABILITY

Visible feature → implementation

Visible areaImplementation path
Landing, workspace form and saved workspace listindex.html + app.js workspace functions
Roommate list and add/removeindex.html forms + app.js member lifecycle
Expense form and ledgerindex.html + app.js addExpense, filteredExpenses and renderExpenses
Search, period and category filtersapp.js filteredExpenses and renderFilters
KPIs, charts and balancesapp.js renderDashboard, renderCharts and renderBalances
Suggested transferssrc/domain/settlement.js computeSettlement + app.js renderTransfers
CSV downloadsrc/infrastructure/csv.js + app.js exportCsv
JSON backup and restoreapp.js exportJson and importJson
Print reportapp.js window.print + styles.css print rules
10 · SOURCE DOCUMENTS

Explore the implementation