Dockmule
A billing tool that turns a month of warehouse work into invoices. Each charge traces back to the work and the rates used to price it.
- Year
- 2026
- Stack
- Go, Postgres, htmx

The problem
A small warehouse stores and ships for a handful of online brands, each on its own rate card. At month end someone exports the activity, prices it line by line and types up the invoices. Tiers, free allowances and minimums get applied differently each month, and when a brand disputes a line the only way to explain it is to rebuild the month by hand.
Dockmule is month-end billing for small third-party logistics warehouses: numbered, taxed invoices for each brand, with every charge traceable to the events and the rate card version that priced it. One warehouse's brands must never be visible to another, an issued invoice has to stay exactly as sent so a mistake needs a credit note, and amounts must be exact to the currency's smallest unit.
My part
I built the billing core on my own, from workspaces and rate cards through the rating calculator, ledger, invoices and credit notes. The app has a working interface built with templ and htmx. The gallery and video show a design comp of the planned interface.
Architecture
One Go binary on Postgres 18. The server renders pages with templ and htmx, sqlc generates typed Go from hand-written SQL, and goose migrations are embedded in the binary. There are 33 tables across 23 migrations, and the job queue is a table: workers claim rows with FOR UPDATE SKIP LOCKED and every handler can safely run twice.
Tenant isolation lives in the database. 23 tables carry a workspace id and sit under forced row-level security, so even the table owner is bound, and requests run as a role that owns nothing and can't bypass it. A filter forgotten in Go returns nothing instead of another warehouse's rows. One test reads the Postgres catalogue to find every table with a workspace column and checks its policy, instead of using a hand-kept list that could drift.
The charge ledger is append-only. Triggers and revoked grants refuse updates and deletes, and a correction is an exact negative reversal beside the original. A pure calculator turns events and the rate card version in force into the entries that should exist, and a rating run compares that with the entries already written and writes only the difference. Minimums and caps are ledger entries too, so they reverse and re-rate like any other charge. Invoice numbers come from a locked counter per workspace, series and year, taken at issue, so numbering has no gaps.
- 33tables
- 23migrations
- 23tables under forced row-level security
Hard parts
Rounding that survives a reversal. A price in ten-thousandths of a minor unit times a quantity in thousandths needs 128 bits. The calculator multiplies on magnitudes with a 128-bit product, rounds half away from zero once, and refuses a result that leaves 64 bits. Working on magnitudes means a charge and its reversal cancel to exactly zero, which the ledger depends on. Tax is a second single rounding on the net and never compounds.
Re-rating without rewriting history. When a rate changes mid-month or a price was wrong, the run writes a reversal and a new entry only for the keys that changed, a reversal alone for a removed key, and nothing for the rest.
Looking a person up before a workspace is known. Sign-in, invitations and resets happen before there is a workspace to scope to, but the identity tables are global. Each lookup is a narrow SECURITY DEFINER function keyed by one exact value, and a test pins the full list of those functions and their callers.
Issuing under concurrency. The number must be gapless when two clerks issue at once, and an invoice must not be issued from a draft that has moved. Issue takes the counter row in one short transaction. The draft shows a fingerprint of its pending entries, and issue is refused if the set changed since. The PDF and the email happen after commit, so the counter row is never held while a PDF renders.
- 128bits to multiply a price by a quantity
- 64bits: a result beyond that is refused
Outcome
Dockmule has no customers, no pilot and no hosted instance. What exists is the billing core, end to end: workspaces from the command line, four roles, rate cards with tiers, free quantities, minimums and caps, hand-entered and CSV-imported events with reversals, drafts, numbered and taxed invoices with PDFs, voiding by credit note, offline payments with cancellation, month and workspace exports, browser smoke tests and an append-only audit trail. It has 1,432 test functions and 12 fuzz targets, most of them on the money paths.
- 1,432test functions, most on the money paths
- 12fuzz targets
Gallery
Design comp of the planned rate-card screen. Design comp of the planned ledger and reversal screen.
