# Deployment

Everything web runs on Vercel, org `ivelins-projects-41ccec27`. Three projects,
one per app, all pointing at this monorepo with a per-app **Root Directory**.

| App | Vercel project | Domain | Root directory |
| --- | --- | --- | --- |
| api | `acrune-api` | acrune.com | `apps/api` |
| dashboard | `acrune-dashboard` | served at acrune.com/dashboard via the apex's rewrite | `apps/dashboard` |
| track | `acrune-track` | track.acrune.com | `apps/track` |

Each app's build config lives in its own `vercel.json` or `next.config.mjs`,
which stays valid relative to that app's root directory. Vercel auto-detects the
pnpm workspace root and installs from there.

`apps/engine` deploys separately to AWS with SST (`sst.config.ts` at the repo
root) and is not a Vercel project.

## The tracker bundles to a committed file

`apps/track` builds with esbuild to `api/index.js`, and **that file is
committed**. Vercel's functions glob validates against it at build time, so a
push that changes a route without rebuilding ships the old bundle.

```bash
pnpm --filter acrune-track build    # tsc --noEmit, then esbuild
```

Rebuild and commit it in the same change as the route.

## Gates

CI runs on every pull request and on pushes to `main`:

- **Build** is the hard gate. It typechecks every app — `api` and `track` run
`tsc --noEmit`, the dashboard runs `next build` — and bundles them.
- **Lint** is enforced on `api`, `track` and `engine`.
- **Test** runs the vitest suites for the same three.
- **Lint (dashboard)** is configured in the main CI workflow; check its actual job result. The reproducible baseline separately runs dashboard production build and guardrails.

The release-baseline workflow also runs the full-schema/browser gate and a native PostgreSQL multi-process payout reservation test. Evidence is uploaded as an artifact. Passing local checks does not mean the current production apps share the same source revision.

A client-side `pre-push` hook runs lint, test and typecheck before any push to
`main`, because server-side branch protection needs a paid plan on a private
repo. Bypass with `--no-verify` only when you have a reason you would say out
loud.

## Secrets

`DATABASE_URL` is duplicated across all three Vercel projects, so rotating it is
three manual edits. Variable names are documented in each app's `.env.example`.
A Vercel shared environment would give the shared values one home; it has not
been set up.

`ADMIN_TOKEN` on the tracker is the legacy operator secret and is being retired
in favour of per-actor keys — see
[Accounts and keys](https://acrune.com/dashboard/docs/platform/accounts-and-keys.md).

`V1_RATE_LIMIT_PER_MINUTE` on the tracker overrides the partner rate limit.

## Local development

```bash
pnpm install
pnpm dev            # all apps, via turbo
pnpm --filter acrune-track dev
```

Each app needs its own env file — copy the `.env.example` in each `apps/*`.
Do not run `pnpm db:push`; see
[Database and migrations](https://acrune.com/dashboard/docs/engineering/database-and-migrations.md).

## Observed deployment baseline

On September 17, API/dashboard production remained at main revision `5a3474e`; tracker had a newer CLI deployment without git metadata. AWS dev-stage functions pointed at the configured dashboard database. See repository `docs/qa/release-baseline.md` for IDs and schema gaps. Pin a coordinated release and its migration receipts; never infer a complete rollout from a successful feature-branch push.
