ErasureDocs
Guides

Self-hosting

Run Erasure on your infrastructure — app, Postgres, and worker.

Self-hosting

Source: app_docs/guide/self-hosting.md, app_docs/deployment.md.

Why self-host

Run Erasure on your infrastructure: console, APIs, Postgres, and worker share one codebase.

When to use this page

  • Local production-like deploy
  • Staging / single-tenant cloud
  • First private environments

For the default evaluation path, use Access & setup and app.erasurehq.in.

Runtime architecture

┌─────────────┐     ┌──────────────┐     ┌────────────┐
│  Browser    │────►│  Next.js app │────►│ PostgreSQL │
│  Console+SDK│     │  API routes  │     │            │
└─────────────┘     └──────┬───────┘     └─────▲──────┘
                           │                   │
                    ┌──────▼───────┐           │
                    │ worker       │───────────┘
                    │ rights.delete│
                    └──────────────┘

Compose-oriented flow

  1. Postgres up (bun run dev:up or your Compose file).
  2. bunx prisma migrate deploy
  3. bunx prisma generate
  4. Set env (below).
  5. bun run build && bun run start (or platform Next start).
  6. bun run worker as a second process.
  7. Optional: bun run demo:reseed for the Acme demo workspace.

Environment variables

Required (production)

VariablePurpose
DATABASE_URLPostgreSQL
NODE_ENV=productionSafe defaults + TLS checks
CONNECTOR_SECRETS_KEYAES-256-GCM for connector and Anumati webhook secrets (openssl rand -hex 32)
VariablePurpose
RESEND_API_KEY + EMAIL_FROMRights OTP email
TRUSTED_PROXY_COUNT=1Client IP for rate limits behind LB

Optional / dangerous

VariableNotes
RIGHTS_INTAKE_DEMO_OTPFatal if true in production
ENABLE_LEGACY_DSARFatal if true in production
WEBHOOK_ALLOW_PRIVATE_URLSFatal if true in production
SQL_ALLOW_INSECUREAllows non-TLS SQL URLs (private networks only)
MAIL_PROVIDER=logStaging only—no real email
Razorpay varsBilling — product billing docs

Production startup refuses known-unsafe config.

Database

  • Provider: PostgreSQL only for product data.
  • Migrations: bun run db:migrate:deploy.
  • Backups: use your host’s Postgres backup; restore = restore DB + same secrets key to decrypt connectors.

Workers

bun run worker
ConcernGuidance
Scaling1–2 workers early; claim uses SKIP LOCKED
EgressRestrict to customer DBs/APIs
Stuck jobsOperational Readiness surfaces pending/stuck

Without a worker, Rights deletion jobs stay pending.

Secrets

  • Never commit keys.
  • Losing CONNECTOR_SECRETS_KEY loses ability to decrypt connector/webhook secrets (re-enter secrets).
  • Publishable keys and session tokens are hashed—not recoverable.

Scaling (Beta guidance)

ComponentGuidance
AppSingle instance OK; multi-instance needs shared rate limits later
PostgresPool app + worker connections
WorkerScale horizontally carefully (customer DB pools)

Next

Access & setup · Security · Troubleshooting