Skip to content
DetweilerRyanPublic

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

501 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SplitSmart P2P

A collaborative receipt splitter built with Next.js, React, TypeScript, and Yjs. Room data is persisted locally with IndexedDB and synchronized between peers with WebRTC by default, with optional Liveblocks-hosted synchronization.

This README is a person's entry point: it gets the project up and running with agents in as few steps as possible.

Optional Liveblocks sync

To use Liveblocks-hosted Yjs sync and persistence instead of WebRTC, set NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY before building or running the app. Set it to a Liveblocks public key, such as pk_prod_…. No application backend is needed; without this setting, or with it blank, the app keeps using its existing P2P sync. Any other value fails the build, with an error naming the variable: the key must start pk_ and contain no spaces.

Public-key mode is client-only and does not authenticate users or restrict access to individual rooms. New room links use a random UUID encoded in the URL to make rooms difficult to discover, but this is obfuscation—not authorization or encryption. Anyone who obtains a room link can access its data. Use it only for non-sensitive receipts; private rooms require Liveblocks token authentication through a trusted backend.

Getting started

Install and set up sbx (first time only)

Agents run in a Docker Sandbox, which the sbx CLI manages. Install sbx 0.53 or newer on the host; Docker Desktop isn't needed. Docker's install guide lists each system's requirements, such as virtualization.

macOS:

brew trust docker/tap
brew install docker/tap/sbx

Windows:

winget install -h Docker.sbx

Ubuntu:

curl -fsSL https://get.docker.com | sudo REPO_ONLY=1 sh
sudo apt install docker-sbx

Then sign in to Docker, choose the Balanced network policy, and turn on image paste, so you can paste screenshots to an agent:

sbx login
sbx policy init balanced
sbx settings set clipboard.imagePaste true

Give every sandbox your GitHub token, so agents can push and open pull requests. Install the GitHub CLI on the host, then sign in with it. The sign-in adds the scopes the dev container's GitHub extension needs. The token stays on the host, as Sandbox secrets explains.

gh auth login -h github.com -s read:user,user:email
sbx secret set github -t "$(gh auth token)"

Clone the repository

Clone the repository to a <path> of your choice on the host, then change into it:

git clone https://github.com/DetweilerRyan/split.git <path>
cd <path>

Start a sandbox

The sandbox kit runs an agent in an isolated sandbox with the dependencies installed. To create one, run this from <path>:

sbx run --clone --name <name> claude --kit ./.sbx-kits/splitsmart .

<name> can be any name you choose. It identifies the sandbox in every later sbx command. For example:

sbx run --clone --name splitsmart claude --kit ./.sbx-kits/splitsmart .

The first time Claude Code starts in a sandbox, sign in with /login. To use an API key instead, store it on the host with sbx secret set anthropic before creating the sandbox.

To return to an existing sandbox, running or stopped, run this from any folder. sbx ls lists your sandboxes' names.

sbx run --name splitsmart

Dev container

The dev container runs inside a sandbox, so create the sandbox first. The dev container README explains each step.

  1. Install VS Code's Remote - SSH and Dev Containers extensions.
  2. On the host, run sbx setup ssh.
  3. With Remote - SSH, connect to <name>.sbx, using your sandbox's name, such as splitsmart.sbx.
  4. Open <path>, the path you cloned the repository to on the host. A Windows <path> such as C:\Users\me\split opens as /c/Users/me/split.
  5. Choose Dev Containers: Reopen in Container.

Deploying

Vercel auto-detects Next.js; use its default build command and output with no vercel.json or SPA rewrites. The app uses Next.js's default server/hybrid deployment, and its pages are statically prerendered and /api/mcp is served on demand. Configure NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY in the Vercel Preview and Production environments only if using Liveblocks; it is client-exposed. WebRTC signaling uses the public signaling servers unless NEXT_PUBLIC_WEBRTC_SIGNALING_URLS lists others, as wss:// or ws:// URLs, comma-separated, before building; leave it unset on Vercel. An entry that isn't a wss:// URL, or a ws:// one to localhost, fails the build, with an error naming the variable and the entry. NEXT_PUBLIC_LIVEBLOCKS_BASE_URL points the browser at a Liveblocks server other than Liveblocks' own, as an http:// or https:// URL; leave it unset on Vercel. The end-to-end tests set it to Liveblocks' local dev server, as End-to-end testing says. src/env.ts checks these variables. Room and ingest URL fragments and query parameters are handled client-side; ingest links live at /ingest (old root-level ingest links are forwarded there).

MCP server

/api/mcp is an unauthenticated remote MCP server (Streamable HTTP). The create_receipt_room tool validates a receipt seed with the shared zod schema in src/domain/receipt/receiptSeed.ts (its field descriptions are the extraction rules agents see) and returns an /ingest link; the room is created when the link is opened. skill://receipt-generation/SKILL.md serves the skill file. POST bodies are capped at 64 KB (413), and tools/call is limited to 30/min per client IP (IPv6 by /64) with a JSON-RPC 429 and Retry-After. The in-app limiter is per-instance and best effort. The per-IP limit across instances is a Vercel Firewall rule. vercel/firewall.json holds the project's whole firewall configuration, and the Firewall workflow applies it, replacing whatever the dashboard holds. Try it with npx @modelcontextprotocol/inspector against http://localhost:3000/api/mcp.

Room IDs use the urn:split:room:<uuid> format and are base64url-encoded in the URL path (/r/<room>); links to rooms created before that format still work when their id has the form the app generated then, split- and one to four base36 characters. Any other room id is rejected: a room path redirects home, and a #room= link opens a new room. Room ids are typed as RoomId, defined in src/domain/room/roomId.ts with the functions that create and parse them; only parsing produces one. Receipt seeds can be shared as compressed URL hash parameters. Claims are stored as flat itemId::participantId values in Yjs so independently hydrated rooms can merge claims without replacing nested item data.

Currencies

Each receipt room stores an ISO 4217 currency (default USD, so legacy rooms and links without one open as USD). It is synced through Yjs and included in receipt seeds. The app shows amounts and the rate in the viewer's number format, through Intl.NumberFormat. A field shows an amount with at least its currency's decimals, such as 12,50 in German, and a rate as stored. Splitting uses integer minor units, by the currency's exponent (JPY 0, USD 2, KWD 3), with remainders distributed deterministically so shares add up exactly. New blank rooms default to the locale's currency.

Optionally choose a display currency in the edit drawer to see each share converted. Rates come from Frankfurter (ECB data, no API key) fetched client-side and cached in IndexedDB; the rate and its date are stored on the receipt so all peers see identical values. Offline, with no cached or stored rate, amounts show in the receipt currency only. The rate can also be edited manually.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages