Skip to content

Amarnath27me/SQLit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—„οΈ SQLit

LeetCode for SQL β€” Practice with Real Datasets, Get Instant Feedback

Live Demo License: MIT Python Next.js FastAPI PostgreSQL

πŸš€ Try it Live Β· πŸ“– Docs Β· 🀝 Contribute


What is SQLit?

SQLit is a free, open-source SQL practice platform β€” like LeetCode, but purpose-built for databases. Write real queries against real schemas, get instant results in the browser, and level up from beginner to expert.

Whether you're prepping for a data engineering or analytics interview, learning SQL from scratch, or sharpening your window functions β€” SQLit has you covered with 412 curated problems, real-world datasets, and a built-in query optimizer.

No account required to start. No setup needed. Just open the browser and write SQL.


Table of Contents


Features

πŸ“ Practice Problems

  • 412 curated problems across Easy, Medium, and Hard difficulties
  • Covers JOINs, subqueries, CTEs, window functions, aggregations, and more
  • Problems organized by concept tags and categories
  • Hints, explanations, and multiple solution approaches for every problem

⚑ In-Browser SQL Engine

  • Write and execute SQL directly in the browser β€” no setup required
  • Supports SQLite (instant, client-side fallback) and PostgreSQL (production sandbox)
  • MySQL dialect support via automatic syntax translation
  • Sandboxed execution with timeout protection and rate limiting

πŸ—‚οΈ Real-World Datasets

Domain Tables
πŸ›’ E-Commerce customers, orders, products, reviews
πŸ’° Finance accounts, transactions, portfolios, market data
πŸ₯ Healthcare patients, diagnoses, prescriptions, appointments

Interactive dataset explorer with schema diagrams, column types, and sample data.

πŸ” Query Optimization Lab

  • Visual EXPLAIN plan analyzer with color-coded node types
  • See Seq Scan vs Index Scan, Nested Loop vs Hash Join
  • Learn to read and optimize execution plans hands-on

πŸ—οΈ Database Design Studio

  • Interactive ER Diagram Builder β€” drag-and-drop entities on an SVG canvas
  • Add tables, columns (19 PostgreSQL types), primary keys, and foreign keys
  • Export to SQL DDL with one click
  • Import from SQL β€” paste CREATE TABLE statements and get a visual diagram
  • Schema normalization guide and best practices

🎯 Interview Prep

  • Timed SQL challenges simulating real interview conditions
  • Company-style question sets (FAANG, startups, finance)
  • Difficulty progression from phone screen to on-site level

πŸ“… Daily Challenges

  • Fresh SQL problem every day with a countdown timer
  • Streak tracking to keep you consistent

πŸ“Š Profile & Progress

  • GitHub-style activity heatmap showing your full solve history
  • Concept badges β€” earn Beginner β†’ Learner β†’ Proficient β†’ Expert β†’ Master per topic
  • XP system with level progression
  • Track solved problems, accuracy, and streaks

πŸ› οΈ Developer Experience

  • Light and dark theme with smooth toggle
  • Resizable editor panels
  • Syntax-highlighted SQL editor with auto-formatting
  • Mobile-responsive design

Screenshots

πŸ“Έ Screenshots coming soon β€” try the live demo in the meantime.


Tech Stack

Layer Technology
Frontend Next.js 16, TypeScript, Tailwind CSS 4
Backend FastAPI, Python 3.12, Uvicorn
Database PostgreSQL (production), SQLite (fallback)
State Zustand with localStorage persistence
Auth Auth0 (optional)
Deployment Vercel (frontend) + Railway (backend)

Project Structure

SQLit/
β”œβ”€β”€ frontend/                  # Next.js app
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/               # Pages (App Router)
β”‚   β”‚   β”‚   β”œβ”€β”€ (main)/        # All authenticated routes
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ practice/  # Problem list + solver
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ datasets/  # Dataset explorer
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ db-design/ # ER builder + normalization
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ optimization/ # EXPLAIN visualizer
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ interview/ # Interview prep
β”‚   β”‚   β”‚   β”‚   └── profile/   # Activity heatmap + badges
β”‚   β”‚   β”‚   └── api/           # API route proxies
β”‚   β”‚   β”œβ”€β”€ components/        # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ stores/            # Zustand state stores
β”‚   β”‚   └── lib/               # Utilities, API client, schemas
β”‚   └── package.json
β”‚
β”œβ”€β”€ backend/                   # FastAPI app
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/               # Route handlers
β”‚   β”‚   β”œβ”€β”€ core/              # Config, auth, database, rate limiter
β”‚   β”‚   β”œβ”€β”€ datasets/          # E-commerce, Finance, Healthcare
β”‚   β”‚   β”œβ”€β”€ models/            # SQLAlchemy models
β”‚   β”‚   └── services/          # Query executor, problem service
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── requirements.txt
β”‚
└── docker-compose.yml         # Full-stack local development

Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Python 3.11+
  • PostgreSQL 16+ (optional β€” SQLite fallback works out of the box)

1. Clone the repository

git clone https://github.com/Amarnath27me/SQLit.git
cd SQLit

2. Start the backend

cd backend
python -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env            # Edit if you have PostgreSQL
uvicorn app.main:app --port 8001 --reload

The API will be running at http://localhost:8001. Test it:

curl http://localhost:8001/health
# β†’ {"status": "ok", "service": "sqlit-api"}

3. Start the frontend

cd frontend
npm install
cp .env.local.example .env.local
npm run dev

Open http://localhost:3000 and start practicing!

4. Full stack with Docker (recommended)

docker-compose up --build

This starts the frontend, backend, and PostgreSQL together in one command.


Deployment

Frontend β†’ Vercel
  1. Push this repo to GitHub
  2. Go to vercel.com β†’ Import your repo
  3. Set Root Directory to frontend
  4. Add environment variable: BACKEND_URL = your Railway backend URL
  5. Deploy
Backend β†’ Railway
  1. Go to railway.com β†’ New Project β†’ Deploy from GitHub
  2. Set Root Directory to backend
  3. Add environment variables from backend/.env.example
  4. Deploy β€” Railway auto-detects the Dockerfile

API Reference

Method Endpoint Description
GET /health Health check
GET /api/problems List all problems (with filters)
GET /api/problems/{slug} Get problem details
POST /api/query/execute Execute SQL query in sandbox
GET /api/progress Get user progress

Full API docs available at http://localhost:8001/docs (Swagger UI) when running locally.


Roadmap

  • AI-powered query reviewer β€” get natural language feedback on your SQL
  • Docker-based query sandbox for full execution isolation
  • Skill tree visualization β€” see your learning path across concepts
  • More datasets β€” education, social media, logistics, SaaS metrics
  • Onboarding tutorial tour for new users
  • Community solutions β€” browse and upvote top solutions per problem
  • SQL interview simulator β€” live timer, hints disabled, score report

Contributing

Contributions are welcome! If you'd like to help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m 'Add your feature'
  4. Push to the branch: git push origin feature/your-feature
  5. Open a Pull Request

High-priority areas:

  • Adding new datasets (education, social media, logistics)
  • More SQL problems (especially hard-level window function challenges)
  • AI-powered query review integration
  • UI/UX improvements

Please open an issue first for major changes so we can discuss the approach.


License

This project is open source and available under the MIT License.


Built with ❀️ for the SQL community by Amarnath Allamraju

⭐ If SQLit helped you, consider starring the repo!

Releases

No releases published

Packages

 
 
 

Contributors