QueryLab is an interactive web-based platform for learning and practicing SQL (SQLite) and MongoDB queries without any local installation. Perfect for students, developers, and anyone looking to master database querying skills.
๐ Try QueryLab Live
- ๐ Live Application: query-lab.vercel.app
- ๐ฆ GitHub Repository: github.com/manavbansal1/query-lab
- ๐ง Contact: bansalmanav39@gmail.com
- ๐ Report Issues: GitHub Issues
Latest Updates:
- MongoDB integration with session isolation
- AI-powered error explanations with Gemini
- Automatic session cleanup (24-hour retention)
- Responsive design for mobile devices
- Monaco Editor for better code editing experience
Coming Soon:
- ๐ Comprehensive documentation
- ๐๏ธ Database overview pages
- ๐ฏ Interactive tutorials
- ๐ Query performance metrics
- Zero Installation Required - Practice SQL and MongoDB directly in your browser
- Sample Databases - Pre-loaded datasets for Users & Orders, Blog, and E-commerce scenarios
- Isolated Sessions - Each user gets their own isolated database environment
- Real-Time Execution - See query results instantly
- Schema Visualization - View database structure before writing queries
- SQL (SQLite) - Runs entirely in the browser using sql.js
- MongoDB - Cloud-based with session isolation for multi-user support
- Gemini Integration - Get intelligent explanations for query errors
- Error Analysis - Understand what went wrong and how to fix it
- Learning Assistant - Helps students debug and improve their queries
- Responsive Design - Works on desktop, tablet, and mobile
- Code Editor - Syntax highlighting with Monaco Editor
- Clean Interface - Intuitive navigation and clear result display
- Auto-Cleanup - Old sessions automatically deleted after 24 hours
- Session Persistence - Your data persists across page refreshes
- Reset Option - Start fresh with new sample data anytime
- Custom Mode - Create your own tables and collections
- Node.js 16+ and npm
- MongoDB Atlas account (free tier)
- (Optional) Gemini API key for AI help feature
-
Clone the repository
git clone https://github.com/manavbansal1/query-lab.git cd query-lab
-
Install dependencies
npm install
-
Set up environment variables
Create a
.env.local
file in the root directory:# MongoDB Atlas Connection MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority # Gemini AI (Optional) GEMINI_API_KEY=your_gemini_api_key # EmailJS (Optional - for contact form) NEXT_PUBLIC_EMAILJS_SERVICE_ID=your_service_id NEXT_PUBLIC_EMAILJS_TEMPLATE_ID=your_template_id NEXT_PUBLIC_EMAILJS_PUBLIC_KEY=your_public_key
-
Run development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000
- Visit MongoDB Atlas
- Sign up for a free account
- Verify your email
- Click "Build a Database"
- Select FREE M0 tier
- Choose AWS and nearest region
- Click "Create"
-
Database Access:
- Add new database user
- Username:
querylab_user
- Generate secure password (save it!)
- Role: "Read and write to any database"
-
Network Access:
- Add IP Address
- Select "Allow Access from Anywhere" (0.0.0.0/0)
- Confirm
- Click "Connect" on your cluster
- Choose "Connect your application"
- Copy connection string
- Replace
<password>
with your actual password - Add to
.env.local
- Next.js 14 - React framework with App Router
- React 18 - UI library
- Monaco Editor - Code editor with syntax highlighting
- Bootstrap 5 - Responsive UI components
- React Icons - Icon library
- Next.js API Routes - Serverless functions
- MongoDB Node Driver - Database connectivity
- sql.js - SQLite in the browser
- Google Gemini - AI-powered error explanations
- EmailJS - Contact form service
- MongoDB Atlas - Cloud MongoDB (free tier)
- SQLite (sql.js) - Client-side SQL database
querylab/
โโโ src/
โ โโโ app/
โ โ โโโ api/
โ โ โ โโโ mongodb-query/
โ โ โ โ โโโ route.js # MongoDB query execution
โ โ โ โโโ cleanup-sessions/
โ โ โ โ โโโ route.js # Auto-cleanup old sessions
โ โ โ โโโ ask-gemini/
โ โ โ โโโ route.js # AI help integration
โ โ โโโ about/
โ โ โโโ databases/
โ โ โโโ documentation/
โ โ โโโ layout.js
โ โ โโโ page.jsx
โ โ โโโ globals.css
โ โโโ components/
โ โ โโโ docs/
โ โ โ โโโ CollapsibleSection.jsx
โ โ โ โโโ Examples.jsx
โ โ โ โโโ GettingStarted.jsx
โ โ โ โโโ MongoDBGuide.jsx
โ โ โ โโโ SQLGuide.jsx
โ โ โ โโโ TipsAndTricks.jsx
โ โ โโโ ClientLayout.jsx # Client-side wrapper
โ โ โโโ Contact.jsx # Contact modal
โ โ โโโ Navbar.jsx # Navigation bar
โ โ โโโ QueryTab.jsx # Main query interface
โ โโโ data/
โ โ โโโ SampleQueries.js # Sample queries & data
โ โโโ lib/
โ โ โโโ sqlite-manager.js # SQLite helper functions
โ โโโ styles/
โ โโโ Contact.css
โ โโโ Navbar.css
โ โโโ QueryTab.css
โโโ public/
โโโ .env.local # Environment variables (create this)
โโโ .gitignore
โโโ vercel.json # Vercel cron config
โโโ package.json
โโโ next.config.js
โโโ LICENSE
โโโ README.md
- Select Database Type: Choose from Users & Orders, Blog, E-commerce, or Custom
- View Schema: Click "Show" to see table structure
- Write Query: Use the Monaco editor with syntax highlighting
- Execute: Click "Execute Query" or press the play button
- View Results: See results in a formatted table
Example SQL Queries:
-- Find all users
SELECT * FROM users;
-- Join users with orders
SELECT u.name, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
GROUP BY u.id;
-- Filter by condition
SELECT * FROM orders WHERE amount > 100;
- Select Database Type: Choose from Users & Orders, Blog, E-commerce, or Custom
- View Schema: Click "Show" to see collection structure
- Write Query: Use MongoDB query syntax
- Execute: Click "Execute Query"
- View Results: See results in JSON format
Example MongoDB Queries:
// Find all users
db.users.find()
// Find with filter
db.orders.find({ amount: { $gt: 100 } })
// Sort and limit
db.posts.find().sort({ views: -1 })
// Count documents
db.users.countDocuments()
- Execute a query with an error
- Click "Ask Gemini for Help"
- Get AI-powered explanation and fix suggestions
- Learn from the mistakes
-
Push to GitHub
git add . git commit -m "Initial commit" git push origin main
-
Import to Vercel
- Visit vercel.com
- Click "New Project"
- Import your GitHub repository
-
Add Environment Variables
- Go to Project Settings โ Environment Variables
- Add
MONGODB_URI
(and optionallyGEMINI_API_KEY
) - Check: Production, Preview, Development
-
Deploy
- Click "Deploy"
- Wait 2-3 minutes
- Your site is live! ๐
The app automatically cleans up sessions older than 24 hours using Vercel Cron Jobs (configured in vercel.json
):
- Runs daily at 3 AM UTC
- Deletes old session collections
- Keeps MongoDB storage under control
- Learn SQL and MongoDB syntax
- Practice queries without installation
- Get immediate feedback on errors
- Experiment safely with isolated data
- Provide hands-on database exercises
- No setup required for students
- Track common query mistakes
- Share live examples during lectures
- Quick SQL/MongoDB testing
- Prototype queries before production
- Compare SQL vs MongoDB syntax
- Refresh database skills
QueryLab is a solo passion project, but contributions are welcome! Whether it's bug reports, feature suggestions, or code contributions, I appreciate all help.
- Fork the repository: github.com/manavbansal1/query-lab
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- ๐ Report bugs you encounter
- ๐ก Suggest new features or improvements
- ๐ Improve documentation
- ๐จ Enhance UI/UX design
- ๐งช Write tests
- ๐ Add translations
Every contribution, no matter how small, is valued! ๐
This project is licensed under the MIT License - see the LICENSE file for details.
- sql.js - SQLite compiled to JavaScript
- MongoDB Atlas - Free cloud MongoDB hosting
- Google Gemini - AI-powered help
- Next.js - Amazing React framework
- Vercel - Seamless deployment platform
QueryLab is built and maintained by Manav Bansal, a solo developer passionate about making database education accessible to everyone. This is a passion project created in my free time to help students and developers learn databases without installation barriers.
If QueryLab has helped you, please consider:
- โญ Starring the repository on GitHub
- ๐ข Sharing it with friends and colleagues
- ๐ Reporting bugs or suggesting features
- ๐ฌ Spreading the word on social media
Your support and feedback drive this project forward! ๐
Manav Bansal - Developer & Creator
- ๐ง Email: bansalmanav39@gmail.com
- ๐ GitHub: @manavbansal1
- ๐ Live Site: query-lab.vercel.app
Project Repository: github.com/manavbansal1/query-lab
If you find QueryLab helpful, please consider:
- โญ Star the repository on GitHub
- ๐ Report bugs you encounter
- ๐ก Suggest features you'd like to see
- ๐ข Share QueryLab with friends, colleagues, and students
- ๐ฌ Spread the word on social media
Your support helps QueryLab grow and improve! ๐
Made with ๐ by Manav Bansal for students learning databases