Purpose
Keep Convex architecture decisions consistent in this repo and avoid flipping between incompatible models.
Canonical model for this repo
- Hosted SaaS: Convex Cloud deployment is the source of truth for production behavior.
- Day-to-day development: use cloud dev deployment via
npx convex devunless explicitly testing local backend behavior. - Local deployment mode (
npx convex dev --local) is optional and temporary for debugging/perf; do not treat it as the default architecture.
Runtime boundaries (must keep)
- Queries/Mutations/HTTP actions: default Convex runtime (deterministic for query/mutation).
- Node runtime: only in files with top-level
"use node". - Node built-ins (
crypto,Buffer, filesystem, etc.) must stay in Node runtime action files. - Do not define queries/mutations in
"use node"files. - Do not import Node-only files from non-Node Convex runtime files.
TypeScript conventions for Convex code
- Keep
convex/convex/tsconfig.jsonwith:"lib": ["ES2021", "dom", "dom.iterable"]"types": ["node"]
- Why:
dom+dom.iterablefor Web APIs used in Convex runtime (Request,Response,URLSearchParams.entries, etc.).nodetypes for Node runtime actions usingprocess,Buffer, and Node modules.
Deployment/env hygiene
- Convex env vars are per deployment; set required keys in every deployment you depend on (dev/prod/preview).
- For this repo, critical Convex env vars often include:
PERKCORD_REST_API_KEYPERKCORD_OAUTH_ENCRYPTION_KEYDISCORD_CLIENT_IDDISCORD_CLIENT_SECRETDISCORD_MEMBER_REDIRECT_URIDISCORD_REDIRECT_URIDISCORD_BOT_TOKEN- Provider credentials/secrets as needed
- Convex HTTP actions should use
.convex.siteendpoints.
When to use cloud dev vs local dev
- Use cloud dev when validating webhooks, OAuth callbacks, or anything needing public URLs.
- Use local dev only when intentionally testing local backend behavior, quotas, or latency.
Quick verification checklist
npx convex devlinks to expected project/deployment.npx tsc -p convex/convex/tsconfig.jsonpasses.npm --prefix convex run lint && npm --prefix convex run testpasses.npx convex env listshows required Discord/provider env vars.- Role Connections metadata registration succeeds (
/api/role-connections/metadata).
Sharp edges
- If
npx convex env ...returnsMissingAccessToken, runnpx convex devinteractively and complete login. - If deployment mismatch prompt appears, choose the team/project deployment for this repo.
- If role sync requests stay
pending, verify bot access to target guild and role hierarchy first.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.