MUTATE
// Documentation

Docs

Production deployment

The production site is split across three services.

PartWhereWhat runs there
Web app and APIVercel (www.mutatelab.fun)Next.js pages and API routes
Postgres, Redis and the workerRailwayData, the job queue and background jobs (image generation, round settlement, transaction reconciliation)
Uploaded and generated imagesVercel Blob (private store)Content-addressed image files

The web app and the worker must point at the same Postgres, Redis and Blob store.

Environment variables

Set these on both Vercel (Production) and the Railway worker unless noted.

VariableNotes
DATABASE_URLRailway Postgres. Vercel uses the public connection URL; the worker can use the private one
DATABASE_POOL_MAXConnections per instance. Default 5. Keep it low on Vercel: each serverless instance opens its own pool
REDIS_URLRailway Redis (public URL on Vercel, private on the worker)
BLOB_READ_WRITE_TOKENThe Blob store's token. Without it, images are written to local disk and are lost on Vercel
APP_URL, NEXT_PUBLIC_APP_URLhttps://www.mutatelab.fun, no trailing slash
PUBLIC_METADATA_BASE_URLhttps://www.mutatelab.fun; token metadata URLs are built from it
SOLANA_CLUSTER, SOLANA_RPC_URLS, NEXT_PUBLIC_SOLANA_RPC_URLChain access. Use a dedicated RPC rather than the public endpoint
PROTOCOL_METADATA_AUTHORITYThe protocol wallet's public key. Required to prepare a launch
PROTOCOL_METADATA_AUTHORITY_KEYPAIRThat wallet's secret key (JSON byte array). Sensitive. Needed to execute Forge identity upgrades
TRUST_PROXYtrue on Vercel, so rate limits use each visitor's real address instead of one shared key. Vercel only
DBC_MIGRATION_QUOTE_THRESHOLDDevnet only, SOL pair only: graduation target in SOL, skipping the Jupiter price lookup. Currently 2. Remove it (and set a Jupiter price key) for USDC, stock pairs and mainnet
MUTATE_*, TREASURY_*, DBC_MIGRATION_USD_TARGETAs in .env.example

Signing keys: the protocol metadata authority (signs Forge identity upgrades) and the treasury executor (signs buybacks) can be given as environment secrets, since Vercel and Railway have no key files. Set PROTOCOL_METADATA_AUTHORITY_KEYPAIR and TREASURY_EXECUTOR_KEYPAIR to the JSON array of 64 secret-key bytes (or that JSON base64 encoded), and store them as sensitive variables. The secret wins over the *_KEYPAIR_PATH file path used in local development. The key must match PROTOCOL_METADATA_AUTHORITY. Launching a token only needs the public key.

Railway

The project is mutate in the Cool Hurricane workspace, with three services in the production environment: Postgres, Redis and worker. Everything is in the sfo region, and vercel.json pins the Vercel functions to sfo1 so queries stay close to the database.

  1. Databases. Add Postgres and Redis. Because Vercel is outside Railway's private network, turn on Public Access for each in its Settings, then click Deploy to apply it. This sets DATABASE_PUBLIC_URL and REDIS_PUBLIC_URL.
  2. Worker. The worker is a service with no GitHub link; deploy it from this folder with railway up --service worker. Railway's builder (Railpack) detects a Next.js app, so these variables on the worker override that:
    • RAILPACK_BUILD_CMD=echo skip-next-build skips the website build.
    • RAILPACK_START_CMD=npm run start:worker applies pending migrations, then starts the worker (start:worker in package.json). .railwayignore keeps local data, tests and the Rust files out of the upload (the root Cargo.toml otherwise makes Railway try to build a Rust app).
  3. Worker variables. DATABASE_URL=${{Postgres.DATABASE_URL}} and REDIS_URL=${{Redis.REDIS_URL}} (the private network), plus the shared variables in the table above.
  4. Vercel variables. DATABASE_URL is the public Postgres URL with ?sslmode=no-verify appended (the connection is encrypted; Railway's certificate is self-signed so it is not verified). REDIS_URL is the public Redis URL. DATABASE_POOL_MAX=3.

railway.toml and railpack.json record the start command, restart policy and the Node provider (the root Cargo.toml would otherwise make Railway try to build a Rust app). Both point at npm run start:worker.

The worker service is connected to the GitHub repository (coolhurricane/mutate, branch main), so every push to main redeploys it, the same way Vercel redeploys the site. A manual deploy from a local folder is still possible with railway up --service worker --detach.

Public Access means anyone with the connection string can reach the database, so the string stays secret (Vercel stores it as a sensitive variable) and the password is the generated one. Public traffic is billed as egress.

Vercel Blob

Create a private Blob store for the project and connect it, which adds BLOB_READ_WRITE_TOKEN to Vercel. Copy the same token to Railway. Uploads are stored as uploads/<sha256>-<owner>.<ext> and served through /api/media/[id], never from a public blob URL.

First deploy checklist

  • Migrations applied to the Railway database (the worker does this on every start).
  • curl https://www.mutatelab.fun/api/status returns healthy.
  • Upload artwork in the incubator and confirm it renders after a refresh (proves Blob works).
  • The worker log shows it connected to Redis and is waiting for jobs.
  • Launch a test token on devnet and watch the worker reconcile it.

Notes

  • The devnet protocol wallet was generated for testing; its key is also saved at ~/.mutate/protocol-authority-devnet.json on the machine that created it (owner-only permissions). Use a separately generated and securely stored key for mainnet.

  • Redis must be a real Redis (BullMQ uses blocking commands and long-lived connections). A serverless Redis that bills per command will be expensive.

  • The public devnet RPC rate limits aggressively. A dedicated RPC is strongly recommended before real traffic.

  • Back up the Railway Postgres. Generation history is append-only and is the permanent record.