# Run it (/docs/developers/run-it)

One repository, one Dockerfile with two targets, and the settings each part needs.

## Layout [#layout]

<Files>
<Folder name="src" defaultOpen>
<Folder name="app" description="Routes: site, app, docs, API, MCP, OAuth" />

<Folder name="server" description="Orders, delivery, providers, chain, rates, rewards, drops, MCP, OAuth, Telegram" />

<Folder name="worker" description="The worker's entry and jobs" />

<Folder name="config" description="Constants, chain, services, env" />
</Folder>

<Folder name="contracts" description="Foundry: TodokuEscrow, FiatRateFeed, tests, deploy scripts" />

<Folder name="drizzle" description="SQL migrations, including the order state guard" />

<Folder name="content/docs" description="These docs" />

<File name="Dockerfile" description="Targets: web and worker" />
</Files>

## Local [#local]

```bash
pnpm install
pnpm dev          # web on :3010 (builds the AI card first)
pnpm dev:worker   # the worker, reading .env.local
pnpm test         # vitest: the state machine, provider outcome maps, request ids
pnpm contracts:test
```

## Docker and Coolify [#docker-and-coolify]

One image recipe, two targets: `web` (the Next.js standalone server, health at `/api/health`) and `worker` (the bundled worker, healthy while its heartbeat is fresh). Each environment (staging, production) runs a web app, a worker and its own Postgres. Deploy the worker first: it runs the migrations.

## Settings [#settings]

| Group | Names |
| --- | --- |
| Build (public) | `NEXT_PUBLIC_APP_ENV`, `NEXT_PUBLIC_APP_URL`, `NEXT_PUBLIC_QIE_NETWORK`, `NEXT_PUBLIC_ESCROW_ADDRESS`, `NEXT_PUBLIC_TELEGRAM_BOT` |
| Database | `DATABASE_URL` |
| Chain | `QIE_NETWORK`, `ESCROW_ADDRESS`, `ESCROW_DEPLOY_BLOCK`, `NGN_FEED_ADDRESS` |
| Keys | `QUOTE_SIGNER_KEY` (web), `OPERATOR_KEY`, `FEED_KEY`, `REWARDS_KEY` (worker) |
| Secrets | `SESSION_SECRET`, `PII_ENC_KEY` |
| Providers | `VTPASS_ENV`, `VTPASS_API_KEY`, `VTPASS_PUBLIC_KEY`, `VTPASS_SECRET_KEY`; the `FONBNK_*` keys |
| Optional | `OPS_WALLETS`, `DEMO_LINE`, `TELEGRAM_BOT_TOKEN` |

Secrets live only in the server's runtime settings, never in the repository.

## Contracts [#contracts]

`contracts/script/Deploy.s.sol` deploys the escrow (limits: 100 QUSDC an order, 2,000 a payment, 5,000 a pot, 20 lines; `RECLAIM_DELAY_SECONDS` from the environment; a one-day delay on handing over the admin role) and the NGN/USD feed, and refuses any chain but 1990. They will be verified on QIE's Blockscout (`--verifier blockscout --verifier-url https://mainnet.qie.digital/api/`).