Skip to content

esoyeon/web-sql-drill

Repository files navigation

SQL Drill

Practice SQL against real PostgreSQL — in your browser. Problems are generated on demand by your local Claude Code subscription. Open source, runs entirely on your machine.

No accounts, no hosted database, no API keys. Clone it, run it, practice.

Why

Most SQL practice gives you a prompt and an answer — but no table to look at and no way to actually run your query. SQL Drill spins up a real Postgres database (PGlite/WASM) in the browser for every problem, so you see the actual tables, real error messages, and result-set grading.

  • Real Postgres in the browserPGlite runs an in-memory Postgres per problem (schema + seed data loaded for you).
  • AI-generated problems — a thin local backend calls claude -p to generate a {schema, seed, prompt, solution} problem, then runs it through PGlite to verify it works before it ever reaches you (self-repairs up to 2× on failure).
  • Deterministic grading — your result set is compared to the reference solution's. No LLM needed to tell you right from wrong.
  • Chat tutor — ask "what's a window function?", get hints, or have your wrong answer diagnosed — all in one conversational panel that sees the problem, schema, and your current query.

Prerequisites

  • Node 20+
  • Claude Code installed and logged in (/login done). The backend calls claude -p to generate problems, reusing your existing subscription — so there's nothing extra to pay or configure.

Quick start

npm install
npm run dev      # starts the web app (Vite) + local backend (Express) together

Then open the printed localhost URL. Pick a topic/difficulty, get a problem, write SQL, run it, and get graded.

Other commands

npm run dev:web      # frontend only
npm run dev:server   # backend only
npm run build        # production build
npm run typecheck    # tsc --noEmit

How it works

[Browser: Vite + React + TS]
  PGlite (WASM)  real Postgres, one in-memory DB per problem
  CodeMirror     SQL editor
  grading        compare your result set vs the reference solution (deterministic)
        │  POST /api/generate
[Local backend: Express]
  execFile("claude", ["-p", prompt, "--output-format", "json"])
  → validates the generated problem against PGlite, self-repairs, returns it

The browser only ever receives problems that have been executed and verified server-side.

Status

Early but usable (v0.0.1). Core loop — generate → see tables → run → grade — works end to end, plus the chat tutor. Hosted / bring-your-own-API-key versions are possible later; today it's a local tool. Issues and PRs welcome.

License

MIT recommended. Add a LICENSE file (with your name) before making the repo public.

About

Practice SQL against real PostgreSQL in your browser (PGlite), with problems generated by your local Claude Code.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors