Skip to content

chore: add Supabase schema and contributor docs#87

Open
mrmagic2020 wants to merge 9 commits into
mainfrom
chore/dev-update
Open

chore: add Supabase schema and contributor docs#87
mrmagic2020 wants to merge 9 commits into
mainfrom
chore/dev-update

Conversation

@mrmagic2020

Copy link
Copy Markdown
Owner

Summary

  • Supabase schema in repo — initialized the Supabase CLI, pulled the full
    production schema into web/supabase/migrations/, and added config.toml so
    contributors can boot a local Postgres + Auth + Storage stack with npx supabase start
  • Type-safe database client — generated database.types.ts from the live
    schema, wired the Database generic into all 4 Supabase client factories, and
    fixed 73 pre-existing type errors across 31 files that were previously hidden by
    untyped (any) queries
  • Node.js 24 upgrade — pinned the runtime to Node 24 LTS via engines,
    .nvmrc, and CI workflow; bumped @types/node to ^24
  • Documentation reorganization — created CONTRIBUTING.md with full local dev
    setup (Supabase, env vars, database workflow, code quality, deployment), slimmed
    README.md to a product overview, updated README.zh-CN.md to match, and removed
    DEPLOYMENT.md (content moved into CONTRIBUTING)

Copilot AI review requested due to automatic review settings April 16, 2026 09:53
@vercel

vercel Bot commented Apr 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
wrong-question-notebook Ready Ready Preview, Comment Apr 18, 2026 8:55am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR brings Supabase into the repo for reproducible local DB/Auth/Storage dev, adds generated type-safe Supabase Database typings across clients and affected query code, upgrades the web runtime baseline to Node.js 24, and consolidates contributor/deployment documentation into a new CONTRIBUTING.md.

Changes:

  • Add Supabase CLI config (and migrations/types) to support npx supabase start local development.
  • Introduce generated web/lib/database.types.ts and wire the Database generic into Supabase client factories, adjusting call sites to satisfy stricter typing.
  • Upgrade Node baseline to 24 and reorganize docs (new CONTRIBUTING, slimmer READMEs, remove DEPLOYMENT).

Reviewed changes

Copilot reviewed 44 out of 46 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
web/supabase/config.toml Adds Supabase CLI local stack configuration (API/DB/Auth/Storage/etc.).
web/supabase/.gitignore Ignores Supabase local working dirs and local env/key files under web/supabase/.
web/package.json Pins Node engine to 24+, bumps @types/node, adds supabase CLI dev dependency.
web/package-lock.json Lockfile updates for Node typings + Supabase CLI and transitive dependencies.
web/lib/user-management.ts Adds Json typing and adjusts query/update return types/casts under typed Supabase client.
web/lib/usage-quota.ts Adjusts RPC return typing cast to satisfy typed schema.
web/lib/supabase/server.ts Types the SSR server client via createServerClient<Database>().
web/lib/supabase/middleware.ts Types middleware Supabase clients and tightens role-check typing.
web/lib/supabase/client.ts Types the browser Supabase client via createBrowserClient<Database>().
web/lib/supabase-utils.ts Types the service role client factory via createSupabaseClient<Database>().
web/lib/storage/delete.ts Types SupabaseClient parameters with <Database> for storage helpers.
web/lib/spaced-repetition.ts Types SupabaseClient parameter with <Database> for schedule updates.
web/lib/review-utils.ts Types SupabaseClient parameters and adjusts result typing for filtered problems.
web/lib/insights-utils.ts Types SupabaseClient parameters and casts digest reads under typed client.
web/lib/digest-generator.ts Casts JSON-ish payload fields to Json for typed inserts/updates.
web/lib/database.types.ts Adds generated Supabase schema/types (Database, Json, helpers).
web/lib/content-limits.ts Adjusts override typing to match DB-returned numeric/string values.
web/lib/categorise-error.ts Normalizes problem data for prompt building under stricter typing.
web/app/sitemap.ts Adjusts sitemap lastModified to tolerate nullable updated_at.
web/app/api/review-sessions/[sessionId]/route.ts Tightens typing around session_state JSON and persists healed state as Json.
web/app/api/review-sessions/[sessionId]/progress/route.ts Tightens typing around session_state JSON and read-only detection.
web/app/api/review-sessions/[sessionId]/complete/route.ts Tightens typing around session_state JSON and session summary typing.
web/app/api/qr-sessions/[sessionId]/status/route.ts Narrows status typing for API response correctness.
web/app/api/profile/route.ts Casts upsert payload to generated user_profiles.Insert type.
web/app/api/profile/avatar/route.ts Casts avatar upserts to generated user_profiles.Insert type.
web/app/api/problems/route.ts Casts status/type filters to generated enum arrays for typed .in(...) queries.
web/app/api/problems/[id]/attempt/route.ts Casts answer_config to AnswerConfig for typed answer marking.
web/app/api/problem-sets/[id]/view/route.ts Aligns RPC arg typing by omitting p_user_id when absent.
web/app/api/problem-sets/[id]/start-session/route.ts Tightens parsing/casting of filter_config + session_config JSON.
web/app/api/problem-sets/[id]/progress/route.ts Tightens parsing/casting of filter_config JSON for smart sets.
web/app/api/problem-sets/[id]/copy/route.ts Tightens filter_config typing and narrows inserted status literal type.
web/app/api/problem-sets/[id]/copy-problem/route.ts Tightens filter_config typing for membership checks.
web/app/api/attempts/route.ts Casts submitted_answer to Json for typed inserts.
web/app/api/attempts/[id]/route.ts Casts PATCH update payload to generated attempts.Update, with Json handling.
web/app/api/ai/categorise-error/[id]/route.ts Adjusts override reset update payload to satisfy typed updates.
web/app/api/admin/settings/route.ts Casts inserted settings value to Json for typed inserts.
web/app/[locale]/(app)/problem-sets/[id]/add-problems/page.tsx Casts fetched problems to app Problem[] for client component props.
web/app/[locale]/(app)/insights/page.tsx Casts initial digest to `InsightDigest
web/app/[locale]/(app)/insights/[subjectId]/page.tsx Casts digest to `InsightDigest
web/.nvmrc Pins local dev Node version to 24.
README.zh-CN.md Updates runtime requirement and points setup details to CONTRIBUTING.md.
README.md Updates runtime requirement and points setup details to CONTRIBUTING.md.
DEPLOYMENT.md Removes standalone deployment doc (content moved to CONTRIBUTING.md).
CONTRIBUTING.md Adds full contributor guide: Supabase local setup, env vars, DB workflow, tooling, deployment notes.
.github/workflows/i18n-check.yml Updates CI Node version used by i18n workflow to 24.
Files not reviewed (1)
  • web/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/supabase/config.toml
Comment thread web/lib/database.types.ts Outdated
Comment thread web/app/sitemap.ts
Comment thread web/lib/user-management.ts
Use ReviewSessionState['session_state'], Partial<FilterConfig>, and
generated DB row types instead of generic Record casts on Supabase
JSONB columns. Adds is_read_only to ReviewSessionState interface.
Seeds two auth users (test@example.com and admin@example.com) with
confirmed emails so contributors can log in immediately after db reset.
The existing handle_new_user trigger auto-creates user_profiles rows.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 48 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • web/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/lib/supabase/middleware.ts Outdated
Comment thread web/lib/review-utils.ts
Comment thread web/app/api/ai/categorise-error/[id]/route.ts
… casts

- Change Problem.tags, ProblemWithTags.tags, ProblemInSet.tags from Tag[]
  to SimpleTag[] to match the (id, name) select used in all tag queries
- Remove transformSimpleTagsToTags workaround in problem-form.tsx
- Replace as string[] admin role check with as const for type-safe comparison
- Use specific inline type for announcement value instead of Record
- Use DB row type for categoriseSingleAttempt return
…ion override

Validate that original_broad_category and original_granular_tag are
present before resetting, preventing an inconsistent state where
overridden values persist after is_user_override is flipped to false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants