PR
Pratham-Prog861/code-compete
A competitive coding platform built with Next.js, featuring real-time code execution, problem tracking, and leaderboard rankings.
Code Compete ๐
A competitive coding platform built with Next.js, featuring real-time code execution, problem tracking, and leaderboard rankings.
Features โจ
- Problem Solving: Solve coding problems with multiple difficulty levels (Easy, Medium, Hard)
- Multi-Language Support: Write solutions in JavaScript, Python, C++, and Go
- Real-Time Code Execution: Execute code using Piston API with instant feedback
- Test Case Validation: Detailed test results showing input, expected output, and actual output
- Progress Tracking: Track solved problems and earn points for each solution
- Leaderboard: Compete with other users and climb the rankings
- Authentication: Secure user authentication with Clerk
- Modern UI: Beautiful, responsive interface built with Tailwind CSS and shadcn/ui
Tech Stack ๐ ๏ธ
- Framework: Next.js 16 (App Router)
- Database: PostgreSQL with Neon
- ORM: Drizzle ORM
- Authentication: Clerk
- Code Editor: Monaco Editor (VS Code editor)
- Code Execution: Piston API
- Styling: Tailwind CSS
- UI Components: shadcn/ui, Radix UI
- Markdown Rendering: react-markdown with syntax highlighting
Getting Started ๐
Prerequisites
- Node.js 18+ installed
- PostgreSQL database (Neon recommended)
- Clerk account for authentication
Installation
1.Clone the repository:
git clone https://github.com/Pratham-Prog861/code-compete.git
cd code-compete2.Install dependencies:
npm install3.Set up environment variables:
Create a .env.local file in the root directory:
# Database
DATABASE_URL=your_neon_database_url
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up4.Push the database schema:
npx drizzle-kit push5.Seed the database with sample problems:
npx tsx src/db/seed.ts6.Run the development server:
npm run devOpen http://localhost:3000 to view the application.
Project Structure ๐
code-compete/
โโโ src/
โ โโโ app/ # Next.js app router pages
โ โ โโโ api/ # API routes
โ โ โ โโโ submit/ # Code submission endpoint
โ โ โโโ leaderboard/ # Leaderboard page
โ โ โโโ problems/ # Problems listing and detail pages
โ โ โโโ profile/ # User profile page
โ โโโ components/ # React components
โ โ โโโ code-editor.tsx # Monaco code editor component
โ โ โโโ navbar.tsx # Navigation bar
โ โ โโโ ui/ # shadcn/ui components
โ โโโ db/ # Database configuration
โ โ โโโ schema.ts # Drizzle schema definitions
โ โ โโโ index.ts # Database connection
โ โ โโโ seed.ts # Database seeding script
โ โโโ lib/ # Utility functions
โ โโโ piston.ts # Piston API integration
โ โโโ utils.ts # Helper functions
โโโ public/ # Static assets
โโโ drizzle.config.ts # Drizzle ORM configurationDatabase Schema ๐
- problems: Coding problems with descriptions, test cases, and starter code
- testCases: Input/output test cases for each problem
- submissions: User code submissions with status and timestamps
- solvedProblems: Tracks which problems each user has solved
- userStats: User statistics including points and problems solved
Features in Detail ๐
Problem Solving
- View problem descriptions with markdown formatting
- Write code in an integrated Monaco editor
- Select from multiple programming languages
- Run code and see detailed test results
Points System
- Earn points by solving problems (10 points for Easy problems)
- Points are awarded only on first successful solve
- Track your total points and rank on the leaderboard
Leaderboard
- Real-time rankings based on total points
- Displays user names, profile pictures, and email
- Special badges for top 3 users
- Shows problems solved count and total points
Scripts ๐
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpx drizzle-kit push- Push database schema changesnpx tsx src/db/seed.ts- Seed database with problems
Contributing ๐ค
Contributions are welcome! Please feel free to submit a Pull Request.
License ๐
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments ๐
- Piston for code execution
- Clerk for authentication
- shadcn/ui for UI components
- Monaco Editor for the code editor
On this page
Contributors
MIT License
Created December 9, 2025
Updated December 9, 2025