Replacing My Cash-Flow Spreadsheet with a Ledger App

How I moved my cash flow from a spreadsheet into a ledger app, first on my laptop, then on Cloudflare Workers: the importer, the data model, and backups.

Published Updated 9 min read

I tracked my money in a spreadsheet that started over every period. Each new file opened with the last one's closing balance, transfers took two rows, and the summary tabs were formulas I had to trust. Checking my balance from my phone meant opening a sheet that was never built for a small screen.

In November I replaced it with a small app. The first version ran on my laptop. Eleven days later it moved to Cloudflare Workers, and the laptop copy is gone. This note covers how it stores money, how the old sheets came in with every balance checked, why and how it moved, and the parts I got wrong on the way.

What the Spreadsheet Couldn't Do

The workbook had a tab for transactions, one for accounts, one each for types and categories, a summary, and a wealth tab for savings, stock, gold, and money I had lent. Only two of those held real data: the transactions and the wealth values. Everything else was a rollup.

The trouble was the rollover. Each file covered a period and began with an “Initial Balance” row per account, copied from the previous file. If I mistyped one, the new file was quietly wrong, and nothing compared it with the old one. A transfer between accounts was two rows that had to cancel out. There was no budget and no way to plan for something I was saving toward.

The First Version

The app started on November 11 as a Python 3 server that used only the standard library, a browser interface in plain JavaScript, and JSON files on disk. I had built an invoice tool the same way, which has since been folded into my CRM. For one person's data on one laptop, a stack with nothing to install was enough.

Reaching it from my phone was the weak part. A Cloudflare Tunnel connected a hostname to the laptop, and Cloudflare Access decided who could sign in. It worked only while the laptop was on and online. On November 21 I added systemd supervision for the tunnel, so it would come back on its own after a drop. The next day I moved the whole app to Cloudflare Workers.

How It's Built Now

The interface is React 19, TypeScript, and Vite, with coss ui https://coss.com/ui/docs components, TanStack Router for clean paths such as /transactions?type=expense, and TanStack Query to cache the API and refetch after every write. One Worker checks Access, serves the built interface, and passes /api/* to a single SQLite Durable Object that holds the ledger. Deploys run from GitHub Actions on every push to main: tests, build, then wrangler deploy.

  1. Browser: React with coss ui, one route per screen, inline SVG charts
  2. Cloudflare Access: Email sign-in before any request reaches the app
  3. Worker: Verifies the Access token, serves the interface, routes the API
  4. Durable Object: SQLite rows for each document, the change log, and backups

There is no local copy of the data anymore. npm run dev runs the interface and the Worker together in workerd with an empty local Durable Object. To work with real-looking data, I download a backup from the site and restore it locally.

A few rules in the data model removed most of the spreadsheet's problems, and they survived the move unchanged:

  • Amounts are integer hundredths of a rupiah. A balance with decimals stays exact, and no float rounding creeps into the totals.
  • A transfer is one entry with a from account and a to account. It is never counted as income or expense.
  • An opening balance is its own transaction type, so accounts have no hidden starting number.
  • A wealth holding has a dated history of values, and its current value is the newest point.
  • The rollups are computed. Only transactions, holdings, and settings are stored.

Within a day, entries keep the order I give them. I can drag a row, use the arrow keys on its handle, or move it from the edit dialog. The order never changes a balance or a report.

Importing the Old Sheets

The importer read .xlsx files with Python's standard library, since an xlsx is a zip of XML files. By default it was a dry run: it converted the workbook, merged each pair of transfer rows into one transfer, and compared the account balances and the wealth total with the sheet's own numbers. --apply ran the same checks and wrote nothing if one failed. It also refused to run when data already existed, so I could not import twice by accident.

The rollover needed its own logic. When several files came in, each file's opening balance was compared with the running balance from the file before. If they agreed, the opening row was skipped as a carry-over. If they differed, the importer added a visible “Balance adjustment” entry on the day after the earlier period ended, so every account still ended on the newest sheet's balance. Dropping the difference would have hidden it.

That happened once. Two accounts in my second sheet had opened lower than the first sheet closed, and the import made the gap two entries I can see and delete. Rows the converter had to interpret were printed as notes: an “Other” row is income when positive and an expense when negative, and a transfer with no other side, such as money moved to a foreign-currency pocket, stays a plain entry.

I imported two archived sheets first and then the current one with --append. The result was 349 transactions from late August to November 10 and 8 holdings, and every balance matched the sheets. When the app moved to Workers, that data went up as one push, and the importer was removed with the rest of the Python code. The spreadsheet is retired, so there is nothing left to import.

What It Does

  • The dashboard shows the net total, wealth, the change since yesterday, this month against last month, a budget summary, recent transactions, and top expenses.
  • Transactions can be filtered by search, account, category, type, and dates.
  • Goals break something I am saving for into items, each with a planned cost and what I have put aside so far.
  • Budget sets one monthly limit per expense category and shows each month's spending against it, tightest first.
  • Wealth groups holdings and keeps each one's value history.
  • Reports show a year at a glance, income and expense by month, net worth over time, and a category table.
  • Settings exports transactions as CSV, downloads a JSON backup, restores a backup, and shows who can edit what and the latest 50 changes.

Backups and Edits

The first change of each day keeps a copy of every document under that date, and the newest 30 days stay. A restore first saves the current data as a “before restore” copy, so a restore can be undone from the same screen. The JSON backup is my copy off Cloudflare.

Every successful write adds a row to a change log: the time, the email of the person who made it, the action, and the item. A restore never touches the log, so I can still see who changed something after I roll it back.

If two people edit the same transaction or goal, the save sends the version the screen loaded. When someone else saved that item in the meantime, the server refuses with “Someone else changed this since you opened it.” The Durable Object handles one request at a time, so writes never interleave.

Design

The interface uses coss ui's own components and theme tokens, now that there is a React build. Before the move, I had ported coss ui to plain CSS by hand. There are two deliberate changes from coss: placeholders use the full muted text color, and the dark theme's muted text is a little lighter, so both pass WCAG AA. It uses Geist and Geist Mono only, a neutral palette, and color only where it means something: green for income, red for expenses, and a green-to-red bar for budgets. Form dialogs become bottom sheets on a phone, and so does the sidebar.

Deleting a transaction shows a message with Undo, which puts it back with the same id in the same place, so there is no confirmation dialog for that. Other deletes, such as an account or a goal, ask first in the app's own dialog instead of the browser's.

It took five looks to get there. The first matched this site, an editorial finance style came next, and on November 16 I switched to a hand port of coss ui. On November 19 I cut it down to a compact monochrome dashboard and dropped the extra fonts and the per-category colors. On November 22 the hand port became the real coss ui components.

Who Can Get In

Access lets in only the emails in its policy, with a one-time PIN. The Worker does not rely on Access alone. Every request must carry Access's signed token, and the Worker checks its signature, audience, issuer, and expiry. A token without an email, such as a service token, gets nothing. The workers.dev address and preview URLs are off, so the hostname behind Access is the only way in.

The owner can edit everything. Anyone else Access lets in can view everything and edit only the areas the owner ticks for them under Settings: transactions, goals, budget, wealth, or accounts and categories. The Worker refuses their other writes, and the interface hides the controls they cannot use. Settings stays owner-only.

Safety

Writes need a custom X-Ledger header. A web page on another site cannot send that header without a CORS preflight the Worker never approves, so it cannot change my data. The Worker sends a strict Content Security Policy with no inline scripts or styles; Base UI's one inline style element is switched off and its rule moved into the stylesheet. The owner's email and the Access settings are Worker secrets, so none of them are in the repository. The repository holds no real data, and the 19 unit tests use made-up names and figures.

Limitations

Each document is one row of up to 2 MB in a Durable Object, and the transactions are about 90 KB now, which leaves years of room. Daily backups live in the same Durable Object as the data, so the JSON download is the only copy that survives a problem with Cloudflare itself, and I have to remember to take it. Money lent between people is still recorded as plain income and expense, so the totals match the sheet. A loan feature is not built.

Lessons

Check imported totals against the source

The importer's balance check is what found the gap between two sheets. Without it, the adjustment would have disappeared into the starting balance.

Store a choice instead of guessing it from a name

An early version picked an account's group and a goal item's icon by reading its name. I replaced that with a stored type and an icon picker, and anything saved without an icon falls back to a fixed default.

Check the screen by eye

A chart class once shared its name with a header rule, and the bars broke. Every check that counted elements passed; only a screenshot showed it. I prefix component classes now and check both themes by eye.

Decide where it runs before polishing how it runs

I spent an evening making the tunnel restart itself and replaced it the next day. Once I wanted the ledger on my phone at any hour, a laptop was the wrong host, and the tunnel work only made that clearer.

Settle the design early

Each restyle touched every screen, and there were five in eleven days.

More on Engineering

Want this set up for you?

Tell me what you need. I usually reply within one working day.