Containerfile + compose (app + Caddy with automatic HTTPS), env-driven domain/limits/ports, VAPID key generation that never prints the key. SPEC updated to match the implementation (Node stdlib server, Svelte SPA, revert by event id, backup contents, push options). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
59 lines
2.9 KiB
Markdown
59 lines
2.9 KiB
Markdown
# AGENTS.md — OweMe
|
|
|
|
End-to-end encrypted group expense splitter (a Settle Up clone). Read
|
|
`SPEC.md` first; it is the source of truth for behaviour and is kept current.
|
|
|
|
## Layout
|
|
- `packages/core/` — pure TypeScript shared by client and service worker:
|
|
event schema, validation, money math, replay/rewind, settle-up, recurring,
|
|
stats, CSV. **No I/O, no floats for money.**
|
|
- `apps/server/` — Node 24, **standard library only** (`node:http`,
|
|
`node:sqlite`, `node:crypto`), run directly as TypeScript (type stripping:
|
|
erasable syntax only, `.ts` import extensions). No npm dependencies; keep it
|
|
that way unless there's a strong reason.
|
|
- `apps/web/` — Svelte 5 SPA + service worker (`src/sw.ts`, built separately
|
|
by `vite.sw.config.ts` as a classic script).
|
|
- `deploy/` — Containerfile, compose.yaml, Caddyfile, `.env.example`, deploy docs.
|
|
- `e2e/` — Playwright tests against the production build.
|
|
|
|
## Run
|
|
Node lives at `~/.local/node/bin` on the dev box (not on PATH by default).
|
|
|
|
```sh
|
|
npm ci
|
|
npm run dev # API 127.0.0.1:8481 + Vite 127.0.0.1:8480
|
|
```
|
|
Preview from your machine: `ssh -p 14922 -L 8480:localhost:8480 <dev box>`,
|
|
then http://localhost:8480.
|
|
|
|
## Test
|
|
```sh
|
|
npm test # core (vitest) + server (node:test)
|
|
npm run check # tsc + svelte-check (must be 0 errors, 0 warnings)
|
|
npm run build && npm run test:e2e
|
|
```
|
|
E2E uses the Playwright browsers cached in `~/.cache/ms-playwright`
|
|
(`@playwright/test` is pinned to 1.63.0 to match them). `e2e/push.spec.ts`
|
|
needs full Chromium (`channel: 'chromium'`): the headless shell denies
|
|
notifications.
|
|
|
|
## Invariants — do not break
|
|
1. **The server never sees plaintext or keys.** The group secret exists only
|
|
in the URL fragment, IndexedDB and backup files. Never send it in a path,
|
|
query string, header or log line. The server stores `SHA-256(authToken)`.
|
|
2. **Every client computes identical balances.** Money is integer minor units;
|
|
rates are decimal strings; rounding is largest-remainder with ties to
|
|
member order, conversion is round-half-even (BigInt). Any change to money
|
|
math needs a test in `packages/core/test/`.
|
|
3. **The event log is append-only.** Undo is a new event (`revert`,
|
|
`expense.restored`, …), never a deletion. Replay must ignore invalid
|
|
events (`validateExpense`), not crash.
|
|
4. **New event types** go in `types.ts` (`EventBody`), `replay.ts` (with
|
|
validation), the activity text in `Activity.svelte` and both locale files.
|
|
5. **i18n:** every string in `locales/en.ts` and `locales/cs.ts` (the type
|
|
enforces it). English is the default; Czech only if the browser prefers it.
|
|
6. **Push endpoints** are restricted to the allowlist in `push.ts` (no SSRF).
|
|
Push payloads carry only the group id.
|
|
7. Strict CSP: no inline scripts, no third-party origins.
|
|
8. Containers: rootless Podman; for local testing publish to `127.0.0.1` only
|
|
(`BIND_ADDR=127.0.0.1` in `deploy/.env`).
|