ØSTEN AI

Ø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-description

Open 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 verify

Typecheck, 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:watch

Coding standards

  • TypeScript everywhere, strict on. backend/tsconfig.json also sets noUncheckedIndexedAccess — indexing an array gives you T | undefined and 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-disable to get past a rule — fix it, or argue for changing the rule in eslint.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. See docs/MULTI_TENANT_SECURITY.md (internal).
  • Tests for new logic, in whichever app it lands:
    • backend/test/ — mocks src/db/pool and drives routes through app.inject, so no database is needed. test/setup.ts refuses to run the suite against anything but a local *_test database, 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:docs is the check.

Adding an environment variable

Three edits, or it works locally and fails in production:

  1. backend/src/config/env.ts — the only place process.env is read
  2. backend/.env.example — so the next person's npm run setup includes it
  3. .github/workflows/deploy-backend.yml — --set-env-vars for plain values, --set-secrets for 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

On this page