Skip to content

About

SAT Reading/Writing trainer — Nest + React, trap diagnostics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

44 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScoreBetter

Bundled practice while Supabase is unavailable

The default signed-in page serves 1,406 distinct Reading & Writing questions from a bundled OpenSAT/PineSAT snapshot. No Supabase connection or provider request is needed at runtime. Answers and source explanations stay on the backend until submission. Source answers have not been independently reviewed.

Progress is saved per account in that browser, with the existing 1-day wrong answer and 3/7/14/30-day correct-answer review intervals. Clearing browser data removes progress; it does not sync across devices or migrate automatically into Supabase. The original nine-question diagnostic quiz is at /?quiz=originals. The existing /?admin=true Supabase development view is still separate.

Snapshot provenance is documented in backend/src/practice/SOURCE.md.

Local agent note

  • Supabase question rows can be inspected at http://localhost:5173/?admin=true while the local frontend and backend are running.
  • The view reads public.question_drafts through the backend; it currently shows all rows, including drafts. The current project returned 1,000 rows, all with review_status: draft as of 2026-10-09.
  • Local Supabase credentials belong in ignored backend/.env as SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY. Never expose the service key in frontend config, commits, or chat.
  • User-specific practice history is stored in public.user_question_memory. Apply backend/supabase/migrations/202610100001_user_question_memory.sql after the question-pipeline migration before testing memory. The local ?admin=true view lets you switch between ALLOWED_EMAILS; wrong answers return in 1 day and consecutive correct answers use 3, 7, 14, then 30 day intervals. This practice route remains local-development-only.
  • Current work branch: feat/supabase-questions-ui.

SAT Reading & Writing practice: multi-question quiz flow, per-option marking (Answer / Maybe / Eliminate), diagnostic labels, and server-side answer checking. The backend also provides a private question draft pipeline for source imports, AI diagnosis, and reviewed approval.

Structure

backend/    NestJS API (bundled practice banks, answer checking)
frontend/   React + Vite UI

Run

Two terminals:

cd backend  && npm install && npm run dev   # http://localhost:3000
cd frontend && npm install && npm run dev   # http://localhost:5173

To skip Magic Link sign-in while developing locally, set DEV_AUTH_BYPASS=1 in backend/.env and VITE_DEV_AUTH_BYPASS=1 in frontend/.env.local, then restart both servers. Vite applies the frontend setting only in development, and the backend ignores the bypass when NODE_ENV=production.

With the local bypass enabled and Supabase configured on the backend, open /?admin=true to inspect rows in question_drafts. This development view shows question text and review status without returning answer keys or diagnosis data to the browser.

API

  • GET /api/questions — all questions for the quiz UI. Omits correct answers, rankings, and authored analysis.
  • GET /api/question — the first question in the bank (same shape as one element of /api/questions).
  • POST /api/submit — body: { questionId, selectedOptionId, secondChoiceOptionId, eliminatedOptionIds }. Browser-imported questions also include a validated authoredQuestion used only when the ID is absent from the server bank. Returns { correct, correctOptionId, trapOptionId, selectedOptionId, secondChoiceWasCorrect, label, explanation, trapExplanation }.

For server-bank questions, authored rankings and analysis live only on the server and are never sent to the client before submission. Rank 1 is the correct answer; rank 2 is the authored primary trap.

User-imported questions are different: the separately supplied JSON file contains the full grading metadata, so its answers and analysis are available to the person importing it and are stored in that browser's local storage. The backend receives the imported question transiently for grading but does not add it to the shared question bank or persist it.

Question bank

  • backend/src/questions/sat-reading-writing.questions.ts is the canonical nine-question runtime bank and contains only original ScoreBetter practice items.
  • Four human-reviewed originals live in backend/src/questions/sat-reading-writing.replacement-candidates.ts and are included in the canonical bank.

The optional browser JSON import remains available for custom questions. The quiz rejects duplicate IDs and IDs that collide with the server bank. Importing or clearing a file starts a fresh quiz session.

Private question pipeline

Apply backend/supabase/migrations/202610070001_question_pipeline.sql to a Supabase project and configure these backend environment variables:

  • ADMIN_EMAIL: exact account allowed to use pipeline endpoints (must also be in ALLOWED_EMAILS).
  • SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY: server-only database access.
  • QUESTION_SOURCES: optional JSON array of additional or overridden source connectors. OpenSAT/PineSAT English is included by default. Each connector has id, an HTTPS endpoint, optional itemsPath, nextCursorPath, and cursorParameter, plus permission fields store, process, serve, and evidence. The endpoint returns a JSON array (or an array at itemsPath); records need an id or questionId. Keep this configuration and credentials private. A source is only syncable when storage and processing are allowed and permission evidence is recorded.
  • AI_API_URL, AI_API_KEY, and AI_MODEL: optional OpenAI-compatible chat completions endpoint for diagnosis. Model output is always unreviewed.

After signing in with the admin account, open /?admin=questions to review private drafts. The screen can diagnose the next 20 unanswered drafts, edit and save a human-reviewed diagnosis, then approve drafts one at a time. Approval requires the diagnosis to be explicitly saved as reviewed.

All pipeline routes require the admin session:

  • POST /api/admin/question-pipeline/sources/:sourceId/sync
  • GET /api/admin/question-pipeline/drafts
  • PATCH /api/admin/question-pipeline/drafts/:id with a draft and/or diagnosis object
  • POST /api/admin/question-pipeline/drafts/:id/diagnose
  • POST /api/admin/question-pipeline/drafts/:id/approve

Approval requires permission to store, process, and serve, plus a complete and structurally valid diagnosis. Drafts stay in the private staging table and do not enter the student quiz bank. Configure only sources whose content rights and intended use have been verified; public API access alone is not permission. The built-in opensat-pinesat connector maps the English endpoint's nested question text, passage, A-D choices, answer key, explanation, domain, and difficulty into ScoreBetter drafts. It resolves repeated provider IDs using a content hash, batches writes, and leaves existing drafts untouched on re-sync. The recorded permission note links OpenSAT's database terms and notes that item-level provenance has not been independently audited. College Board's undocumented endpoint is not configured, and PDF/image upload extraction is not included yet.

Marking rules

Each option can be marked Answer, Maybe, or Eliminate. Answer and Maybe are exclusive — assigning either moves it off whichever option held it. Clicking an option's current mark clears it. Submit requires an Answer.

Tests

cd backend  && npm test              # unit tests (diagnostic classifier, submit)

With both servers running:

cd frontend && npm run e2e        # headless Cypress
cd frontend && npm run e2e:open   # interactive

Deploy

On Vercel (free, one project)

This repo is a Vercel Services app: Vite frontend + NestJS API on one URL. Leave Root Directory empty so Vercel reads the root vercel.json.

  1. Push to GitHub.
  2. In Vercel: Add New Project → import this repo. Framework should be Services.
  3. Deploy. You get a production URL (e.g. scorebetter.vercel.app).
  4. Test: open the URL, load questions, import a JSON file, submit answers.
  5. Share the site URL.

The browser calls /api on the same host. If the UI is on a different Vercel project, set VITE_API_URL to the API origin (with or without /api) and redeploy the frontend. Imported questions stay in that browser's localStorage. The original diagnostic bank contains original practice items; the default practice view uses the bundled source snapshot.

Next steps

Persistence, auth, AI explanations, and expanding the original practice bank.

About

SAT Reading/Writing trainer — Nest + React, trap diagnostics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages