|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | +- App entry: `index.html`, client in `src/`, server in `server.js`. |
| 5 | +- Frontend: React + Vite (`src/components`, `src/lib`, `src/styles`, `src/pages`). |
| 6 | +- Tokens/design: `tokens/` (primitives, themes) with generated output in `tokens/build` and `src/styles/tokens`. |
| 7 | +- Scripts & reports: `scripts/` (utilities) and `reports/` (audit output). |
| 8 | +- Tests: `tests/*.test.js` (Jest + Supertest). |
| 9 | +- Static assets: `assets/`, data seeds in `src/data/`. |
| 10 | + |
| 11 | +## Build, Test, and Development Commands |
| 12 | +- `npm run dev` — run Vite client (3000) and Node server with hot reload. |
| 13 | +- `npm run build` — build design tokens then Vite production bundle. |
| 14 | +- `npm start` — start Express server (`server.js`). |
| 15 | +- `npm run preview` — preview built client. |
| 16 | +- `npm test` — run Jest test suite. |
| 17 | +- Token tools: `npm run tokens:build`, `tokens:watch`, `tokens:clean`, `tokens:validate`, `tokens:audit`. |
| 18 | +- Utilities: `npm run generate-thumbnails`. |
| 19 | + |
| 20 | +## Coding Style & Naming Conventions |
| 21 | +- JavaScript/JSX (ESM). Indent 2 spaces; semicolons optional but be consistent. |
| 22 | +- Components: `PascalCase` in `src/components` (e.g., `WorkflowEditor.jsx`). |
| 23 | +- Hooks/utils: `camelCase` (e.g., `useAvailableModels.js`, `workflowEngine.js`). |
| 24 | +- CSS modules by domain: place under `src/styles/components` or `src/styles/tokens`. |
| 25 | +- Keep server code side-effect free on import; export pure functions where possible. |
| 26 | + |
| 27 | +## Testing Guidelines |
| 28 | +- Framework: Jest with Supertest for server routes. |
| 29 | +- File names: mirror feature with `.test.js` (e.g., `tests/auth.routes.test.js`). |
| 30 | +- Run all tests: `npm test`; run a file: `jest tests/image.routes.test.js`. |
| 31 | +- Aim for coverage of core flows: auth, image processing, workflow engine. |
| 32 | + |
| 33 | +## Commit & Pull Request Guidelines |
| 34 | +- Commit messages: concise imperative present (e.g., "Add auth route guard"). |
| 35 | +- Group related changes; avoid mixed refactors + features. |
| 36 | +- PRs: include purpose, scope, screenshots for UI, steps to test, and linked issues. |
| 37 | +- Touching tokens: include before/after screenshots and run `tokens:validate`. |
| 38 | + |
| 39 | +## Security & Configuration Tips |
| 40 | +- Env: configure required secrets in `.env` for server (`PORT`, auth, API keys). Never commit secrets. |
| 41 | +- Validate untrusted input; use `dompurify` when rendering user content. |
| 42 | +- Prefer `src/lib/logger.js` and `prom-client` metrics for observability. |
| 43 | + |
| 44 | +## Agent-Specific Instructions |
| 45 | +- Treat this file as authoritative. Follow directory scopes when adding or modifying files under `src/`, `tokens/`, and `tests/`. |
| 46 | + |
| 47 | +## Recent Changes & Rationale |
| 48 | +- For a concise summary of the latest implementation updates (Markdown rendering, mock persistence, drawer UI, centered layouts, headers), see `docs/IMPLEMENTATION_NOTES.md`. |
| 49 | + |
| 50 | +## Changelog Process (All Agents) |
| 51 | +- Before committing and pushing changes: |
| 52 | + 1) Add a one‑sentence entry to `CHANGELOG.md` with today’s date and a concise summary. |
| 53 | + 2) If the change is non‑trivial, append details to `docs/IMPLEMENTATION_NOTES.md`. |
| 54 | + 3) Stage, commit, and push. |
| 55 | + |
| 56 | +Example: |
| 57 | +``` |
| 58 | +echo "$(date +%F): Short description of the change." >> CHANGELOG.md |
| 59 | +git add CHANGELOG.md docs/IMPLEMENTATION_NOTES.md |
| 60 | +git add -A |
| 61 | +git commit -m "chore(changelog): update for <feature/area>" |
| 62 | +git push |
| 63 | +``` |
| 64 | + |
| 65 | +## Deployment Environment Variables |
| 66 | +- Core: `NODE_ENV` (`production` on deploy), `PORT` (defaults to 8081 locally). |
| 67 | +- URLs: `FRONTEND_URL`, `BACKEND_URL`, `DOMAIN`. Used for CORS and OAuth redirects. Example: `https://app.example.com`. |
| 68 | +- Auth/JWT: `AUTH_SECRET` (required). Rotate regularly. |
| 69 | +- OAuth/Identity: `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET` (if enabling Google flows), `GOOGLE_API_KEY` (GenAI). |
| 70 | +- AI Providers (optional): `GEMINI_API_KEY`, `OPENAI_API_KEY`, `CLAUDE_API_KEY`. |
| 71 | +- Vercel: `VERCEL_URL` is auto-set; leave unset locally. |
| 72 | +- Local `.env` example: |
| 73 | + - `NODE_ENV=development` |
| 74 | + - `PORT=8081` |
| 75 | + - `FRONTEND_URL=http://localhost:3000` |
| 76 | + - `BACKEND_URL=http://localhost:8081` |
| 77 | + - `AUTH_SECRET=change-me` |
| 78 | + - `GOOGLE_API_KEY=...` |
| 79 | + - `GEMINI_API_KEY=...` |
| 80 | + |
| 81 | +Notes |
| 82 | +- CORS allows `FRONTEND_URL`, `BACKEND_URL`, `DOMAIN`, and `https://${VERCEL_URL}` automatically. |
| 83 | +- For Vercel, build client with `vercel-build` and route API to `server.js` (see `vercel.json`). Ensure `AUTH_SECRET` and provider keys are set in Vercel project settings. |
0 commit comments