Layout, from the approved mock: - Group header on Expenses/Balances: my balance as the headline number (Money component de-emphasises currency and decimals), total spent, and round quick actions Add / Payment / Settle up / Share. The floating + shows only once those scroll off screen. - Expense rows on two lines (title | amount, payer | my part) with round icons tinted per category; sentence-case section headings. - Balances: larger avatars, paired avatars on settle-up rows, tinted button. Bugs found in a screenshot pass (phone 320/390, desktop 1280; dark, black, light; English and Czech): - A long title or member name widened the group page past the screen and phones zoomed out (grid tracks without minmax(0, ...)); same in Stats. - Long titles were clipped mid-word with no ellipsis. - Category emoji nearly invisible on its grey circle in the light theme. - Stats period labels wrapped (en) or ran off screen (cs); shortened. - Icons next to wrapping text were squashed (lock on Home/App settings). - Dialogs opened with a focus ring on the close button after a tap. - New expenses always defaulted to Food & drink; now the group's default category (settable in group settings), else Other. e2e: the Balances check now targets the Settle up heading, which the new quick action shares its text with. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HA82gVKYyo9BHLHPW4qr4x
25 KiB
OweMe — Specification
A mobile-first, end-to-end encrypted group expense splitter (a Settle Up clone) that runs in any browser, on phones and desktops alike.
Status: v1, implemented · Last updated: 2026-10-09
1. Goals and non-goals
Goals
- Track shared expenses in groups and show who should pay whom.
- End-to-end encrypted: the server stores only ciphertext and never sees group names, members, amounts, notes or photos.
- All calculations happen client-side (splits, conversions, balances, settle-up, statistics).
- Works great on a phone, equally well on desktop, installable as a PWA, usable offline.
- Multiple currencies with exchange rates prefilled from daily reference rates.
- Czech and English UI; dark and light "money green" theme.
- Trivial self-hosting on a VPS via podman compose.
Non-goals (v1)
- User accounts, email, passwords, or recovery of lost group links.
- Per-member permissions (everyone in a group can edit everything; the event log makes every change reversible).
- Native mobile apps.
- Real payments / bank integration.
- Importing from other apps (Settle Up, Splitwise, …).
2. Core concepts
| Term | Meaning |
|---|---|
| Group | A shared ledger. Identified by a random ID; unlocked by a secret key carried in the link. |
| Member | A named person in a group. Not an account — just a name (plus optional colour/emoji). |
| Expense | Someone paid an amount; it is split between some members. |
| Transfer | A member paid another member directly (settling a debt). Same model as an expense with exactly one beneficiary. |
| Event | One immutable, encrypted change to a group (e.g. "expense created"). The group's state is the replay of its events. |
| Base currency | The group's currency for balances and settle-up. |
3. Access model
3.1 Group links
https://<domain>/g/<groupId>#<groupSecret>
groupId: 128-bit random, base64url. Visible to the server.groupSecret: 256-bit random, base64url, in the URL fragment. Browsers never send the fragment to the server (and it is not included inReferer).- From
groupSecretthe client derives, via HKDF-SHA-256:encKey(info"oweme/enc/v1"): AES-256-GCM key for events and blobs.authToken(info"oweme/auth/v1"): bearer token sent to the server. The server stores onlySHA-256(authToken)and requires the token for every read/write of that group. Knowing thegroupIdalone gives nothing.
- Sharing = sending the link (chat, QR code shown in the app).
- Losing every copy of the link means the group is unrecoverable. The UI says so on creation and offers "copy link", "show QR" and "export backup".
3.2 Groups remembered on the device
- Every group opened on a device is saved locally (IndexedDB):
groupId,groupSecret, cached name, chosen identity, cached events, last synced sequence number. - The home screen lists these groups (name, my balance, last activity) so the user can browse them without the link.
- "Remove from this device" deletes the local copy only; the group lives on.
- Note: keys are stored unencrypted in the browser's storage. Anyone with access to the unlocked device/browser profile can open the groups. (A device-level PIN lock is a possible later addition.)
3.3 Identity ("who are you?")
- On first opening a group on a device, the user picks themselves from the member list (or adds themselves as a new member).
- The choice is remembered per group per device, and can be changed in group settings ("I'm not Anna").
- The identity is used for: "you owe / you are owed" wording, defaulting the payer on new expenses, attributing events in the history ("Anna edited…"), and push notification filtering.
- Identity is not authentication — anyone with the link can pick any name. This is an accepted trade-off of the no-accounts model.
4. Data model
All amounts are integers in minor units of their currency (ISO 4217 exponent: CZK/EUR/USD = 2, JPY = 0, …). Never floats.
4.1 Event envelope
Stored by the server:
{
"seq": 1042, // assigned by server, strictly increasing per group
"id": "uuid-v7", // assigned by client (idempotent retries)
"deviceId": "random", // so a device can skip notifying itself
"iv": "base64url", // 96-bit, random per event
"ct": "base64url", // AES-GCM(encKey, plaintext, aad = groupId|id)
"createdAt": "server timestamp"
}
Decrypted plaintext:
{
"v": 1, // schema version
"type": "expense.created",
"actor": "memberId|null",
"at": "2026-10-09T12:00:00Z", // client clock
"data": { ... }
}
4.2 Event types
| Type | Data |
|---|---|
group.created |
name, baseCurrency, icon |
group.updated |
name / baseCurrency / icon / defaultCategory |
member.added |
memberId, name, colour |
member.updated |
memberId, name / colour |
member.archived / member.restored |
memberId (only allowed with zero balance; history kept) |
expense.created / expense.updated |
full expense object (see 4.3) |
expense.deleted / expense.restored |
expenseId |
comment.added / comment.deleted |
commentId, expenseId, text |
recurring.created / recurring.updated / recurring.deleted |
template (see 7.4) |
revert |
targetId (an event id) — see 6.2 |
Updates carry the full new object (not a diff), so the latest event per
entity fully defines it. Conflicts resolve last-writer-wins by server
seq.
4.3 Expense object
{
"id": "uuid",
"kind": "expense", // or "transfer"
"title": "Dinner",
"category": "food",
"date": "2026-10-08", // when it happened (user-editable)
"currency": "EUR",
"amount": 12050, // 120.50 EUR
"rate": "25.214", // decimal string: 1 EUR = 25.214 base; "1" if same currency
"rateSource": "ecb:2026-10-08", // or "xr:<date>", "manual" (see 8.2)
"payers": [ { "member": "m1", "amount": 12050 } ], // sums to amount
"split": {
"mode": "equal", // equal | shares | exact | percent
"entries": [
{ "member": "m1", "value": 1 }, // equal: 1 = included
{ "member": "m2", "value": 1 },
{ "member": "m3", "value": 0 } // excluded
]
},
"note": "optional text",
"photo": { "blobId": "…", "thumbBlobId": "…", "w": 1600, "h": 1200 } // or null
}
Split value meaning per mode:
| Mode | value | Validation |
|---|---|---|
equal |
1 included / 0 excluded | ≥ 1 included |
shares |
integer weight ≥ 0 (e.g. 2 = double share) | sum > 0 |
exact |
amount in minor units | sum == amount |
percent |
basis points (100 % = 10000) | sum == 10000 |
Multiple payers are supported (payers list); the default UI shows a single
payer with an "add payer" option.
5. Calculations (client-side, deterministic)
All clients must compute identical results from the same events, so every rounding rule is fixed and specified here, and covered by unit tests.
5.1 Splitting with rounding
- Compute each member's exact (rational) share of
amountfrom the split weights. - Floor each share to a whole minor unit.
- Distribute the leftover units one by one by largest remainder; ties
broken by member order in the group (order of
member.added).
Example: 100.00 CZK equally among 3 → 33.34 / 33.33 / 33.33.
5.2 Currency conversion
- Each expense stores the rate it was entered with. Balances never change retroactively when market rates move.
- Conversion to base:
baseTotal = round_half_even(amount × rate)adjusted for the two currencies' exponents. Rates are parsed as exact decimals (no binary floats; use bigint arithmetic). - Per-member shares in base currency: split the already-rounded original
share vector, then convert it to base using the same largest-remainder
method so that the converted shares sum exactly to
baseTotal. Payers are converted the same way.
5.3 Balances
For each member: balance = Σ paid (base) − Σ owed (base) over all non-deleted
expenses and transfers. The sum of all balances is always exactly 0
(asserted in tests).
5.4 Settle-up suggestions
Greedy: repeatedly match the largest debtor with the largest creditor and
transfer min(|debt|, credit). Produces at most n − 1 transfers, usually
the minimum in practice, and is easy to reason about.
- Shown as "Petr → Anna: 450 Kč" cards.
- "Mark as paid" opens a prefilled transfer the user can adjust (partial payments allowed) and confirm.
- Optional display of balances/suggestions in another currency using the current rate (display only, clearly labelled).
6. History and rewind
6.1 History view
- Group-wide activity feed from the event log: "Anna added Dinner · 120.50 EUR", "Petr changed amount 450 → 540 Kč", "Jana deleted Taxi".
- Per-expense history: every version, with a diff of changed fields.
6.2 Rewind
- Restore an expense: undelete, or roll it back to a chosen earlier
version (emits
expense.updated/expense.restoredwith the old content). - Rewind the whole group to a point in time: emits a
revert { targetId }event naming an earlier event. Replay replaces the state with a snapshot taken right after that event, then applies later events normally. Nothing is ever erased, so a rewind can itself be undone (revert to the event just before the revert). Event ids rather than seqs are used so a restored backup, which gets new seqs, keeps working. - The log is append-only on the server; there is no destructive delete API for events (only deleting the entire group, see 8.3).
7. Features
7.1 Groups
- Create group: name, base currency (default by locale: CZK for Czech, EUR otherwise), icon/emoji, initial members.
- Share: copy link, native share sheet, QR code.
- Settings: rename, members, "who am I", default category, remove from device, export, delete group (see 8.3).
- Base currency is locked once the group has any expense or transfer. It
can be changed freely while the group is empty; afterwards the setting is
read-only with a short explanation. Clients enforce this during replay too:
a
group.updatedthat changesbaseCurrencyafter the first expense event is ignored.
7.2 Expenses
- Fast add flow optimised for one hand: amount first (numeric keypad), then title, payer (defaults to me), split (defaults to everyone equally).
- Currency picker with recent currencies first; the rate is prefilled from the daily rate for the expense date and is editable.
- Split editor: equal / shares / exact / percent tabs; tap to exclude people; live "remaining to assign" indicator for exact and percent modes.
- One photo per expense (receipt), see 9.
- Category, date, note.
- Comments thread on each expense.
7.3 Categories
Fixed v1 set with icons: food & drink, groceries, transport, accommodation, entertainment, shopping, utilities, rent, travel, gifts, health, other. Transfers have their own implicit category.
Each group has a default category (group.updated → defaultCategory,
one of the set above; absent means "other") that new expenses start with.
Replay ignores a group.updated whose defaultCategory isn't in the set,
without applying any other field of that event. Each category has an icon
colour (CATEGORY_COLORS in apps/web/src/lib/format.ts).
7.4 Recurring expenses
- A template (expense object + rule: weekly / monthly / yearly, interval, start, optional end).
- There is no server-side worker (the server cannot read templates). When any
member's client opens the group and a due occurrence is missing, it creates
it. The occurrence's expense ID is derived deterministically
(
rec-<templateId>-<occurrenceDate>), so two clients doing it at once produce the same ID;expense.createdis first-wins on replay, so the duplicate is ignored. Deleted occurrences are not recreated. - Occurrences are normal expenses (editable/deletable individually).
7.5 Statistics
Client-side charts per group, filterable by date range:
- Spending by category (bar chart).
- Spending per month (bar chart).
- Per member: paid vs. consumed.
- "My spending" view.
7.6 Export / backup
- CSV export of expenses (one row per expense, columns per member share) and of current balances.
- Backup file (JSON): the encrypted event log and photos exactly as the server stores them, plus the group secret, so a group can be restored even if every link is lost. The file is therefore as sensitive as the link, and the UI says so. Restoring creates the group on the server (or finds it already there) and re-uploads everything; uploads are idempotent by id, so an interrupted restore can simply be run again.
7.7 Push notifications
- Opt-in per group per device (Web Push, VAPID).
- Because the server cannot read events, the push it sends contains no
content, just
{ g: groupId }(itself encrypted to the browser per RFC 8291). The service worker wakes, fetches new events, decrypts them locally and shows "Anna: Dinner · 120.50 EUR". It stays quiet if that group is open and focused. - The server skips the device that created the event (
deviceId). - On/off per group only. An "only expenses involving me" option was dropped: browsers require every push to show a notification, so the worker can't silently discard irrelevant ones.
- The server only delivers to known push services (FCM, Mozilla, Apple, Windows), so a registered endpoint can't make it call arbitrary hosts.
- iOS: works only when the app is installed to the home screen (iOS 16.4+); the UI explains this.
8. Server
The server is deliberately simple: storage, sync, rates, push.
8.1 API
All group endpoints require Authorization: Bearer <authToken>.
| Method & path | Purpose |
|---|---|
POST /api/groups |
Create: { groupId, authTokenHash }. Rate-limited per IP. |
GET /api/groups/:id/events?after=<seq> |
Fetch events after seq (paginated). |
POST /api/groups/:id/events |
Append a batch; idempotent by event id; returns assigned seqs. |
GET /api/groups/:id/stream |
Server-Sent Events: "new seq available" pings for live sync. |
PUT /api/groups/:id/blobs/:blobId |
Upload encrypted photo (size-capped). |
GET /api/groups/:id/blobs/:blobId |
Download encrypted photo. |
POST/DELETE /api/groups/:id/push |
Register/unregister a Web Push subscription. |
DELETE /api/groups/:id |
Delete group, events and blobs (requires typing the group name client-side as confirmation). |
GET /api/rates?date=YYYY-MM-DD |
Daily reference rates (no auth). |
GET /api/config |
Public settings: VAPID public key, size limits (no auth). |
GET /api/health |
Health check. |
Unknown groups and wrong tokens both answer 404, so the API doesn't reveal
which group ids exist.
8.2 Exchange rates
- The server fetches ECB daily reference rates (~30 currencies, from the ECB's own XML feed) every 6 hours and caches them in SQLite. The first run loads the full history (back to 1999) for back-dated expenses; later runs fetch the last 90 days.
- For currencies the ECB doesn't publish (e.g. ALL), the server also fetches
a supplementary EUR-based feed on the same schedule: ExchangeRate-API's
free endpoint (
RATES_EXTRA_URL, defaulthttps://open.er-api.com/v6/latest/EUR; empty turns it off). It has no history, so its daily snapshots accumulate from when the server starts fetching them; one older than a week before the requested date is not used. It is stored apart from the ECB rates, and the ECB rate always wins for a currency both publish.GET /api/ratesmerges the two and returnssources: { CODE: "xr:<date>" }for every supplementary rate. - An expense's
rateSourceisecb:<date>, orxr:<date>when either side of the conversion came from the supplementary feed. The editor labelsxr:rates with a link to exchangerate-api.com (the free tier's attribution requirement). - Clients fetch from our server only, so third parties don't learn users' IPs or currency usage. Clients cache rates offline.
- The currency picker offers only ISO 4217 currencies in circulation
(
ACTIVE_CURRENCIESinpackages/core/src/currencies.ts, hand-maintained; browsers'Intl.supportedValuesOf('currency')includes long-gone codes). Those with a daily rate come first; the rest can be used with a manually entered rate. A group or recent currency that has since been withdrawn stays selectable. - Behind an interface so a paid intraday provider can be swapped in later.
8.3 Storage and limits
- SQLite (WAL) for groups, events, push subscriptions, rates.
- Blobs on disk:
data/blobs/<groupId>/<blobId>. - Limits (env variables, see 13): photo blob ≤ 2 MB (
MAX_PHOTO_BYTES), event ≤ 64 KB (MAX_EVENT_BYTES), per-group storage ≤ 200 MB (MAX_GROUP_BYTES), group creation rate limit (GROUP_CREATE_PER_HOUR). The server enforces the photo limit per uploaded blob; the client keeps a photo and its thumbnail together under it. - Inactive-group retention: none by default (configurable).
9. Photos
- User picks/takes a photo (
<input type="file" accept="image/*" capture>). - Client decodes it, scales it to max 1600 px long edge, plus a 320 px thumbnail, and re-encodes it as WebP (JPEG fallback). Re-encoding through a canvas strips EXIF, including GPS location.
- Each image is encrypted with
encKey(fresh IV) and uploaded as a blob. - The expense references the blob IDs. Viewing downloads, decrypts and caches.
- Deleting/replacing the photo leaves the old blob in place (history can restore it); blobs are garbage-collected only when the group is deleted.
10. Client / UX
10.1 Platform
- Single-page PWA: installable, offline-capable (service worker caches the app shell; IndexedDB caches events, rates and thumbnails).
- Offline edits are queued and synced when the device comes back online.
- Responsive: single column on phones; on desktop, a two-pane layout (group list / expenses on the left, detail/balances on the right).
- Minimum targets: last 2 versions of Safari iOS, Chrome Android, Chrome, Firefox, Safari, Edge.
10.2 Screens
- Home: groups saved on this device, each showing my balance. "New group", "Open link/scan QR".
- Group: on Expenses and Balances, a header with my balance as the headline number ("You're owed / You owe / settled up"; the group total if "who am I" isn't set), the group's total spent, and round quick actions: Add · Payment · Settle up · Share. Tabs: Expenses · Balances (settle up) · Stats · Activity. A floating "+" appears only once the quick actions have scrolled off screen.
- Expense editor (sheet on mobile, dialog on desktop).
- Expense detail: photo, split breakdown, comments, history.
- Group settings.
- App settings: language, theme, notifications.
10.3 Language
- English (default) and Czech.
- Auto-detect: if the browser's preferred language (
navigator.languages) is Czech (cs,cs-CZ, …) use Czech; anything else uses English. The user can override this in settings (remembered on the device). - Numbers, currencies and dates are formatted with
Intlfor the active locale (1 234,50 KčvsCZK 1,234.50); Czech plural forms viaIntl.PluralRules.
10.4 Theme
Three themes, chosen per device in app settings: System (default:
follows the OS between soft dark and light), Dark (soft near-black),
Black (true black, for OLED screens) and Light. Neutral backgrounds;
green is the accent only. Tokens live in apps/web/src/app.css:
| Token | Dark | Black | Light |
|---|---|---|---|
| background | #0A0B0D |
#000000 |
#F2F3F5 |
| surface | #16181C |
#121316 |
#FFFFFF |
| surface-raised | #1F2227 |
#1B1D21 |
#E9EBEE |
| text | #F5F6F7 |
same as Dark | #0D0F12 |
| text-muted | #8B9099 |
same as Dark | #5F6670 |
| accent / you are owed | #3DDC97 |
same as Dark | #0B7549 |
| you owe | #FF9466 |
same as Dark | #B53C0A |
| highlight (sparingly) | #D4AF37 |
same as Dark | #9A7B12 |
Text, muted, accent, owe and danger colours have at least 4.5:1 contrast on every background and surface in each theme. Cards and lists are separated by shade with hairline dividers; controls are pill-shaped; the phone tab bar floats as a pill above the content.
Positive/negative amounts also differ by sign and icon, never by colour alone.
11. Security & threat model
| Threat | Outcome |
|---|---|
| Server/database compromise or leak | Attacker sees group IDs, event counts, sizes, timestamps, IPs. No content. |
| Malicious server operator | Could withhold, reorder or delete events (clients detect seq rollback against their local cache and warn), or serve modified JavaScript — an inherent limit of web-delivered E2E. Mitigation: self-hosting, strict CSP, SRI on all assets, reproducible builds. |
| Leaked group link | Full read/write access to that group. No revocation in v1 (future: key rotation = re-encrypt into a new group). |
| Vandalising group member | Everything is reversible via history/rewind. |
| Lost link on all devices | Data unrecoverable (by design). Mitigated by backups and remembered groups. |
| Device access | Remembered groups are readable from an unlocked browser profile. |
Hardening:
- Strict CSP (
default-src 'self'), no third-party scripts, fonts or analytics; self-hosted assets only. Referrer-Policy: no-referrer, HSTS,X-Content-Type-Options: nosniff.- The secret never appears in a query string, path, log or error report.
Server logs exclude
Authorizationheaders. - WebCrypto only (AES-256-GCM, HKDF-SHA-256); no custom crypto.
12. Tech stack
| Layer | Choice | Why |
|---|---|---|
| Frontend | Svelte 5 + Vite SPA, TypeScript, a ~60-line history router | Small bundle (~65 KB gzipped), simple reactivity; SvelteKit wasn't needed for a static SPA |
| PWA | Hand-written service worker, built as a classic script by a second Vite step | Offline shell, push handling; no Workbox dependency |
| Local storage | IndexedDB (small hand-written wrapper) | Groups, events, outbox, blobs cache; shared with the service worker |
| Charts | Hand-built HTML/CSS bars | Stats tab; no chart library |
| i18n | Small typed dictionary (locales/en.ts, cs.ts) |
EN/CS; the type makes missing translations a compile error |
| Backend | Node 24, standard library only (node:http, node:sqlite, node:crypto), run as TypeScript via type stripping |
No npm dependencies on the server; Node was already on the dev box (Bun would have meant another runtime) |
| DB | SQLite (node:sqlite) |
Zero-ops, single file |
| Tests | Vitest (money math, replay, crypto), Playwright (E2E on mobile + desktop viewports) | Rounding and replay must be bulletproof |
| Proxy/TLS | Caddy | Automatic HTTPS (required for WebCrypto, service workers and push) |
Repo layout (monorepo):
apps/web Svelte client + service worker
apps/server Node API (no dependencies)
packages/core shared: types, event schema, money math, replay, settle-up, recurring, stats, CSV
compose.yaml podman compose deployment (with .env.example)
deploy/ Containerfile, Caddyfile, README
e2e/ Playwright tests
13. Deployment (podman compose, with or without the panel)
compose.yaml (repo root) runs the app service: the Node server, which
also serves the built static client, on port 8080 (PORT) with its data in the
oweme-data volume. It works with zero configuration: VAPID keys are
generated on first start and stored in the volume (vapid.json, mode 600),
and the push contact defaults to https://<site domain>.
Every setting is an optional environment variable, written in compose.yaml
as ${VAR:-default} so it is visible and documented in one place:
MAX_PHOTO_BYTES, MAX_EVENT_BYTES, MAX_GROUP_BYTES,
GROUP_CREATE_PER_HOUR, PORT, VAPID_SUBJECT, VAPID_PUBLIC_KEY /
VAPID_PRIVATE_KEY (pin keys), PUSH_DISABLED.
- With the panel (the main target): the panel clones the repo, finds
compose.yamlat the root, routes the app's domain toapp:$PORTthrough its own Caddy (HTTPS) and passes the Environment tab's variables to compose for${VAR}interpolation. "Pass to every container" must stay off until the panel's injection override stops clashing with variables the compose file sets (podman-compose:can't merge value of [KEY]). - Standalone:
podman compose --profile standalone up -dadds a Caddy container with automatic HTTPS forDOMAIN, published on${BIND_ADDR}:${HTTP_PORT}/${HTTPS_PORT}(defaults all interfaces, 80/443). Settings come from.envnext tocompose.yaml.
Step-by-step instructions, the full settings table, ports for rootless Podman
and backups are in deploy/README.md.
Development (on the dev box): servers bind 127.0.0.1 only; preview over an
SSH tunnel. Ports and commands go in AGENTS.md.
14. Milestones
All five milestones below shipped together in the first implementation (2026-10-09):
- Core: crypto, event log, sync, groups (link + QR), members, identity, expenses with all split modes, balances, settle-up, transfers, remembered groups, EN/CS, dark/light theme, PWA + offline, podman compose deploy.
- Money & media: multiple currencies + rates service, photos.
- History: activity feed, per-expense history, restore, group rewind.
- Extras: comments, categories, statistics, recurring expenses, CSV export, backup/restore.
- Notifications: Web Push.