Local development
Requirements
- Node.js 22 (see
.nvmrc) and pnpm 10 (the repo pinspnpm@10.28.0inpackageManager). - PostgreSQL 16.
- Network access to Strike (
api-v2-testnet.strikefinance.orgby default) for real market data. Tests that use the mock Strike don't need it.
Install
git clone https://github.com/wolfofdefi/strikeabox.git
cd strikeabox
pnpm installDatabase
Create a role and a database. The examples use sbx/sbx on localhost:
createuser -h 127.0.0.1 -U postgres --pwprompt sbx # password: sbx
createdb -h 127.0.0.1 -U postgres -O sbx strikeabox_devThen apply the migrations:
DATABASE_URL=postgres://sbx:sbx@127.0.0.1:5432/strikeabox_dev pnpm --filter @sbx/server migrateMigrations are plain SQL files in apps/server/src/db/migrations, applied in filename order, each in its own transaction, under an advisory lock. Applied files are recorded with a checksum: editing one that has been applied is an error. Add a new file instead.
Configure
cp apps/server/.env.example apps/server/.envFill in at least:
DATABASE_URLQUOTE_SECRET: 32 random bytes as hex, e.g.openssl rand -hex 32
The defaults use Strike testnet (STRIKE_NETWORK=testnet). Practice mode works with just these. For Live mode you also need KEY_ENCRYPTION_KEY, a builder code and LIVE_TRADING_ENABLED=true; see Environment variables. Never commit .env.
The server validates its configuration at start-up and stops with a clear error if something is wrong, including any Strike host that does not belong to the configured network.
Run
Everything in one go (server in role all, web app, docs):
pnpm devOr each part on its own:
pnpm --filter @sbx/server dev # API + worker (ROLE=all), http://localhost:8787
pnpm --filter @sbx/web dev # web app, http://localhost:5173
pnpm --filter @sbx/docs dev # this siteTo run the API and the worker as separate processes, as in production, set the role per process:
ROLE=api pnpm --filter @sbx/server dev
ROLE=worker pnpm --filter @sbx/server devThe server reads apps/server/.env if it exists; variables set in your shell take precedence. Only one worker records prices at a time (it takes a Postgres advisory lock), so starting two workers is safe.
APP_ORIGIN must match where the web app runs (default http://localhost:5173): it is used for CORS, cookies and share links.
Check it works
curl -s http://localhost:8787/api/health
curl -s http://localhost:8787/api/health/worker/api/health/worker reports the age of the last tick per market. Within a few seconds of starting the worker, each market should show a small number. A market starts quoting after 60 ticks, about a minute.
Useful commands
pnpm typecheck # all packages
pnpm test # all packages' tests
pnpm build # all packages' builds
pnpm --filter @sbx/docs build # docs only, fails on dead links
pnpm --filter @sbx/web dev:mock # a mock API on :8787 for the web app: no Postgres, no StrikeSee Testing for the test databases and the browser suites.