|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This repository is a **pnpm + Turborepo monorepo** for **KlickerUZH v3**. |
| 4 | + |
| 5 | +## Repo layout |
| 6 | + |
| 7 | +- `apps/*` — deployable apps/services (frontends, backend services, Azure Functions) |
| 8 | +- `packages/*` — shared libraries (e.g. `graphql`, `prisma`, `util`) |
| 9 | +- `cypress/` — end-to-end tests |
| 10 | + |
| 11 | +## Tooling / prerequisites |
| 12 | + |
| 13 | +- **Node.js 20** (see `package.json` `engines` / `volta`) |
| 14 | +- **pnpm 10.x** (repo is pinned to `pnpm@10.15.0`) |
| 15 | + |
| 16 | +## Common commands (run from repo root) |
| 17 | + |
| 18 | +- Install dependencies: `pnpm install` |
| 19 | +- Format: `pnpm run format` / Check: `pnpm run format:check` |
| 20 | +- Lint: `pnpm run lint` |
| 21 | +- Typecheck (CI-style): `pnpm run check` |
| 22 | +- Build: `pnpm run build` |
| 23 | + |
| 24 | +## Running a single workspace |
| 25 | + |
| 26 | +Use filters: |
| 27 | + |
| 28 | +- `pnpm --filter <workspace> <script>` (example: `pnpm --filter @klicker-uzh/graphql build`) |
| 29 | + |
| 30 | +## Dev notes |
| 31 | + |
| 32 | +Some dev scripts load secrets via `./util/_run_with_infisical.sh` (e.g. `pnpm run dev`). Avoid starting long-running dev servers or anything requiring credentials unless explicitly requested. |
| 33 | + |
| 34 | +## Apps & URLs |
| 35 | + |
| 36 | +Local development uses Traefik to route `*.klicker.com` hostnames to apps running on the host (see `util/traefik/rules_docker.yaml` / `util/traefik/rules_wsl.yaml`). |
| 37 | + |
| 38 | +| URL | App / code | Local port | Notes | |
| 39 | +| ------------------------------------------- | ------------------------------------------- | ---------: | -------------------------------- | |
| 40 | +| https://pwa.klicker.com | Student PWA (`apps/frontend-pwa`) | 3001 | | |
| 41 | +| https://manage.klicker.com | Lecturer UI (`apps/frontend-manage`) | 3002 | | |
| 42 | +| https://control.klicker.com | Mobile controller (`apps/frontend-control`) | 3003 | | |
| 43 | +| https://chat.klicker.com | Chat UI (`apps/chat`) | 3004 | | |
| 44 | +| https://auth.klicker.com | Auth UI (`apps/auth`) | 3010 | | |
| 45 | +| https://api.klicker.com | Backend / GraphQL (`apps/backend-docker`) | 3000 | GraphQL endpoint: `/api/graphql` | |
| 46 | +| https://assessment.klicker.com | Assessment PWA (same service as PWA) | 3001 | | |
| 47 | +| https://assessment-api.klicker.com | Assessment API (same service as API) | 3000 | | |
| 48 | +| https://response-api.klicker.com | Response API (`apps/response-api`) | 7078 | | |
| 49 | +| https://response-api-assessment.klicker.com | Response API (assessment) | 7078 | | |
| 50 | + |
| 51 | +If Traefik is not used, the apps are still reachable directly via `http://localhost:<port>`, but the `*.klicker.com` domains better mirror production cookie/domain behavior. |
| 52 | + |
| 53 | +## Factory skills (AI assistance) |
| 54 | + |
| 55 | +This repo includes Factory skills under `.factory/skills/` (mirrored in `.github/skills/`). |
| 56 | + |
| 57 | +- `agent-browser` — browser automation for UI verification (see `.factory/skills/agent-browser/SKILL.md`). |
| 58 | +- `web-design-guidelines` — UI/UX/accessibility review (see `.factory/skills/web-design-guidelines/SKILL.md`). |
| 59 | +- `vercel-react-best-practices` — React/Next performance guidance (see `.factory/skills/vercel-react-best-practices/SKILL.md`). |
| 60 | + |
| 61 | +### Using agent-browser to verify changes |
| 62 | + |
| 63 | +Use `agent-browser` when changes affect browser behavior and need real UI validation, especially: |
| 64 | + |
| 65 | +- Auth/login/redirect/cookie-domain changes |
| 66 | +- UI/UX changes (layout, navigation, forms) |
| 67 | +- Cross-app flows (e.g. manage ↔ auth, pwa ↔ auth) |
| 68 | +- Browser-only behavior (localStorage, service worker/PWA, media queries) |
| 69 | + |
| 70 | +**Screenshots are required** (snapshots alone miss visual regressions). Take a screenshot before and after the action you’re verifying and review it with the `Read` tool. |
| 71 | + |
| 72 | +Prereqs: the app is running locally in **dev mode** and the database is **seeded**. |
| 73 | + |
| 74 | +If `agent-browser` is missing entirely: |
| 75 | + |
| 76 | +```bash |
| 77 | +npm i -g agent-browser |
| 78 | +``` |
| 79 | + |
| 80 | +If the browser executable is missing on a new machine, run once: |
| 81 | + |
| 82 | +```bash |
| 83 | +agent-browser install |
| 84 | +``` |
| 85 | + |
| 86 | +For automated runs, **do not use Edu-ID** (it will not work with `agent-browser`). Always use **Delegated login**: |
| 87 | + |
| 88 | +- Username: `lecturer` |
| 89 | +- Password: `abcd` |
| 90 | + |
| 91 | +For Student PWA testing in local seeded dev environments, you can log in with the seeded participants (see `packages/prisma-data/src/data/seedTEST.ts`): |
| 92 | + |
| 93 | +- Usernames: `testuser1`–`testuser50` (enrolled in course **Testkurs**) |
| 94 | +- Password: `abcdabcd` |
| 95 | + |
| 96 | +Additional seeded participants exist (`testuser51`–`testuser52`), but they are not enrolled in any course by default. |
| 97 | + |
| 98 | +### Example: delegated login (Manage) |
| 99 | + |
| 100 | +Note: on the first screen, **“Delegated Access” is disabled until the Terms checkbox is checked**. |
| 101 | + |
| 102 | +```bash |
| 103 | +agent-browser open https://manage.klicker.com |
| 104 | +agent-browser screenshot /tmp/klicker-manage-01.png --full |
| 105 | +agent-browser snapshot -i -c |
| 106 | + |
| 107 | +# 1) Check the Terms checkbox (if needed) |
| 108 | +# 2) Click “Delegated Access” |
| 109 | +# 3) Fill username/password and submit |
| 110 | +# (Use the @e* refs from the latest snapshot output) |
| 111 | + |
| 112 | +agent-browser wait --load domcontentloaded |
| 113 | +agent-browser screenshot /tmp/klicker-manage-02.png --full |
| 114 | +agent-browser get url |
| 115 | +agent-browser close |
| 116 | +``` |
| 117 | + |
| 118 | +These credentials are intended for local seeded dev environments only. |
| 119 | + |
| 120 | +## Change hygiene |
| 121 | + |
| 122 | +- Keep changes small and follow existing patterns in the touched app/package. |
| 123 | +- Don’t add/update dependencies (or churn lockfiles) unless required for the task. |
| 124 | +- Never commit secrets (tokens, `.env` files, credentials). |
0 commit comments