Rivisk

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#

ServiceDoesPort
apps/apiREST API, auth, rate limitingAPI_PORT
apps/indexerReads wallets through the protocol adapters—
apps/workerScores risk, evaluates alerts, delivers webhooks and email, publishes attestations—
apps/realtimeSocket.IO gateway for live eventsREALTIME_PORT
apps/webThe dashboard and these docs3000
Postgres 16 · Redis 7State and queues5432 · 6379

Running it#

  1. Infrastructure and dependencies

    bash
    git 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:generate
  2. Database

    bash
    pnpm --filter @rivisk/database exec prisma migrate deploy --schema prisma/schema.prisma

    Migrations 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.

  3. Build and start

    bash
    pnpm buildnode apps/api/dist/main.jsnode apps/indexer/dist/main.jsnode apps/worker/dist/main.jsnode apps/realtime/dist/main.js
  4. Prove it works

    bash
    RIVISK_BASE_URL=http://localhost:4000/api/v1 pnpm --filter @rivisk/api smoke

    The 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_NETWORK to 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.

bash
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 --build

setup-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#

VariablePurpose
DATABASE_URLPostgres connection string
REDIS_URLRedis, for queues, nonces, rate limits and realtime
STACKS_NETWORKmainnet or testnet. Also selects the network attestations are published to
STACKS_API_URLA Stacks API, e.g. api.hiro.so or api.testnet.hiro.so
ZEST_V2_ENABLEDtrue to read Zest lending positions. Off by default
BITPAY_CORE_CONTRACTEnables the BitPay stream adapter
COINGECKO_API_KEYOptional; raises pricing rate limits
WEB_URLAllowed browser origins, comma-separated
TRUST_PROXY_HOPSProxies in front of the API. See rate limits
SMTP_HOSTWith SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, SMTP_FROM. Email is skipped quietly when unset
CHAINHOOK_AUTH_TOKENBearer token Chainhook must present
INDEXER_CONCURRENCYAlso RISK_WORKER_CONCURRENCY, ALERT_WORKER_CONCURRENCY. Default 4

Publishing attestations#

VariableValue
RISK_REGISTRY_CONTRACTST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7.risk-registry
RISK_POLICY_CONTRACTST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7.risk-policy
PROTOCOL_REGISTRY_CONTRACTST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7.protocol-registry
RISK_PUBLISHER_ENABLEDtrue
RISK_PUBLISHER_SECRET_KEYThe private key of an authorised publisher. Use a secret manager
ATTESTATION_MIN_INTERVAL_BLOCKSDefault 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.