Infrastructure and operations

Surplus runs on managed infrastructure to keep the security surface small and operational burden low.

Hosting

Surplus is deployed on Cloudflare Workers and Containers:

  • The Surplus app — one Cloudflare Worker on one origin serves the web app, its API, authentication, the MCP server, the public impact map, the docs, and stored files (each checked before it is served)
  • Scheduled jobs — each its own Worker, started by Cloudflare Cron Triggers: the analytics cache, and database and file backups, which run in a container

Managed data services

ServiceProviderPurpose
PostgreSQLNeonPrimary database + read replicas
RedisUpstashTwo instances: one for caches, rate limits, and locks, and one for authentication (sign-in codes, refresh token chains, rate limits)
Object storageTigrisUploads and backups (S3-compatible)

External integrations: Stripe (invoicing), Resend (email), and Sentry (observability).

Sub-processors

ProviderRole
CloudflareApplication hosting
NeonPostgreSQL
UpstashRedis
TigrisFile storage and backups
StripeInvoicing / payments
ResendTransactional email
SentryError, crash, and scheduled-job monitoring and alerting (PII kept out, see Data protection)

The dashboards dashboards are part of the same app, and read only from a dedicated analytics replica.

Environment isolation

  • Cookies named and domain-scoped per environment
  • One origin per environment — each environment's app, auth, and files answer on its own host, so no cross-origin access is needed or allowed
  • Error reporting enabled in staging and production only

Secret management

Secrets are stored encrypted, with a key kept outside the source code. A deploy decrypts them and gives each Worker only the secrets it reads, as encrypted Cloudflare secrets, and only the app layer reads them. Reusable packages receive configuration by injection, not from environment variables directly.

The app validates its configuration before a deploy and on first use; missing secrets fail fast rather than shipping a broken deploy.

Network and application controls

Cross-site requests: app API calls and sign-in requests from other sites are refused. The MCP and OAuth metadata, token, and revocation endpoints allow any origin, without credentials, and the public read-only endpoints the website uses (/public) allow only Sharing Excess's own sites.

Security headers: HSTS (one-year max-age, subdomains included), nosniff, and a strict referrer policy on every response. Pages can't be framed by other sites (frame-ancestors 'none'), except the public impact map, which partners embed.

Rate limiting: Global 100 req / 10 s per IP (300 per signed-in admin or advisor); stricter limits on auth endpoints and MCP. See Access control.

Input validation: Every API call's input and output are validated against shared Zod schemas. Database access uses parameterized queries through an ORM.

Error handling: Clients receive safe messages and a requestId — never stack traces.

Monitoring

  • Cloudflare Workers logs — one structured line per server call (procedure, status, duration, user id), without request bodies
  • Sentry — errors and crashes from the web app, its server, and every scheduled job; checks that each scheduled job (including backups) runs and succeeds; alerts to the engineering team. Users are identified only by internal id
  • x-request-id — correlation id on every request, returned on errors for support