One workspace for SQL, relational algebra, tuple calculus and ER diagrams. Write a query, see the theory behind it, and move between them without leaving the page.
Features · Screenshots · Getting started · How it works · Project layout
Database courses teach the same ideas in four different notations: SQL, relational algebra, tuple relational calculus and ER diagrams. Most tools cover only one of them, and most need a server or an account.
QueryCraft puts all four in one browser app, runs on the same sample data, and lets you translate between them.
- Nothing to install or sign up for. SQL runs in your browser through SQLite compiled to WebAssembly. There is no database server and no account.
- Theory and practice side by side. An algebra expression shows its evaluation tree and step results, then converts to SQL. A calculus expression converts to SQL and runs against the same tables.
- Your work stays yours. Queries, history and diagrams are saved in your browser's
localStorageand never leave your machine. - Built for practice. Bundled datasets, a table generator and a searchable reference mean you can start learning in seconds.
| SQL Sandbox | In-browser SQL editor with syntax highlighting and autocomplete, a schema browser, statement-level results, query history, CSV export and SQL file import. Covers DDL, DML, joins, transactions, users and privileges, stored routines, triggers and cursors, with a MySQL compatibility layer on top of SQLite. |
| Relational Algebra | Expression editor with a symbol palette (σ π ρ γ τ, set operations and every join type). Shows a parsed expression tree, intermediate results for each step, and a translation to SQL. |
| Tuple Relational Calculus | Write { <t.name, t.gpa> | students(t) ∧ t.gpa > 3.5 } style queries, convert them to SQL and run them against your tables. |
| ER Diagram Builder | Drag-and-drop canvas with entities, weak entities, relationships and key, multivalued, derived and composite attributes. Ships with University, Banking and Credentia presets, exports to PNG and converts the diagram to relational tables. |
| Table Generator | Define tables and columns, and QueryCraft picks realistic Faker-based sample data from the column name. Handles foreign keys across tables and outputs ready-to-run CREATE and INSERT SQL. |
| Learn | Searchable SQL and DBMS reference, from DDL and joins to transactions, DCL, routines and relational algebra, with runnable examples. |
| Themes | Multiple editor and UI themes, dark and light, including Tokyo Night, Catppuccin Mocha, Nord and One Dark Pro. |
All screenshots are taken from the running app using the bundled university dataset.
Prerequisites: Node.js 22.13+ (22.x), 24.x or 26+, and npm.
git clone https://github.com/Cosmos-0118/QueryCraft.git
cd QueryCraft
npm install
npm run devOpen http://localhost:3000. No environment variables are needed.
npm install also copies the sql.js WebAssembly runtime into public/ through the postinstall script.
| Command | What it does |
|---|---|
npm run dev |
Start the development server |
npm run build |
Create a production build |
npm run start |
Serve the production build |
npm run lint |
Run ESLint with zero warnings allowed |
npm run typecheck |
Type-check without emitting files |
npm run format |
Format the repository with Prettier |
npm run test |
Run the Vitest suite once |
npm run test:watch |
Run Vitest in watch mode |
npm run sync:sql-wasm |
Re-copy the sql.js WASM runtime to public/ |
flowchart LR
SQL[SQL Sandbox] --> E[SqlExecutor<br/>sql.js · SQLite WASM]
ALG[Relational Algebra] -->|translate to SQL| E
TRC[Tuple Calculus] -->|translate to SQL| E
ER[ER Builder] -->|convert to tables| SQL
GEN[Table Generator] -->|CREATE + INSERT| SQL
SEED[(seed/datasets)] -->|/api/datasets| E
E --> UI[Results, trees, history]
- Execution.
SqlExecutorwraps sql.js. A translation layer rewrites MySQL syntax to SQLite, and emulates admin commands such asSHOWandDESCRIBE, privileges, procedures, triggers and cursors. See MySQL compatibility limitations for the cases it cannot match. - Seed data. Bundled datasets in
seed/datasets(banking,credentia,university) are served byGET /api/datasetsand loaded into the engine on start. - State. Zustand stores, persisted to
localStorage. Nothing is sent to a server. - Diagrams. The ER canvas is built on
@xyflow/react, with PNG export throughhtml-to-image.
| Area | Tools |
|---|---|
| Framework | Next.js (App Router, Turbopack), React 19, TypeScript |
| SQL engine | sql.js (SQLite compiled to WebAssembly) |
| Editor | CodeMirror 6 with @codemirror/lang-sql |
| State | Zustand |
| Styling | Tailwind CSS v4, Framer Motion, Lucide icons |
| Data | Faker for sample data, Zod for validation |
| Testing | Vitest |
| Route | Page |
|---|---|
/ |
Landing page |
/learn |
SQL and DBMS reference |
/sandbox, /sandbox/history |
SQL Sandbox and its query history |
/algebra, /algebra/history |
Relational algebra and its history |
/tuple-calculus, /tuple-calculus/history |
Tuple calculus and its history |
/er-builder |
ER diagram builder |
/generator |
Table generator |
/our-team, /privacy, /terms |
About and policy pages |
GET /api/datasets |
Seed datasets from seed/datasets |
src/
app/ Routes (landing page, dashboard workspaces, API)
features/ sandbox, algebra, tuple-calculus, er-builder, generator, our-team
shared/ SQL engine, UI components, storage helpers
styles/ Global styles and theme tokens
seed/datasets/ Bundled sample databases (JSON)
tests/ Vitest suites (SQL executor, PL/SQL runtime, app helpers)
docs/ Documentation and README images
scripts/ Build-time helpers (sql.js WASM sync)
npm run testThe suite covers the SQL executor (DDL, DML, DCL, transactions, procedures, triggers, cursors and MySQL compatibility), statement splitting, the PL/SQL runtime, the data generator's column hinting and session persistence. See tests/README.md for the folder layout.
Note
TypeScript stays on 6.0.x because the ESLint TypeScript parser needs a version below 6.1, and ESLint stays on 9.x because Next's React, accessibility and import plugins do not yet support ESLint 10.





