Cook Off 10.0
Competitive programming IDE built on Next.js and CodeMirror 6 serving 1,000+ contest participants with triple-layer state persistence.
- Timeline
- Sep 2025 — Feb 2026
- Stack
- Next.js · React · TypeScript · JavaScript · C++ · Tailwind CSS · Zustand · CodeMirror 6 · MongoDB
- Links
- Source on GitHub
The problem
During a timed competitive coding contest with 1,000+ participants, a browser refresh or last-minute submission spike can wipe out a contestant's code or drop auth tokens.
- Hundreds of contestants compiling and submitting simultaneously in the final minutes create 40%+ concurrent load spikes.
- Relying only on in-memory React state loses code on accidental tab refresh or network drop.
How it works
- 01
CodeMirror 6 multi-language IDE
Built a low-latency browser code editor supporting C++, Python, Java, and JavaScript with syntax diagnostics and custom keymaps. - 02
Triple-layer state persistence
Combined Zustand in-memory state with synchronous LocalStorage write-through caching and debounced MongoDB background checkpoints so zero code is lost on refresh. - 03
Resilient Axios interceptor pipeline
Centralized JWT refresh, request queuing, and test-case execution polling to sustain 40% concurrent contest traffic without dropped submissions.
Architecture
Triple-layer persistence from CodeMirror 6 to Zustand, LocalStorage, and MongoDB.
- 01CodeMirror 6 keystrokes
Contestants write and test solutions across languages in real time.
- 02Zustand state orchestration
Active problem buffers, language selections, and test results update with zero re-render lag.
- 03Write-through LocalStorage backup
Every edit persists locally so a browser crash or refresh recovers instantaneously.
- 04Authenticated Axios submission queue
Interceptors attach tokens and handle retries during peak submission bursts.
- 05MongoDB checkpoint & judge verdict
Submissions are evaluated and persisted for 1,000+ participants.
Contest scale
- active contest participants served
- 1,000+
- persistence layers (Zustand, LocalStorage, MongoDB)
- 3
- peak concurrent contest load sustained
- 40%
- lost code submissions across the event
- 0
Technical deep dive
Complete system specification, schemas, and implementation notes.
The ultimate real-time competitive programming platform built to handle hundreds of concurrent coders without breaking a sweat.
The Problem
During live coding contests, hundreds of users submit code, save drafts, and run tests simultaneously in the final 5 minutes. Most platforms crash, lose drafts, or lag out, ruining the contest experience.
The Outcome
A flawless, real-time contest experience with zero dropped submissions and sub-second compiler feedback for over 1,000 users.
How It Works (The Mechanism)
- Triple-Layer Persistence: Code state is guaranteed through in-memory Zustand state, automatic browser
localStoragepersistence, and durable MongoDB storage. - Custom CodeMirror 6 Editor: Built a customized editor that handles syntax highlighting, auto-completion, and real-time syncing without blocking the main thread.
- Auto-Submission: Code is automatically submitted when the timer runs out, ensuring no participant loses progress.
- Optimized Server Actions: Reduced payload sizes and utilized Next.js Server Components to render the live leaderboard instantly.
Frontend System Design & State Management
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.
Frontend Architecture
- Component-Based Structure: The UI is built using React and organized into a set of reusable components. Larger components, such as the
DashboardandEditor, 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.
Zustand State Management (useKitchenStore)
The coding part 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
persistmiddleware 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 theselectedLanguageandlanguageByQuestionslices.TestCases: Displays results fromtestResultsandcompilerDetails.
The Value Stack
- Framework: Next.js (with Turbopack)
- Language: TypeScript
- Styling: Tailwind CSS with
tailwind-mergeandclsx - UI Components: Shadcn/UI
- State Management: Zustand
- Form Handling: React Hook Form & Zod
- Code Editor: CodeMirror 6
- HTTP Client: Axios
- Notifications: Firestore, React Hot Toast
Detailed Features
- Advanced Code Editor: Powered by CodeMirror 6, 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 CodeMirror 6 IDE supports multiple contest languages including Python, Java, C++, and C.
- Real-time Compiler Feedback: Get instant feedback on your code with detailed compiler messages and test case results.
Login Interface

Live Dashboard

The Kitchen (Code Editor)

The Proof
- Sustained 40% concurrent load across 1,000+ users without a single dropped submission.
- Maintained sub-second response times during peak submission windows.
- Delivered a rock-solid, scalable platform for CodeChef-VIT's premier event.