Skip to content

Commit ddcd5fb

Browse files
committed
AGENTS
1 parent 09d442c commit ddcd5fb

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# workplacify — Agent Guide
2+
3+
## Stack
4+
- Next.js 15 (Pages Router), tRPC v10, Chakra UI v3, Prisma 6 (PostgreSQL), NextAuth v4, Zod
5+
- React 18, Vitest (unit, globals enabled, excludes `playwright/`), Playwright (E2E, desktop Chrome only, video always on)
6+
- i18n via next-intl (en/de/it), PostHog analytics, Cloudinary floor-plan images, Discord bot for notifications
7+
8+
## Dev server
9+
```sh
10+
npm run dx # parallel: db-up + migrate-dev + db-seed + next dev --experimental-https
11+
npm run dx:next # serial: same tasks then dev server
12+
```
13+
HTTPS required by NextAuth (certificates in `certificates/`). Dev URL: `https://127.0.0.1:3000`.
14+
15+
## Database
16+
PostgreSQL via Docker on port **5835**. Prisma schema uses **snake_case** everywhere (`@map`).
17+
```sh
18+
npm run db-up # docker compose up -d
19+
npm run db-nuke # docker compose down --volumes --remove-orphans
20+
npm run db-seed # prisma db seed (via tsx prisma/seed.ts)
21+
npm run db-reset # prisma migrate dev reset
22+
npm run migrate-dev # create new migration
23+
npm run migrate # prisma migrate deploy (CI-safe)
24+
```
25+
After editing `prisma/schema.prisma`:
26+
```sh
27+
npm run generate # prisma generate (auto-runs on postinstall)
28+
npm run prisma-case-format # reformats schema to snake_case
29+
```
30+
31+
## Verification (run in order)
32+
```sh
33+
npm run lint # eslint --cache --ext .js,.ts,.tsx src/
34+
npm run tsc # tsc --noEmit
35+
npm run test:unit # vitest run
36+
npm run test:e2e # playwright test (needs dev server)
37+
npm run test-dev # start-server-and-test: dev -> http://127.0.0.1:3000 -> test
38+
npm run test-start # same but with prod build + start
39+
```
40+
**Do not run `npm run build` locally**`prebuild` runs `prisma migrate deploy`. CI uses `npm run build-ci` (skips migration).
41+
42+
## Key gotchas
43+
- **`src/server/env.js`** must stay `.js` — it is CJS-`require`d by `next.config.js`.
44+
- **`src/pages/app/`** is Pages Router, not App Router (Next.js 15 still uses `pages/`).
45+
- **E2E auth**: most pages require login (NextAuth + Google/Microsoft). No mock auth set up.
46+
- **Vitest globals**: `describe`, `it`, `expect` available without imports.
47+
- **`tsx`** (not `ts-node`) runs TypeScript scripts (e.g. seed).
48+
- **`npm install`** auto-runs `prisma generate` via `postinstall`.
49+
- **Pre-commit** (Husky + lint-staged): runs `eslint --cache --fix && prettier --write` on staged `*.{js,ts,tsx}`. Do not format manually before commit unless file is staged.
50+
- **CI** ([`.github/workflows/main.yml`](.github/workflows/main.yml)): copies `.env.example → .env`, `npm ci`, `npm run build-ci`. Tests are **not** run in CI.
51+
52+
## Deployment
53+
- Render.com via `render.yaml`. Health check: `GET /api/trpc/healthcheck`.
54+
- Build command: `npm install --include=dev && npm run build --include=dev`.
55+
56+
## Project structure
57+
| Path | Purpose |
58+
|---|---|
59+
| `src/pages/app/` | App pages (auth-gated, sidebar layout) |
60+
| `src/pages/api/trpc/[trpc].ts` | tRPC HTTP handler |
61+
| `src/pages/api/auth/[...nextauth].tsx` | NextAuth config (Google + Microsoft Entra) |
62+
| `src/server/routers/_app.ts` | Root tRPC router (merges all sub-routers) |
63+
| `src/server/env.js` | Zod env validation (CJS) |
64+
| `prisma/seed.ts` | Seed script (tsx, faker + Box-Muller) |

0 commit comments

Comments
 (0)