Backend Deployment
The backend is a long-running Node process. The reference deployment uses PM2 on a regular VPS, fronted by a Cloudflare Tunnel so the public TLS certificate is managed by Cloudflare.
Topology in production
- Process:
pm2 start dist/index.js --name taskfi-api - Edge:
cloudflaredtunnel terminating at a publicapi.taskfi.xyzhostname. - Database: Postgres (local or managed). Schema managed by Prisma migrations.
Required env vars
| Variable | Notes |
|---|---|
DATABASE_URL | Postgres connection string. |
JWT_SECRET | Long random string. Rotate to invalidate sessions. |
JWT_EXPIRES_IN | e.g. 7d. |
BASE_CHAIN_ID | 8453 or 84532. Must match the SIWE chain id. |
BASE_RPC_URL | RPC endpoint the backend uses to read state. |
SIWE_DOMAIN | Comma-separated list. Each entry matches as exact or subdomain. |
CORS_ALLOWED_ORIGINS | Comma-separated full origins (https://…). |
SCORING_ORACLE_PRIVATE_KEY | Signs completeTask and reputation updates. |
TASK_MANAGER_ADDRESS, STAKING_REGISTRY_ADDRESS, … | All contract addresses. Served back to the front via /api/public/config. |
LLM_PROVIDER | stub or claude. |
ANTHROPIC_API_KEY | If LLM_PROVIDER=claude. |
Scoring oracle key
The
SCORING_ORACLE_PRIVATE_KEY is the most sensitive secret in the system. Rotate it on a leak and call setScoringOracle on every contract that trusts it (TaskManager, ReputationEngine, RewardPool).Migrations
bash
cd taskfi/backend
npm run prisma:generate
npm run prisma:migrate
pm2 reload taskfi-apiEnd-to-end local test (30 agents on a fork)
See taskfi/orchestration/README.md for the full runbook. In short: run-fork-test.sh spins up anvil, deploys the contracts, funds 30 wallets, and writes the matching .env files for the backend and agents.