Local setup
Prerequisites
Section titled “Prerequisites”- Bun 1.3.14 — the package manager and the API runtime.
bun.lockis the lockfile that gates every deploy build. - Node 22 —
next build, the migration scripts and CI all run under Node. Both are needed; they are not alternatives. - Access to the
.envfiles (ask the team — they are not in the repo).
First run
Section titled “First run”cd tcgkl-webbun install --frozen-lockfile
# Env files live once at the repo root. apps/web/.env* are gitignored symlinks:ln -s ../../.env apps/web/.envln -s ../../.env.local apps/web/.env.local
bun run dev # web on :3000bun run dev:api # API on :4000, in a second terminalThe web app runs without the API: when API_INTERNAL_URL is unset, the thin
routes under apps/web/src/app/(main)/api/* serve tRPC and auth locally. Set
API_INTERNAL_URL=http://localhost:4000 to exercise the split the way
production runs it.
Which database am I pointed at?
Section titled “Which database am I pointed at?”There is no local Postgres. .env.local points at beta, .env at
production. Scripts run by a bare bun run load .env.local.
DATABASE_URL is the pooled Neon endpoint (-pooler, with
sslmode=require&channel_binding=require); postgres.js runs with
prepare: false because of PgBouncer. Migrations use DATABASE_URL_DIRECT, the
non-pooler endpoint, and the migrate script refuses a -pooler host.
Connection refused or CONNECT_TIMEOUT is almost always one of those two URLs
being wrong — or a dev server that needs restarting.
Everyday commands
Section titled “Everyday commands”All of these work from the repo root:
| Command | What it does |
|---|---|
bun run dev |
Next.js web app on :3000 |
bun run dev:api |
Hono API on :4000 |
bun run lint |
Biome check |
bun run format:fix |
Biome autofix |
bun run typecheck |
tsc in every workspace, in parallel |
bun run test |
Unit tests |
bun run db:generate |
Generate a migration from schema changes |
bun run db:migrate / db:migrate:beta |
Apply migrations |
bun run dev:stripe |
Forward Stripe webhooks to localhost |
Web-only scripts live in apps/web/package.json — run them with
bun run --cwd apps/web <script>.
The docs site itself
Section titled “The docs site itself”bun run --cwd apps/docs dev # this site, on :4321bun run --cwd apps/docs build # static output in apps/docs/distPages are Markdown under apps/docs/src/content/docs/. The sidebar is generated
from the folder structure — add a file, it appears. Order inside a group comes
from sidebar.order in the frontmatter.
