ØSTEN AI Development Guide
How we work on this repo. For getting the environment running at all, see
setup-local.md; for what runs on a PR and how deploys work,
see docs/ci-cd.md (internal).
Git workflow
Feature branches into main, reviewed by pull request. main is protected and
deploys on merge — nothing lands there directly.
git checkout main && git pull origin main
git checkout -b fix/short-description
# ...work...
npm run verify # same checks CI runs; cheaper to fail here
git commit -m "fix(shopify): reconcile product sync"
git push -u origin fix/short-descriptionOpen the PR against main. The template asks for what changed, why, and how to
verify. CI passed must be green before merge; it runs the checks for whichever
apps your branch touched.
Branch names: feat/, fix/, chore/, docs/ + a short description.
Commit messages: Conventional Commits.
Before you push
npm run verifyTypecheck, lint and tests across backend, frontend and landing — the same
definitions CI uses, so a green verify means a green PR. Individual pieces:
npm run typecheck:backend
npm run lint:frontend
npm --prefix backend run test:watchCoding standards
- TypeScript everywhere,
stricton.backend/tsconfig.jsonalso setsnoUncheckedIndexedAccess— indexing an array gives youT | undefinedand you have to handle it. - Lint is enforced in CI. Warnings are allowed through (there is a backlog);
errors are not. Do not add
eslint-disableto get past a rule — fix it, or argue for changing the rule ineslint.config.mjs. - Prettier formats the frontend:
npm --prefix frontend run format. - Every org-scoped query filters on
organization_id. This is a multi-tenant app and a missing filter is a data leak, not a bug. Seedocs/MULTI_TENANT_SECURITY.md(internal). - Tests for new logic, in whichever app it lands:
backend/test/— mockssrc/db/pooland drives routes throughapp.inject, so no database is needed.test/setup.tsrefuses to run the suite against anything but a local*_testdatabase, so a forgotten mock cannot reach real data.frontend/**/__tests__/— pure logic (payload builders, validation, plan mapping).frontend/e2e/for anything that needs a rendered page.landing/lib/__tests__/— content invariants and pure helpers.landing/e2e/for routes; add a spec there whenever you add a page, since an unreachable marketing route fails silently.docs-site/has no test suite;npm run build:docsis the check.
Adding an environment variable
Three edits, or it works locally and fails in production:
backend/src/config/env.ts— the only placeprocess.envis readbackend/.env.example— so the next person'snpm run setupincludes it.github/workflows/deploy-backend.yml—--set-env-varsfor plain values,--set-secretsfor anything sensitive
Secrets must exist in Google Secret Manager before they are referenced in
--set-secrets; the deploy fails on a nonexistent secret.
New integrations should fail closed when unconfigured (a 503 with a named
reason), the way billing and the scheduler already do — never fall back to
placeholder credentials.
Adding a migration
New numbered file in backend/migrations/, plain SQL, applied in filename
order.
Write them additively. During a deploy the migration job runs before the new revision takes traffic, so the previous revision briefly serves against the new schema — and the automatic rollback on a failed health check depends on that still working. Drop a column in a later release, once nothing reads it.
CI applies every migration to an empty Postgres on each run, so a migration that does not work from scratch fails the PR rather than the deploy.
Running the production images
Development runs on the host — bind-mounting node_modules into a container
makes Next.js fast refresh painfully slow. To exercise the actual Dockerfile
that ships to Cloud Run:
docker compose --profile full up --build