## Inspiration

The way we learn to code can be really dull. Traditional coding platforms make it feel like homework that you can do anytime. There's no rush, no pressure. It gets repetitive quickly. We wanted to change that and make it more exciting, like a game.

We aimed to build something a platform where people can connect play with friends and grow together. CodeDuel is more than matching with random opponents. It helps developers challenge peers climb the ranks as a community and turn grind into a shared journey to master software engineering.

## What it does

CodeDuel is a web arena where two developers compete directly in real-time.

  • The Core Loop: Players join the matchmaking queue get paired based on their skill level and face the coding problem with a 15-minute countdown. The first to solve the problem and pass test cases wins, updating ELO ratings instantly.

  • The Social Layer: Players can create custom lobbies, challenge friends to settle bets make connections and track progress on a leaderboard.

  • AI Coaching: If a player gets stuck an integrated AI coach provides hints to help them think through the problem without giving away the solution.

## How we built it

CodeDuel uses a serverless architecture eliminating the need for a server. We built it with Next.js (App Router) for API routes and the core game engine. To handle an user base we decoupled data into two streams:

  • The Hot Path (Amazon DynamoDB): We use DynamoDB for changing data like the live matchmaking queue and live score updates. This ensures data safety and low latency.

  • The Cold Path (AWS Aurora PostgreSQL): We use Aurora PostgreSQL for data that doesn't change often like user accounts and historical match archives.

  • Execution & AI: Code execution runs natively through Piston. Ai features are powered by the Gemini 2.0 Flash Engine.

## Challenges we ran into

  • Decoupling Data Streams Safely: Our biggest challenge was ensuring data integrity when syncing state between two database systems. We had to record match results across both systems without blocking the client UI.

  • React State Closures in Fast Polling Loops: We hit stale React state closure traps due to client-side polling. We resolved this by anchoring state streams to reference tokens and implementing unmount lifecycles.

  • Ghost Abandons and Network False Positives: We built a custom heartbeat system to detect when a player abruptly closes their tab mid-match.

## Accomplishments that we're proud of

  • True Serverless Multiplayer: We built a low-latency multiplayer game engine on serverless architecture with zero persistent server costs.

  • Data Layer Synchronization: We designed a hot/cold data system that bridges NoSQL speed with SQL persistence under intense traffic.

  • Socratic AI Guardrails: We engineered AI prompts that teach developers without writing code for them preserving the competitive integrity of the arena.

## What we learned

  • Smart Data Splitting Architecture: We learned that real-time web applications don't require heavy server setups. Splitting operations between Amazon DynamoDB and AWS Aurora PostgreSQL allows us to scale seamlessly while keeping costs

  • State Machine Predictability: Using state transition rules eliminated edge-case bugs and race conditions.

## What's next for CodeDuel

  • True WebSockets Integration: Upgrading to an AWS API Gateway WebSocket layer for instant keystroke and presence updates.

  • Deep Social Ecosystem: Expanding features, with dedicated friend lists, persistent player profiles and collaborative team modes.

  • Anti-Cheat Hardening: Implementing plagiarism detection filters, tab-focus monitoring and clipboard paste rate limits to ensure matches.

Built With

Share this project:

Updates