Repository avatar
Communication
v0.7.0
active

subetha

io.github.curtcox/subetha

Publish to and receive from SubEtha topics, and read and post in SubEtha Chat workspaces.

Documentation

subetha

Messaging platform: send and receive ntfy-style messages between any devices over any transport (IP, push, email, Slack, SMS/voice, MCP, Reticulum, Bluetooth, audio, QR/video), without devices needing to know about each other or how messages are relayed.

Production: https://subetha.us · Docs: docs/ (published at https://subetha.us/docs/ and https://curtcox.github.io/subetha/) · Build info and pricing report: https://curtcox.github.io/subetha/build-info.html

See PLAN.md for the design, status, remaining work and open questions, and CHANGELOG.md for what changed.

curl -H "Authorization: Bearer $SUBETHA_TOKEN" -d "Backup done" https://subetha.us/@me/backups
curl -H "Authorization: Bearer $SUBETHA_TOKEN" https://subetha.us/@me/backups/json   # stream

What's here

  • Relay (workers/api): one Cloudflare Worker. ntfy-compatible publish and subscribe, a Durable Object per topic and per account (prepaid ledger), D1, KV, R2, Queues and a daily cron; the /v1 control plane (accounts, tokens, policies, endpoints, subscriptions with escalation, traces, dry runs, billing, devices through devicebasedauth.org, transforms, ingest); delivery over Web Push, APNs, FCM, webhooks, email, Slack, Discord, Telegram, Matrix, MQTT, Twilio SMS/MMS/WhatsApp/voice, MCP, LXMF and Meshtastic.
  • SDKs (sdk/): TypeScript (plus CLI and web components), Python, a Rust core with UniFFI bindings, Swift, Kotlin, Flutter and React Native, all passing the shared vectors in spec/vectors; sample apps for each in samples/.
  • Gateways (gateways/): Reticulum/LXMF, MQTT, and Meshtastic/LoRa bridges, plus an APNs HTTP/2 relay.
  • Site (apps/site): landing page, web console, docs, pricing calculator, route simulator, API explorer and the Edge lab (sound, QR and Bluetooth between browsers).
  • SubEtha Chat (apps/chat, at /chat/): Slack-style channels, threads and DMs whose rooms are topics (docs/chat.md).
  • Pricing (pricing/): generated price table with margin invariants enforced in CI.

Repository layout

spec/             protocol spec, JSON Schema, errors.json, OpenAPI 3.1, conformance vectors (+ tests)
pricing/          costs.yaml, fixed-costs.yaml, price generator, invariant tests, generated/ report
workers/api/      the relay Worker: src/ (Hono app, Durable Objects, delivery senders, MCP, devices,
                  cron, inbound email), migrations/ (D1), test/ (Miniflare tests), wrangler.jsonc
sdk/js/           TypeScript SDK, CLI (`subetha`), web components (sdk.js), Web Push helper
sdk/python/       Python SDK
sdk/core/         Rust core (protocol, store-and-forward, routing, edge transports, FFI)
sdk/swift/ sdk/kotlin/ sdk/flutter/ sdk/react-native/   mobile SDKs (see sdk/core/BINDINGS.md)
sdk/flutter_core/ Flutter plugin: the Rust core through flutter_rust_bridge
sdk/react-native-core/ React Native Turbo Module: the Rust core through uniffi-bindgen-react-native
gateways/reticulum/  Python Reticulum/LXMF gateway
gateways/mqtt/       Python MQTT bidirectional gateway
gateways/meshtastic/ Python Meshtastic/LoRa bidirectional gateway
gateways/apns-relay/ HTTP/1.1 → HTTP/2 relay for APNs (Node, no dependencies)
apps/site/        landing page, web console, tools (src/ → tools.js), docs builder (build.mjs)
apps/chat/        SubEtha Chat web app (Preact, signals, CodeMirror; Vite → apps/site/public/chat)
docs/             developer docs (Markdown), samples/ (runnable, CI-tested), legal/ (drafts)
infra/            Cloudflare setup, secrets manifest, zone notes
e2e/              Playwright tests: the console and SubEtha Chat against the relay under wrangler dev
scripts/          file-size check, load test, D1 restore from nightly backups
.github/workflows ci.yml, mobile.yml, pages.yml, deploy.yml, deploy-env.yml, nightly.yml, release.yml, file-size-check.yml

Tests

pnpm install
pnpm -r typecheck
pnpm -r test                 # spec, pricing, TS SDK, relay (Miniflare), docs samples
cargo test --workspace       # Rust core (+ builds the Rust docs sample)
pip install -e "sdk/python[test]" -e "gateways/reticulum[test]"
pytest sdk/python gateways/reticulum
pnpm --filter @subetha/e2e exec playwright install chromium   # once
pnpm --filter @subetha/e2e e2e   # console E2E: builds, starts wrangler dev on :8788, drives Chromium

pnpm vectors and pnpm pricing regenerate the conformance vectors and the price table; CI fails if the committed copies are stale.

Local development

pnpm install
pnpm --filter @subetha/sdk build     # builds sdk.js into apps/site/public
pnpm --filter @subetha/site build    # docs, llms.txt, openapi.yaml into apps/site/public
pnpm --filter @subetha/chat build    # SubEtha Chat into apps/site/public/chat
pnpm --filter @subetha/api exec wrangler d1 migrations apply DB --local
pnpm --filter @subetha/api dev       # wrangler dev on http://localhost:8787

curl -X POST localhost:8787/v1/dev/bootstrap -d '{"secret":"local-dev-only","handle":"me","credit_usd":5}'
# → {"account_id":"…","handle":"me","token":"se_…"}
curl -H "Authorization: Bearer se_…" -d "hello" localhost:8787/@me/test

Open http://localhost:8787/console/ and sign in with the token. Provider secrets for local testing go in workers/api/.dev.vars (see infra/secrets.md). Deploying: infra/README.md.

File size limits

Pushes are checked (locally with git config core.hooksPath .githooks, and in CI by .github/workflows/file-size-check.yml) so large files stay out of history. Limits depend on type, from 200 KB for SVG and 500 KB for source and text up to 10 MB for audio and video; scripts/check-file-sizes.sh --list-defaults prints them. Exceptions go in the committed .filesize-allow (for example assets/hero.png 3MB).

scripts/check-file-sizes.sh --range origin/main..HEAD   # commits not yet on main
scripts/check-file-sizes.sh --tree                      # every file at HEAD

No installation packages available.

Remote

streamable-http
https://subetha.us/mcp