Architecture

Share links

How a whole bill fits in a URL fragment, and why that means no server ever sees it.

"Copy link" produces something like:

https://splitmize.example/s#zXZDPSsNAEMZfJcz5a5nZrXXTg2jr0YOIJ5c9TNNYA0k2JFakNx9F…

Everything after # is the bill. Browsers never send the fragment in HTTP requests, so the server that serves /s only ever sees /s — it can't log, store or leak the contents. Opening the link decodes it in the browser and shows a read-only view where each friend picks "who are you?" and sees their share, what they owe to whom, and the Pix code.

Format

src/lib/share-link.ts:

token = version + payload
  "z" + base64url( deflate-raw( JSON(compact) ) )   when CompressionStream supports deflate-raw
  "j" + base64url( JSON(compact) )                  fallback

toCompact(bill) rewrites the bill as nested arrays and replaces person ids with indexes:

[1, id, title, currency, createdAt,
  people:      [[name, color], …],
  items:       [[name, quantity, price, [portions per person…]], …],
  adjustments: [[label, kindIndex, value, proportional, discount, [person indexes], presetIndex], …],
  payment:     [0] | [1, payerIndex] | [2, [paid per person…]],
  settled:     ["1>0", "3", …],
  pix:         [[personIndex, key, city], …]]

A typical four-person, five-item bill becomes a ~330-character URL. Compression support is feature-tested by constructing a CompressionStream('deflate-raw') (Chrome 103+, Safari 16.4+, Firefox 113+).

Decoding is defensive

Links come from strangers. fromCompact treats every field as untrusted: it type-checks, clamps lengths (names to 40 characters, at most 100 people and 500 items), clamps numbers, regenerates internal ids and falls back to safe defaults. A malformed link shows "This link didn't open" instead of throwing. Nothing from the link is ever rendered as HTML.

Saving a shared bill

"Save to my Splitmize" stores the decoded bill in local history. The bill keeps its original id, so saving the same link twice overwrites instead of duplicating. "Open in the app" saves and switches to it.

Limits

  • A shared link is a snapshot. If the organizer edits the bill afterwards, they need to send a new link. (Live sync would require a server, which this project deliberately doesn't have — see ADR 0003.)
  • Messaging apps sometimes truncate very long URLs. Bills with dozens of items still fit comfortably, but the compact format exists precisely to keep links short.
Edit this page on GitHub