Modern SQL practice lab built with SvelteKit 2, Svelte 5 runes, UnoCSS, PGlite (PostgreSQL in WASM), CodeMirror 6, and Vercel AI SDK + Anthropic for streaming hints.
- 30+ SQL Challenges across beginner, intermediate, and advanced difficulty levels
- 3 Real-World Databases (employees, e-commerce, movies) with realistic schemas
- In-Browser PostgreSQL powered by PGlite (WASM) - no server required
- AI-Powered Hints from Claude 3.5 Sonnet to guide your learning
- Progress Tracking with points, streaks, and completion rates
- Query History to review and reload past attempts
- Concept Filtering to focus on specific SQL topics (JOINs, GROUP BY, etc.)
- CSV Export for query results
- Playground Mode for free-form SQL experimentation
- Modern Code Editor with CodeMirror 6, syntax highlighting, and Cmd/Ctrl+Enter shortcuts
- Full Accessibility with ARIA labels, keyboard navigation, and screen reader support
- Node.js 18+ and npm
- Clone the repository
- Install dependencies:
npm install- Create a
.envfile (optional, for AI hints):
cp .env.example .env- Add your Anthropic API key to
.env:
ANTHROPIC_API_KEY=your_api_key_here
Get your API key from Anthropic Console
- Start the development server:
npm run devThe app will be available at http://localhost:5173
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production build
npm run check- Run TypeScript type checkingnpm run lint- Run ESLint and Prettier checksnpm run format- Auto-format code with Prettier
npm test- Run unit tests with Vitestnpm run test:watch- Run tests in watch modenpm run test:coverage- Generate test coverage reportnpm run test:e2e- Run end-to-end tests with Playwrightnpm run test:e2e:ui- Run E2E tests with UInpm run test:all- Run all tests (unit + E2E)
- Frontend Framework: SvelteKit 2 + Svelte 5 (with runes)
- Styling: UnoCSS (Tailwind-compatible)
- Database: PGlite (PostgreSQL WASM)
- Code Editor: CodeMirror 6
- AI Integration: Vercel AI SDK + Anthropic Claude 3.5 Sonnet
- Type Safety: TypeScript 5.9 (strict mode)
- Testing: Vitest + Playwright + Testing Library
src/
├── lib/
│ ├── components/ # Reusable UI components
│ │ ├── ChallengeSelector.svelte
│ │ ├── ChallengeEditor.svelte
│ │ ├── ProgressDashboard.svelte
│ │ ├── SchemaExplorer.svelte
│ │ ├── Playground.svelte
│ │ ├── QueryHistory.svelte
│ │ ├── ConceptFilter.svelte
│ │ ├── Editor.svelte
│ │ └── ResultsTable.svelte
│ │
│ ├── stores/ # Svelte 5 stores
│ │ ├── progressStore.svelte.ts
│ │ └── queryHistoryStore.svelte.ts
│ │
│ ├── logic/ # Business logic
│ │ └── runner.ts # SQL execution & validation
│ │
│ ├── data/ # Static data
│ │ └── challenges.ts # Challenge definitions & DB seeds
│ │
│ ├── utils/ # Utility functions
│ │ └── index.ts # Helpers (debounce, CSV export, etc.)
│ │
│ └── types.ts # TypeScript type definitions
│
├── routes/
│ ├── +page.svelte # Main application page
│ ├── +layout.svelte # Root layout
│ └── api/hint/+server.ts # AI hint API endpoint
│
└── app.html # HTML shell
tests/
├── e2e/ # Playwright E2E tests
└── ... # Unit tests co-located with source
-
Performance Optimization
- PGlite instance pooling to reduce WASM initialization overhead
- Debounced localStorage writes to prevent performance issues
- Parallel query execution for challenge validation
-
Code Quality
- Modular component architecture (from 415-line monolith to focused components)
- Centralized state management with Svelte 5 stores
- Comprehensive JSDoc documentation
- Input validation with Zod schemas
-
User Experience
- Progress reset functionality
- Concept-based filtering for challenges
- Query history with timestamp tracking
- CSV export for results
- Enhanced accessibility (ARIA labels, keyboard navigation)
- Better error messages and validation
-
Developer Experience
- Full testing infrastructure (Vitest + Playwright)
- Type-safe API endpoints
- Utility functions with unit tests
- Clear separation of concerns
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY |
No* | Anthropic API key for AI hints |
*The app works without the API key, but AI hints will not be available.
- Push your code to GitHub
- Import the project to Vercel
- Add
ANTHROPIC_API_KEYenvironment variable - Deploy
The app uses adapter-auto which automatically detects your deployment platform. For other platforms, you may need to install a specific adapter:
# For Node.js
npm install -D @sveltejs/adapter-node
# For static hosting
npm install -D @sveltejs/adapter-staticUpdate svelte.config.js to use your chosen adapter.
departments- Department informationemployees- Employee records with hire dates and salariesdept_manager- Department manager assignmentsdept_emp- Department employee assignmentssalaries- Salary history
customers- Customer profilesproducts- Product catalogorders- Order recordsorder_items- Order line items
movies- Film catalog with ratingsactors- Actor profilesdirectors- Director profilesmovie_actors- Actor-movie relationships
Contributions are welcome! Please feel free to submit issues or pull requests.
MIT
- Built with SvelteKit
- Powered by PGlite
- AI hints by Anthropic Claude
- Styled with UnoCSS