Multi-User Product Design
Status: phase 2 core implemented (accounts, personal and agent tokens, agent linking, the /v1 run intake and per-account data in every service); see MULTI_USER_ARCHITECTURE.md for the system as built. The rest of this design, Razorpay plans included, is still a proposal.
Date: 2026-09-26
Decided: payments use Razorpay.
Where this proposal and the built core differ, MULTI_USER_ARCHITECTURE.md is authoritative: linked agents authenticate with a bearer agent token (ghb_agt_) from a device-flow link rather than a key pair, a run reports logs, results and its completion in batches rather than one summary, isolation is enforced in application code (row-level security is a follow-up), and plans are not enforced yet.
This doc describes how the single-user backup system becomes a product that many people download and use, while the part we host stays small. architecture/ describes the system as it is today and the approved target. It replaces the earlier SaaS and MCP roadmap (removed from the docs archive, kept in git history):
- credentials stay on the user's machine, so there is no server-side connector vault;
- payments use Razorpay instead of Stripe;
- the hosted dashboard never connects to users' own databases.
1. Goals
- Anyone can sign in, download the agent and back up their GitHub accounts in a few minutes, with no
.envfiles, SSH keys or tokens to copy. - Backups go wherever the user chooses: GitHub, any S3-compatible storage (Neon, AWS, R2, B2, MinIO), Google Drive, Dropbox, OneDrive or Box. A run can write to several of them.
- We host only sign-in, the dashboard (stats and history), alerts and billing. Users' code and storage credentials never reach us.
- Plans are enforced per account, so copying the binary gains nothing.
Not in the first version:
- running backups on our servers;
- backing up issues, PRs and other GitHub metadata;
- GitLab and Bitbucket;
- a hosted dashboard that reads a user's own database.
2. Architecture
flowchart LR
subgraph user["User's machine, server or container"]
agent["Agent (github-backup-worker)"]
end
gh[("GitHub: source accounts")]
dest[("User's destinations: GitHub, S3, Drive, Dropbox, OneDrive, Box")]
subgraph ours["What we host"]
cp["Control plane (Go: API, MCP, run intake)"]
dash["Dashboard (Next.js)"]
pg[("PostgreSQL: accounts, runs, plans")]
end
rzp["Razorpay"]
agent -->|clone| gh
agent -->|upload bundles| dest
agent -->|start run, send summary| cp
dash --> cp
cp --> pg
rzp -->|webhooks| cp
| Part | Runs on | Job |
|---|---|---|
| Agent | The user's machine, a server or a container | Finds the repos, clones and bundles them, optionally encrypts the bundles, uploads them, runs on a schedule and reports each run. |
| Control plane | Our host, as one container | Accounts, agent linking, plan checks, run summaries, alerts, Razorpay webhooks and the Box token proxy. |
| Dashboard | Our host | Sign-in, stats, run history, destinations and billing pages. |
| PostgreSQL | Our host, in the same Compose stack | Metadata for every account. It holds no code and no credentials. |
| Observatory (optional) | Our host | AI chat over the user's own run data, using the user's own OpenRouter key. |
There are two modes:
- Hosted (the product). The agent never gets a database connection. It keeps its repo state (the last
pushed_atseen for each repo) in a local state file and talks only to the control plane's API. - Self-hosted. Everything runs on the user's side, as it does today.
DATABASE_URLpoints at the user's own Postgres, and they run their own dashboard with Docker Compose. It needs no account with us.
3. User journey (hosted)
- Sign in on the website with GitHub. Install the Reader app on the accounts to back up.
- Install the agent (section 11) and run
github-backup-worker link. It shows a code, which the user approves in the dashboard. - Add destinations:
login github --profile destinationfor the Writer app;connect s3|drive|dropbox|onedrive|box, where the browser opens, the user signs in and clicks allow.
github-backup-worker setupinstalls the schedule. From then on the dashboard shows every run.
Commands that don't exist yet: connect, setup, restore, copy and self-update. login, github-app create, auth status, link and unlink exist today.
4. Accounts and agents
- Account. The GitHub user id is the account's identity. One account belongs to one person.
- Linking. When linked, the agent creates a key pair. The control plane stores the public key, and the agent signs each request with the private key, which replaces today's shared
INTERNAL_SECRET. - Agent management. The dashboard lists the linked agents and can revoke any of them. Each plan limits how many agents can be linked.
- GitHub and storage logins. These stay in the agent, as today: device flow or a browser sign-in, with the tokens kept in the OS keychain.
5. GitHub Apps
| App | Permissions | Installed on |
|---|---|---|
| Reader | Contents: read, Metadata: read | The accounts and organizations being backed up |
| Writer | Contents: write; in mirror mode also Administration: write and Workflows: write | Only the backup account (in bundle mode, only the backup repo) |
- Why two apps. A GitHub App has one permission set for all its installations, so a single app would make every source account grant write access.
- Tokens. Both are public apps with device flow enabled. The agent gets user access tokens that last 8 hours and refreshes them for up to 6 months. Device-flow tokens refresh without the client secret, so the agent ships no secret.
- Private keys. They stay on the control plane and are never shipped in the agent. Nothing uses them yet; hosted runs will need them.
- Self-hosting.
github-app create(the manifest flow) creates both apps.
Destination layout:
- Bundle mode (today). One repo holds a bundle per source repo. Bundles over 100 MiB are skipped, because GitHub rejects files that large. Every change commits a full new bundle, so the repo only grows.
- Mirror mode (proposed default). One private repo per source repo, updated with
git push --mirror.- It is incremental, can be browsed on GitHub, and restoring is a clone.
- The agent creates each repo with a user token, because installation tokens can't create repos in personal accounts.
- The agent turns off Actions on each mirror, so that pushes don't run the mirrored workflows.
6. Destinations
Changes to the sink interface (today Put, Stat and Delete, plus Commit for batched sinks):
GetandList, which restore, retention and copying need.- A fan-out sink that writes each archive to several destinations. Each destination succeeds or fails on its own.
github-backup-worker copy --from <dest> --to <dest>for switching providers.
| Destination | How the user connects | Access asked for | Limits to handle |
|---|---|---|---|
| S3-compatible: Neon, AWS S3, R2, B2, MinIO | Endpoint, bucket and keys. For Neon, a Neon API key instead: the agent creates the bucket and a storage key through Neon's API. | One bucket | Neon allows at most 5 GiB per object and doesn't enforce lifecycle rules. Downloads count against the project's transfer allowance. |
| Google Drive | Browser sign-in started by the agent (loopback redirect with PKCE) | drive.file | No review is required. Brand verification is only needed to show our name and logo. |
| Dropbox | Same as Drive | App folder | Production approval is needed within 2 weeks of the 50th linked user. |
| OneDrive | Same as Drive | Files.ReadWrite.AppFolder | Needs publisher verification (a Microsoft partner account and our own domain). Upload chunks must be under 60 MiB. |
| Box | Same as Drive, with the token exchange going through our Box proxy | Standard OAuth | The free plan allows 250 MB per file and 10 GB in total. Refresh tokens work only once and expire after 60 days. |
- One-way only. The agent checks every upload against its SHA-256 and applies retention. Destinations are never synced two ways.
- Credentials. Tokens and keys live in the agent's keychain (the existing credentials store). The control plane only sees what the agent reports: the destination, its last success and the bytes stored.
- Box proxy. Box needs the client secret for every token request. A control-plane endpoint adds it and stores nothing.
- Neon sign-in. "Sign in with Neon" would need Neon's OAuth, which Neon offers only to partners with a commercial agreement. Revisit once we qualify.
7. Runs and data
Each run goes like this:
- The agent calls
POST /v1/runs. The control plane checks the plan and the per-account lease, then returns a run id and the runs left. - The agent backs up.
- The agent calls
POST /v1/runs/{id}/summary. For each repo and destination, the summary gives the status, bytes, duration and any error. It contains no code. - The control plane stores the summary in
backup_runsandbackup_results, updates the stats and sends alerts. Alerts are a failure alert, and a "no backup in N days" warning when an agent stops reporting, to the account's Slack, Discord or webhook channels (the product sends no e-mail, ADR 0020).
When the plan ends, the agent's next run is refused (402 PLAN_REQUIRED) until the account pays again; there is no free tier to drop to (decided 2026-11-07, ADR 0022).
New tables:
| Table | Holds |
|---|---|
accounts | GitHub user id, login, email and plan |
agents | Account, name, public key, last seen, revoked at |
destinations | Account, kind, label, last success and bytes stored (no secrets) |
subscriptions | Account, Razorpay subscription id, plan, status and period end |
credit_ledger | Account, change, reason and Razorpay payment id |
razorpay_events | The event id of every processed webhook, so duplicates are ignored |
Changes to existing tables:
account_idand row-level security onbackup_runs,backup_results,execution_logs,analytics_snapshots,backup_run_requests,worker_run_leaseand the observatory's tables.backup_runsalso getscounted.worker_run_leaseholds one lease per account instead of one global lease.worker_repo_stateis only used in self-hosted mode. Hosted agents keep that state locally.
Size: 1,000 accounts × 100 repos backed up weekly is about 100k backup_results rows a week. The history limit caps it (one year for every account; there is no free plan, ADR 0022).
8. Plans and Razorpay
Superseded in part: there is no free plan (ADR 0022, 2026-11-07), and the prices are the cohorts of 000031. The table below is the original proposal, kept for its Pro column:
| Free | Pro | |
|---|---|---|
| Source accounts | 1 | 5 |
| Destinations | GitHub, S3-compatible | All |
| Schedule | Weekly | Daily |
| Runs per month | 5 | 60 |
| History | 30 days | 1 year |
| Alerts | Failures | Failures and missed backups |
| AI chat (own OpenRouter key) | No | Yes |
| Linked agents | 1 | 3 |
- Credit packs: extra runs, bought as one-off payments. Hosted runs will use credits later.
- Which runs count: only runs that finish with at least one repo backed up. Interrupted runs (no summary arrives) and runs that fail before backing anything up are free.
Razorpay:
- Subscriptions for monthly and yearly plans, paid by card, UPI AutoPay or eMandate. Orders and Checkout for credit packs.
- Webhooks are the only source of truth.
- Verify
X-Razorpay-Signature: an HMAC-SHA256 of the raw body, keyed with the webhook secret. - Drop duplicates by their
x-razorpay-event-id. - Handle events that arrive out of order.
- Verify
- Events used:
subscription.activated,subscription.charged,subscription.halted,subscription.cancelled,order.paid,payment.failedandrefund.processed. A subscription is halted after 4 failed charges; the account then drops to Free. - Secrets. The key id and secret and the webhook secret exist only on the control plane.
- Tax. Razorpay is a payment gateway, not a merchant of record. GST invoices, a Letter of Undertaking (LUT) for exports and any foreign VAT are ours to handle.
- International customers. Enable international payments on the account, and confirm with Razorpay that international cards work for subscriptions. If they don't, sell yearly plans as one-off payments.
9. Licensing
- The account is the license. The control plane enforces runs, source accounts and linked agents per plan, so a copied binary is only the self-hosted tool.
- No license checks in the binary. They can be patched out and add nothing.
- Open question: keep the agent proprietary (today's LICENSE), or publish it under FSL-1.1? FSL-1.1 forbids competing commercial use, and each release becomes Apache 2.0 or MIT after two years.
10. Security
- Least privilege:
- the Reader app is read-only;
- storage providers get app-folder scopes;
- the Writer app is installed only on the backup account.
- No secrets in the agent: no private keys and no client secrets.
- Optional client-side encryption of bundles with
age. The key stays with the user, and a lost key means lost backups, so the dashboard must say so. - Hosted-mode protections:
- login is required on every page (today
DASHBOARD_REQUIRE_LOGINdefaults on as soon asGITHUB_OAUTH_CLIENT_IDorJWT_SECRETis set, and off otherwise); - agents sign requests with their own keys;
- row-level security on
account_id; - stored secrets are encrypted with AES-GCM.
- login is required on every page (today
- Privacy. Repository names are the most sensitive data we store. The privacy policy says so, and that we never receive code.
11. Restore and backup quality
- Restore:
github-backup-worker restore <repo> [--at <date>] --to <github-url|dir>. It needsGetandList. - Integrity check (built): every run reads each unchanged archive back and compares its SHA-256 with the state, and
github-backup-worker verifyrestores each archive: a bundle is cloned and checked withgit fsck --full, becausegit bundle verifypasses damaged pack data. A run's page shows a damaged archive (archive_damaged). Still a proposal: showingverify's results in the dashboard. - Smaller uploads: incremental bundles (only the commits since the last backup), with a periodic full bundle.
- Retention: keep 7 daily, 4 weekly and 12 monthly backups. The agent deletes old ones itself, because Neon doesn't enforce lifecycle rules.
- Later: issues, PRs, releases, wikis (
<repo>.wiki.git) and LFS objects. Today only the LFS pointers are saved.
12. Distribution and hosting
- Agent packages: GoReleaser builds, signed (and notarized for macOS). They ship as a Homebrew tap, winget/Scoop, .deb/.rpm and a Docker image, and
self-updatekeeps them current. github-backup-worker setupinstalls the schedule (systemd, launchd, cron or Task Scheduler) from the binary itself. End users no longer needmake setup.- Our hosting: the self-hosted Docker Compose stack (
deploy/selfhost) on the owner's machine: the control plane, the dashboard and PostgreSQL. - No GitHub Actions runners. GitHub's Actions terms forbid offering Actions as part of a commercial service, and using GitHub-hosted runners for work unrelated to the repo's own project.
- Self-hosted bundle: a Docker Compose file with the control plane, dashboard and Postgres, with both apps created through the manifest flow.
- Name: pick a product name that doesn't suggest GitHub makes or endorses it. "for GitHub" is fine as a description.
13. Phases
- Prove the single-user flow.
- Run today's flow against real GitHub.
- Add the Writer app and the fan-out sink.
- Test the S3 sink against Neon Object Storage.
- Multi-user core. Accounts, agent linking, the run API, per-account data, required login, and Razorpay plans and webhooks. Implemented except the plans and webhooks: see MULTI_USER_ARCHITECTURE.md.
- Restore.
Get/List, restore, retention and the monthly check. - Google Drive and Dropbox.
- OneDrive and Box, including the Box proxy.
- Later.
- Hosted runs paid with credits.
- Issue and PR backups.
- Encryption on by default.
- The transfer and rewriter tools as extra features.
14. Open questions
- Hybrid only, or hosted runs from the start?
- A proprietary agent, or FSL-1.1?
- Should interrupted runs count? The proposal says no.
- Default GitHub destination: bundle mode or mirror mode?
- Prices in INR and USD (
000031; there is no free tier, ADR 0022). - The product name.
15. External facts this relies on (checked 2026-09-26)
- Neon Object Storage went GA on 2026-09-17. It is S3-compatible, allows at most 5 GiB per object, and does not enforce lifecycle rules: S3 compatibility. Its OAuth is offered only to partners: OAuth integration.
- GitHub:
- Choosing permissions.
- Refreshing user access tokens: device-flow tokens need no client secret.
- Permissions per endpoint:
POST /user/reposaccepts only user tokens. - Actions terms.
- Brand rules.
- Storage providers: Drive scopes, Dropbox developer guide, Microsoft publisher verification, Box plans.
- Razorpay: Webhook validation, Subscription webhook events, Subscriptions.