CookOff 10.0 featured an in-house developed portal, the platform where we hosted the 10th edition of our premier competitive coding challenge, uniting hundreds of coders in an intense contest. This platform is designed to provide a seamless and robust experience for participants, featuring a powerful code editor, real-time scoring, and persistent progress tracking.
The portal is deployed and accessible at: https://cookoff.codechefvit.com/
This project is built with a modern, robust, and scalable tech stack:
- Framework: Next.js (with Turbopack)
- Language: TypeScript
- Styling: Tailwind CSS with
tailwind-merge
andclsx
- UI Components: Shadcn/UI
- State Management: Zustand
- Form Handling: React Hook Form & Zod
- Code Editor: CodeMirror
- HTTP Client: Axios
- Authentication: Firebase Authentication
- Notifications: React Hot Toast
- Advanced Code Editor: Powered by CodeMirror, supporting multiple languages (Python, Java, C++, etc.), themes, and keybindings.
- Progress Restoration: Your code, selected language, and current round are automatically saved to
localStorage
, allowing you to resume your session anytime. - Auto-Submission: Code is automatically submitted when the timer runs out, ensuring no progress is lost.
- Resizable Layout: A flexible and resizable panel layout to customize your workspace.
- Real-time Scoreboard: Users can monitor their scores in real time as they complete rounds.
- Multi-language Support: The portal uses the Monaco editor, with support for many languages like Python, Java, C++, etc.
- Secure Authentication:
- Real-time Compiler Feedback: Get instant feedback on your code with detailed compiler messages and test case results.
The application is designed as a highly interactive and real-time single-page application (SPA) built on Next.js. The frontend architecture is centered around a clean, component-based structure and a centralized state management system.
-
Component-Based Structure: The UI is built using React and organized into a set of reusable components. Larger components, such as the
Dashboard
andEditor
, are composed of smaller, more focused components. -
Routing: Next.js App Router is used for navigation, providing a file-system-based routing mechanism that supports nested layouts and server-side rendering.
-
State Management: Zustand is employed for global state management. It offers a simple, unopinionated, and scalable way to manage state that is shared across multiple components, such as user authentication status, editor content, and submission results.
The core of the application's state is managed by a single Zustand store, useKitchenStore
. This store is the single source of truth for the "Kitchen" (the main coding environment).
-
State Slices: The store is organized into logical slices:
- Session State:
round
,selectedQuestionId
,submissionStatus
. - Editor State:
codeByQuestion
,languageByQuestion
,selectedLanguage
. - Data:
questions
,testCases
. - UI State:
fullScreenEditor
,showModal
, etc. - Results:
testResults
,compilerDetails
.
- Session State:
-
Persistence: The
persist
middleware is used to save critical state tolocalStorage
. This includes:codeByQuestion
: The code for each question.languageByQuestion
: The selected language for each question.round
: The user's current round.
This ensures that a user can refresh the page or close the tab without losing their progress.
-
Component Interaction:
Editor
: The editor component reads and writes code to the store usingsetCodeForQuestion
.LanguageSelector
: This component updates theselectedLanguage
andlanguageByQuestion
slices.TestCases
: Displays results fromtestResults
andcompilerDetails
.
To get a local copy up and running, follow these simple steps.
- Node.js (v20 or later)
- pnpm
- Fork the repository.
- Clone your forked repository:
git clone https://github.com/<Your-Username>/cookoff-portal-10.0.git
- Install the dependencies:
pnpm install
- Set up your environment variables by creating a
.env
file. You can useexample.env
as a template. - Start the development server:
pnpm dev
The application will be available at http://localhost:3000
.
- Backend: https://github.com/CodeChefVIT/cookoff-10.0-be
- Admin Panel: https://github.com/CodeChefVIT/cookoff-admin-X
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- 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
Distributed under the MIT License. See LICENSE
for more information.
Made with β€οΈ by CodeChef-VIT