Operate
Self-hosting
Run the whole stack yourself: an API, an indexer, a worker and a realtime gateway, backed by Postgres and Redis. A hosted beta API exists for trying Rivisk out, but it runs on early-stage infrastructure with no availability guarantee, so anything that matters should run its own instance.
Services#
| Service | Does | Port |
|---|---|---|
apps/api | REST API, auth, rate limiting | API_PORT |
apps/indexer | Reads wallets through the protocol adapters | — |
apps/worker | Scores risk, evaluates alerts, delivers webhooks and email, publishes attestations | — |
apps/realtime | Socket.IO gateway for live events | REALTIME_PORT |
apps/web | The dashboard and these docs | 3000 |
| Postgres 16 · Redis 7 | State and queues | 5432 · 6379 |
Running it#
Infrastructure and dependencies
bashgit clone https://github.com/TheSoftNode/rivisk && cd riviskcp .env.example .env # then fill in the secrets belowdocker compose up -d # Postgres and Redispnpm installpnpm db:generateDatabase
bashpnpm --filter @rivisk/database exec prisma migrate deploy --schema prisma/schema.prismaMigrations are committed and checked in CI against a real Postgres, including a drift check that fails the build if the schema and the migrations disagree.
Build and start
bashpnpm buildnode apps/api/dist/main.jsnode apps/indexer/dist/main.jsnode apps/worker/dist/main.jsnode apps/realtime/dist/main.jsProve it works
bashRIVISK_BASE_URL=http://localhost:4000/api/v1 pnpm --filter @rivisk/api smokeThe smoke test acts as a wallet: it signs in with a throwaway key, then exercises API keys, webhooks, alerts, ownership checks and the key permission boundary against your running API. Unit tests mock the database and the queue. This does not. Set
STACKS_NETWORKto the API's network: sign-in checks the address prefix.
Production on one server#
infrastructure/deploy/ runs the whole backend from one image with Docker Compose: the four services, a one-off migration step, Postgres and Redis on a private network, and Caddy in front for automatic HTTPS. Only ports 80 and 443 are published.
cd infrastructure/deploy./setup-env.sh api.example.com ws.example.com https://your-site.vercel.appdocker compose --env-file .env.production -f docker-compose.prod.yml up -d --buildsetup-env.sh generates every secret on the server and never prints one. The AWS runbook walks through it on EC2, with the web app on Vercel, backups and Chainhook registration.
Environment#
| Variable | Purpose |
|---|---|
DATABASE_URL | Postgres connection string |
REDIS_URL | Redis, for queues, nonces, rate limits and realtime |
STACKS_NETWORK | mainnet or testnet. Also selects the network attestations are published to |
STACKS_API_URL | A Stacks API, e.g. api.hiro.so or api.testnet.hiro.so |
ZEST_V2_ENABLED | true to read Zest lending positions. Off by default |
BITPAY_CORE_CONTRACT | Enables the BitPay stream adapter |
COINGECKO_API_KEY | Optional; raises pricing rate limits |
WEB_URL | Allowed browser origins, comma-separated |
TRUST_PROXY_HOPS | Proxies in front of the API. See rate limits |
SMTP_HOST | With SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, SMTP_FROM. Email is skipped quietly when unset |
CHAINHOOK_AUTH_TOKEN | Bearer token Chainhook must present |
INDEXER_CONCURRENCY | Also RISK_WORKER_CONCURRENCY, ALERT_WORKER_CONCURRENCY. Default 4 |
Publishing attestations#
| Variable | Value |
|---|---|
RISK_REGISTRY_CONTRACT | ST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7.risk-registry |
RISK_POLICY_CONTRACT | ST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7.risk-policy |
PROTOCOL_REGISTRY_CONTRACT | ST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7.protocol-registry |
RISK_PUBLISHER_ENABLED | true |
RISK_PUBLISHER_SECRET_KEY | The private key of an authorised publisher. Use a secret manager |
ATTESTATION_MIN_INTERVAL_BLOCKS | Default 120. An unchanged snapshot is republished at most once per this many blocks; a changed figure publishes immediately. 0 publishes every snapshot |
The values above are the public testnet deployment, which you can read from but not publish to: only its authorised publisher can write. To publish your own attestations, deploy your own copy of the contracts (see the deployment runbook) and authorise your publisher with set-publisher.

