Cursor rule
.cursor/rules/api-patterns.mdcExpress API conventions (Math Tutoring App)
Cursor rules
Quality
73/100
Scores the file, not the repository.Length
318 words
8 headings · 1 code blocksRepository
0
— · pushed 112 days agoLast changed
3 days ago
First indexed 3 days ago.1234567# API Patterns — `api/`89Stack: **Express** (CommonJS **`.js`**), **Vercel AI SDK** (`ai`, `@ai-sdk/openai`), deployed as **Vercel** serverless. **No database in this API** — persistence is **Firebase** from the **webapp** only.1011## Folder layout (actual)1213```14api/15 server.js ← Express app, CORS, JSON, mounts routes, error handler16 index.js ← Vercel entry; re-exports app17 routes/18 chat.js ← POST /chat, SSE streaming, tool schemas (Zod)19 services/20 promptService.js ← System prompt / message building21 contextManager.js ← Conversation context helpers (if used)22 src/lib/23 logger.js ← Pino singleton; pino-http attaches `req.log` per request (see server.js)24 src/config/ ← Centralized env (Phase 4 — read REFACTOR_RUNBOOK.md)25```2627There is **no** `middleware/` or `prisma/` here. Do not add Prisma or hand-written SQL migrations to this project.2829## Responsibilities3031- **`routes/`** — Thin HTTP: validate inputs, call `services/`, set status codes, stream SSE. Avoid huge inline prompt strings; keep them in `services/promptService.js` (or dedicated modules under `services/`).32- **`services/`** — Business-ish logic: prompt construction, helpers. No Firebase Admin for Firestore user data (removed by design); optional context utilities only.33- **`server.js`** — App wiring only; avoid new domain logic here.3435## LLM & streaming3637- Use the **Vercel AI SDK** patterns already in `routes/chat.js` (`streamText`, tools, Zod `inputSchema`).38- **OpenAI API key** must stay **server-side** only (`OPENAI_API_KEY`).3940## Environment variables4142- **Do not** scatter new `process.env` reads — the refactor runbook centralizes config under **`api/src/config/`** (Phase 4). Until then, follow existing patterns and Oxlint overrides documented in the runbook.4344## Logging4546- Import **`api/src/lib/logger.js`** for startup and process-level logs; in routes use **`req.log`** from **pino-http** (registered first in `server.js`).47- Never use `console.*` in application code.4849## Errors5051- Prefer consistent JSON error shapes for new routes; match existing `{ error, message }` style in this codebase unless a refactor standardizes on another shape.5253## SSE5455- Chat streaming uses `text/event-stream` and `data: …` lines as already implemented; preserve headers (`Content-Type`, `Cache-Control`, `Connection`) when touching streaming code.56
Also in VictorGoic0/Math-Tutoring-App
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| VictorGoic0/Math-Tutoring-App.cursor/rules/linting.mdc · 0 | Cursor rules | lint-formatstyledo-notagent-behaviour | 68/100 | 3 days ago | |
| VictorGoic0/Math-Tutoring-App.cursor/rules/one-pr-at-a-time.mdc · 0 | Cursor rules | git | 16/100 | 3 days ago | |
| VictorGoic0/Math-Tutoring-App.cursor/rules/react-patterns.mdc · 0 | Cursor rules | stylearchdo-not | 69/100 | 3 days ago | |
| VictorGoic0/Math-Tutoring-App.cursor/rules/react-readability.mdc · 0 | Cursor rules | styleuido-not | 57/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
