https://github.com/rahul-shrivastav/leetcode-clone
CodeArena - A competitive coding platform where user can practise coding questions, made with NextJS, Python, Redis and MongoDB.
https://github.com/rahul-shrivastav/leetcode-clone
flask nextauth nextjs14 python tailwind-css tyepscript
Last synced: 16 days ago
JSON representation
CodeArena - A competitive coding platform where user can practise coding questions, made with NextJS, Python, Redis and MongoDB.
- Host: GitHub
- URL: https://github.com/rahul-shrivastav/leetcode-clone
- Owner: rahul-shrivastav
- Created: 2024-07-08T21:07:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-11-03T10:14:36.000Z (7 months ago)
- Last Synced: 2025-11-03T12:10:05.899Z (7 months ago)
- Topics: flask, nextauth, nextjs14, python, tailwind-css, tyepscript
- Language: TypeScript
- Homepage: https://codearena-pi.vercel.app/
- Size: 381 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CodeArena








Welcome to CodeArena – a platform for practicing and solving coding problems, similar to LeetCode. Built with Next.js 14, MongoDB, and NextAuth, CodeArena provides a smooth user experience to enhance your coding skills and connect with others.
[](https://codearena-pi.vercel.app/)
## Tech Stack
- `Next.js` : A React-based framework for building server-rendered and static web applications, offering features like routing, API handling, and optimized performance.
- `React.js` : A JavaScript library for building dynamic user interfaces with reusable components.
- `Node.js`: A server-side runtime that allows running JavaScript on the backend.
- `MongoDB ` : A NoSQL database that stores data in flexible, JSON-like documents.
- `Tailwind-CSS` : A utility-first CSS framework for building custom, responsive designs quickly by composing classes directly in HTML.
- `Redis` : An in-memory data structure store commonly used as a database, cache, and message broker. I used it as a message queue to efficiently manage and process background tasks.
## Workflow

- User submits code from the frontend (React or similar).
- API Service (Flask + Gunicorn) accepts the submission, stores metadata in MongoDB (status = pending), and pushes the job into Redis queue.
- Worker Service (Flask background service with thread pool) pulls jobs from Redis, executes user code safely (via subprocess or Docker depending on environment), and updates the MongoDB record with results.
- Frontend polls MongoDB via the API to check if submission results are available (status = executed).
## Getting Started
### 1. Clone the Repository
First, clone the repository to your local machine:
```bash
git clone https://github.com/rahul-shrivastav/Leetcode-clone.git
```
### 2. Install Dependencies
Install the required dependencies by running:
```bash
cd frontend
npm install
cd ../backend/api_service
pip install -r requirements.txt
cd ../execution_service
pip install -r requirements.txt
```
### 3. Setup Environment Variables
To run this project, you will need to add the following environment variables to your .env file
```bash
MONGO_DB_URI=
AUTH_SECRET =
GOOGLE_CLIENT_ID =
GOOGLE_CLIENT_SECRET =
NEXTAUTH_URL= http://localhost:3000
NEXT_PUBLIC_NEXTAUTH_URL= http://localhost:3000
NEXT_PUBLIC_SUBMIT_CODE_API= http://127.0.0.1:5000
SUBMIT_CODE_API= http://127.0.0.1:5000
NEXT_PUBLIC_WORKER_URL = http://127.0.0.1:5001
WORKER_URL = http://127.0.0.1:5001
REDIS_URL = redis://localhost:6379
NEXT_PUBLIC_REDIS_URL = redis://localhost:6379
```
A sample .evn file is also provided in the repository.
### 4. Run Dev server Locally
First, run the frontend and backend development server:
```bash
cd frontend
npm run dev
```
and locate to backend
```bash
cd api_service
python app.py
cd ../execution_service
python worker.py
```