This is a full-stack application built with Turborepo, Next.js, Express.js, and Kafka. It provides a web interface for users to submit code, which is then processed by a backend service via a message queue for execution.
This project is a monorepo containing several applications and shared packages.
/
├── apps/
│ ├── web/ (Package name: "contest_frontend") - The Next.js frontend application.
│ ├── server/ (Package name: "codeeditor") - The main backend Express.js server.
│ ├── docs/ (Package name: "docs") - The documentation site.
│ └── kafka-server/ (Package name: "kafka-server") - Handles incoming code submissions.
└── packages/
├── ui/ - Shared React components.
├── eslint-config/ - Shared ESLint configuration.
└── typescript-config/ - Shared TypeScript configuration.
- Monorepo Architecture: Managed with Turborepo for efficient development and builds.
- Next.js Frontend: A modern, server-rendered React application for the user interface.
- Express.js Backend: A robust Node.js server to handle API requests and business logic.
- Asynchronous Code Execution: Uses Kafka as a message broker to queue and process code submissions reliably.
- Database Integration: Connects to MongoDB Atlas for data persistence.
- Live Development: Uses
nodemonfor automatic backend restarts. - Containerized Services: Uses Docker to run essential services like Kafka.
Before you begin, ensure you have the following installed on your system:
- Node.js (v18 or later)
- npm (comes with Node.js)
- Docker Desktop
- A MongoDB Atlas account and a cluster set up.
Follow these steps to get the project running on your local machine.
Clone this project to your local machine.
git clone <your-repository-url>
cd CODEEASYInstall all the necessary dependencies for all packages from the root directory.
npm installYour backend server needs a .env file to connect to your database.
-
Navigate to the main backend server directory:
cd apps/server. -
Create a new file named
.env. -
Add your MongoDB Atlas connection string to this file. Remember to replace
<username>,<password>, and other placeholders with your actual database user credentials.DATABASE_URI=mongodb+srv://<username>:<password>@your-cluster-address.mongodb.net/your_database_name?retryWrites=true&w=majority -
Navigate back to the root directory:
cd ../...
This project requires Kafka to be running. We use Docker to manage this.
- Ensure Docker Desktop is open and running.
- In a separate terminal window, navigate to the project root and run:
docker-compose up
- Leave this terminal window running. It is now your Kafka server.
All commands should be run from the root directory of the project.
To start all applications (contest_frontend, codeeditor, etc.) at once:
npm run devTo run a specific application, use the --filter flag with the package's official name.
-
To run the Frontend Web App:
npm run dev -- --filter=contest_frontend
This will start the Next.js app, typically on
http://localhost:3000. -
To run the Backend Server:
npm run dev -- --filter=codeeditor
This will start the Express.js server, typically on
http://localhost:8000. -
To run the Worker Script (
server1.js):npm run dev:worker -- --filter=codeeditor
The system is designed to accept code submissions via a dedicated Kafka endpoint.
To send a file to the Kafka server for processing, send it to:
http://localhost:3003
(This endpoint is likely managed by the kafka-server application.)
Before the application can use a topic, it must be created. For example, to create the CPP topic for C++ code submissions:
- Make sure your Docker Kafka container is running.
- Open a new terminal and run the following command from the project root:
You should see a confirmation message:
docker-compose exec kafka kafka-topics --create --topic CPP --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1Created topic CPP.
To build all applications for production, run the following command from the root directory:
npm run buildThis Turborepo includes:
- TypeScript for static type checking.
- ESLint for code linting.
- Prettier for code formatting.


