SumBuddy

Run your own server

How to put SumBuddy’s split server online on your own accounts, in order. docs/server.md is the contract; this file says which account to make, what to click and where each value goes. Until step 4 everything runs on your computer: the Worker, its database and the live rooms run in wrangler dev, and a debug build of the app talks to it at http://10.0.2.2:8787.

The server is optional. The app tracks your month from SMS without it; only sign-in, splitting with friends, Family and Import from Splitwise need it.

Free plans and console menus change: check each step against the provider’s page when you do it. Some steps cannot be undone (3.2, 6.3), so read a section to the end before you start it.

Placeholders. server/wrangler.toml, server/web/wrangler.toml and gradle.properties in this repository hold the values of the maintainer’s own server (none of them is secret). In your copy, replace each with yours:

Placeholder Meaning Example
<worker> The Worker’s name (name in server/wrangler.toml) sumbuddy-api
<subdomain> Your workers.dev subdomain (1.5) my-name
<db> The D1 database name (database_name in server/wrangler.toml) sumbuddy
<project-id> Your Google Cloud project id (2.1) sumbuddy-123456
<package> app.applicationId in gradle.properties com.example.sumbuddy
<name>, <host> The Pages project name of the friends’ link page and its host (3.1, 3.2) my-split-links, my-split-links.pages.dev

The Worker’s address is then https://<worker>.<subdomain>.workers.dev.

0. Local development (no account needed)

From the repository root:

cd server
npm ci                                # node_modules is git-ignored
cp .dev.vars.example .dev.vars        # local SESSION_SECRET; .dev.vars is git-ignored
npm run db:migrate:local              # creates the local D1 database in .wrangler/ (git-ignored)
npm run dev                           # http://127.0.0.1:8787; the emulator reaches it as http://10.0.2.2:8787
npm test                              # every route, against a local D1 and Durable Object
npm run typecheck

1. Cloudflare: account, database, subdomain, secret

Fills: server/wrangler.toml database_id, the SESSION_SECRET secret.

2. Google sign-in (Google Cloud project, OAuth clients)

Fills: GOOGLE_WEB_CLIENT_ID and GOOGLE_ANDROID_CLIENT_IDS in server/wrangler.toml, app.googleWebClientId.

Which Google account. Use one account for every Google step here and in 6 (Firebase), and check the account picker (top right) in each console before you click. A work or Google Workspace account puts the project under the company’s organization, whose admins control it. Organizations made since May 2024 also block service account keys by default, and 6.6 needs one.

Do this before the first deploy (4): npm run deploy refuses while LINK_HOST and WEB_ORIGIN hold a placeholder.

Fills: LINK_HOST and WEB_ORIGIN in server/wrangler.toml, app.linkHost, the project name the page deploy uses.

4.1 Before the first deploy. Needed: 1.6 (SESSION_SECRET), 2.3 (GOOGLE_WEB_CLIENT_ID) and 3.3 (LINK_HOST, WEB_ORIGIN). Push (6) can come later. After a later change to server/wrangler.toml (FCM_PROJECT_ID, GOOGLE_ANDROID_CLIENT_IDS), run npm run deploy again. A wrangler secret put needs no redeploy.

5. Check the free limits

Before the first link goes to a real person, re-read each page and compare with docs/server.md 8:

6. Push (Firebase, messaging only)

Optional: without push the app works, a little less promptly. It can come after 4.

Fills: FCM_PROJECT_ID in server/wrangler.toml, the FCM_SERVICE_ACCOUNT_JSON secret, the four app.fcm.*.

7. Before a release

8. Watch it

Where each value goes

Value Secret? Where Step
D1 database_id no server/wrangler.toml 1.3
SESSION_SECRET yes wrangler secret put (prod); server/.dev.vars (local, git-ignored) 1.6
GOOGLE_WEB_CLIENT_ID no server/wrangler.toml [vars] and app.googleWebClientId 2.3
GOOGLE_ANDROID_CLIENT_IDS no server/wrangler.toml [vars], comma separated 2.4, 7.1
app.applicationId no gradle.properties; ANDROID_PACKAGE of the page deploy permanent once people install the app
LINK_HOST, WEB_ORIGIN no server/wrangler.toml [vars]; app.linkHost 3.3
Pages project name no PAGES_PROJECT of the page deploy; server/web/wrangler.toml 3.2, 3.3
Worker address no app.apiBaseUrl; API_BASE of the page deploy 1.5, 4.2
FCM_PROJECT_ID no server/wrangler.toml [vars] and app.fcm.projectId 6.3, 6.7
FCM_SERVICE_ACCOUNT_JSON yes wrangler secret put only; the key file is deleted 6.6
app.fcm.applicationId, app.fcm.apiKey, app.fcm.senderId no (API key restricted to the app) ~/.gradle/gradle.properties 6.3
Signing key SHA-1s no Google Cloud Android clients (2.4); the FCM API key’s Android restriction (6.4) 2.4, 6.4, 7.1
Signing key SHA-256s no ANDROID_CERT_SHA256 of the page deploy, which writes assetlinks.json 4.3, 7.1
App download URL no APP_DOWNLOAD_URL of the page deploy 4.3

Your values for the app go in ~/.gradle/gradle.properties or ORG_GRADLE_PROJECT_<name> environment variables, which override the values committed in gradle.properties (the maintainer’s public server; the app.fcm.* values are not committed).