SQL Dojo is an interactive web-based SQL learning platform that enables users to practice SQL queries directly in their browser. The platform provides structured challenges, real-time feedback, AI-powered assistance, and progress tracking.
Key Value Propositions:
- No database installation required
- No server setup or configuration
- No account creation or signup
- Immediate hands-on practice with real PostgreSQL
Primary: Aspiring data analysts, CS students, career changers, professionals refreshing SQL skills
Secondary: Bootcamp instructors, interviewers, self-learners
- Provide 30+ unique SQL challenges across three difficulty tiers (beginner, intermediate, advanced)
- Display challenge prompt with clear success criteria and starter SQL
- Validate user query results against expected output
- Tag challenges with SQL concepts (JOIN, GROUP BY, etc.)
- Support multiple database contexts (employees, e-commerce, movies)
- Execute SQL queries entirely in browser using PGlite (PostgreSQL WASM)
- Support full PostgreSQL syntax and functions
- Execute queries within 500ms for typical workloads
- Isolate database instances to prevent cross-contamination
- Handle SQL syntax errors gracefully with helpful messages
- Compare user query results against expected results
- Validate both schema (column names/order) and data (row content)
- Display user results and expected results side-by-side
- Show execution time for performance awareness
- Provide on-demand hints via Claude 3.5 Sonnet
- Stream hints in real-time for responsive UX
- Provide context-aware hints based on challenge, user query, and schema
- Guide users toward correct SQL concepts without providing complete solutions
- Gracefully degrade if API key not configured
- Track completed challenges, total points, and daily streak
- Persist progress to browser localStorage
- Calculate and display completion percentage
- Provide progress reset functionality with confirmation
- Syntax highlighting for SQL (CodeMirror 6)
- Keyboard shortcuts (Cmd/Ctrl+Enter to run)
- SQL autocomplete suggestions
- Dark theme for reduced eye strain
- Display all tables and columns for current database
- Update when switching databases
- Remain visible while editing queries
- Record every query execution (up to 50 per user)
- Display timestamp and success/failure status
- Allow loading previous queries back into editor
- Filter history by current challenge
- Unrestricted SQL query interface
- Database switching (employees, e-commerce, movies)
- Support both read and write operations
- CSV export of results
- Filter challenges by SQL concepts
- Support multiple concept selection
- Show challenge count for each concept
- Initial page load: < 2 seconds on 3G
- PGlite initialization: < 2 seconds
- Query execution: < 500ms
- Result rendering: < 100ms
- WCAG 2.1 AA compliance
- Full keyboard navigation
- ARIA labels for interactive elements
- Screen reader support
- Validate all API inputs with Zod schemas
- Sanitize user queries to prevent XSS
- Store API keys server-side only
- Rate limiting on AI hint endpoint
- PGlite runs in WASM sandbox (isolated)
- Chrome, Firefox, Safari, Edge (latest 2 versions)
- WebAssembly support required
- Responsive: mobile (320px+), tablet (768px+), desktop (1024px+)
- TypeScript strict mode
- Test coverage > 70%
- ESLint + Prettier for code quality
- Component files < 150 lines
| Category | Technology |
|---|---|
| Framework | SvelteKit 2 + Svelte 5 |
| Styling | UnoCSS |
| Database | PGlite (PostgreSQL WASM) |
| Editor | CodeMirror 6 |
| AI | Vercel AI SDK + Anthropic Claude |
| Validation | Zod |
| Testing | Vitest + Playwright |
interface Challenge {
id: string;
title: string;
prompt: string;
difficulty: 'beginner' | 'intermediate' | 'advanced';
points: number;
database: 'employees' | 'ecommerce' | 'movies';
starterSQL: string;
solutionSQL: string;
concepts: string[];
}
interface ProgressState {
completed: Record<string, boolean>;
points: number;
streak: number;
lastCompletedDate: string | null;
attempts: number;
}
interface HistoryEntry {
id: string;
sql: string;
timestamp: string;
success: boolean;
challengeId: string;
}Employees: departments, employees, dept_manager, dept_emp, salaries
E-commerce: customers, products, orders, order_items
Movies: movies, actors, directors, movie_actors
src/
├── lib/
│ ├── components/ # UI components
│ ├── stores/ # Svelte 5 stores
│ ├── logic/ # Business logic (runner.ts)
│ ├── data/ # Challenge definitions
│ ├── hooks/ # Custom hooks
│ ├── services/ # API and security services
│ └── utils/ # Helper functions
├── routes/
│ ├── +page.svelte # Main application
│ └── api/hint/ # AI hint endpoint
tests/
├── e2e/ # Playwright E2E tests
└── *.test.ts # Unit tests
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY |
No | Anthropic API key for AI hints |
- Browser-only execution: All SQL runs client-side in PGlite
- No authentication: Free, anonymous access
- English only: All content in English
- Static challenges: No user-generated content
- Version: 2.0.0
- Last Updated: 2025-12-21
- Status: Production