SQLBench is a comprehensive platform designed for developers to practice and master SQL through real-world problems. It provides an interactive environment to write, execute, and test SQL queries against isolated database instances.
- Interactive SQL Compiler: Write and execute SQL queries directly in the browser with real-time feedback.
- Problem Library: A curated collection of SQL problems ranging from basic SELECT statements to complex recursive CTEs.
- Real-time Execution: Queries are executed against a real PostgreSQL database environment.
- Progress Tracking: Track your solved problems and view your progress on the dashboard.
- Authentication: Secure user accounts using Email/Password or Google authentication.
- Leaderboard: Compete with other users and see where you stand.
- Dark Mode: Fully supported dark mode interface.
- Framework: Next.js 14+ (App Router)
- Language: TypeScript
- Database: PostgreSQL
- ORM: Prisma
- Authentication: NextAuth.js
- Styling: Tailwind CSS
- UI Components: Shadcn UI
- Queue Management: Bull / Redis
Follow these instructions to set up the project locally.
- Node.js (v18 or higher)
- PostgreSQL
- Redis (for the submission queue)
-
Clone the repository:
git clone https://github.com/yourusername/sqlbench.git cd sqlbench -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root directory and add the following variables:DATABASE_URL="postgresql://user:password@localhost:5432/sqlbench" NEXTAUTH_SECRET="your-secret-key" NEXTAUTH_URL="http://localhost:3000" GOOGLE_CLIENT_ID="your-google-client-id" GOOGLE_CLIENT_SECRET="your-google-client-secret" REDIS_URL="redis://localhost:6379"
-
Initialize the database:
npx prisma generate npx prisma db push
-
Seed the database (optional):
npm run prisma:seed
-
Run the development server:
npm run dev
Open http://localhost:3000 with your browser to see the application.
app/: Next.js App Router pages and API routes.api/: Backend API endpoints.compiler/: The main problem-solving interface.dashboard/: User dashboard and progress.
components/: Reusable UI components.lib/: Utility functions, database clients, and core logic.prisma/: Database schema and seed scripts.public/: Static assets.
Contributions are welcome. Please feel free to submit a Pull Request.
This project is licensed under the MIT License.