{"id":49571254,"url":"https://github.com/sagargupta16/code-arena","last_synced_at":"2026-05-03T14:04:47.137Z","repository":{"id":352337651,"uuid":"1200647276","full_name":"Sagargupta16/code-arena","owner":"Sagargupta16","description":"Real-time competitive coding arena - race friends on LeetCode problems with built-in timer, scoring, and live leaderboards","archived":false,"fork":false,"pushed_at":"2026-04-27T01:47:32.000Z","size":192,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-27T03:34:25.248Z","etag":null,"topics":["coding-challenge","competitive-programming","developer-tools","fastapi","leetcode","multiplayer","python","react","real-time","websocket"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sagargupta16.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-03T16:59:23.000Z","updated_at":"2026-04-27T01:46:37.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Sagargupta16/code-arena","commit_stats":null,"previous_names":["sagargupta16/code-arena"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Sagargupta16/code-arena","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fcode-arena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fcode-arena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fcode-arena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fcode-arena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sagargupta16","download_url":"https://codeload.github.com/Sagargupta16/code-arena/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fcode-arena/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32571464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coding-challenge","competitive-programming","developer-tools","fastapi","leetcode","multiplayer","python","react","real-time","websocket"],"created_at":"2026-05-03T14:04:43.729Z","updated_at":"2026-05-03T14:04:47.130Z","avatar_url":"https://github.com/Sagargupta16.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code Arena\n\nReal-time competitive coding platform where 2-5 friends race to solve LeetCode problems with built-in C++ and Python execution.\n\n## Features\n\n- **GitHub OAuth** -- sign in with GitHub, no passwords\n- **Private rooms** -- 6-character code, 2-5 players\n- **Random LeetCode problems** -- filtered by difficulty and tags, with real function signatures\n- **Built-in code execution** -- C++ and Python in sandboxed containers via Piston\n- **Two modes** -- Blind Race (no peeking) and Live Status Board\n- **LeetCode-style editor** -- Monaco Editor with language toggle, test cases panel, submission results\n- **Server-authoritative timer** -- real-time sync via WebSocket\n- **Scoring** -- speed + attempts + test cases passed\n\n## Tech Stack\n\n| Layer | Technology |\n|-------|-----------|\n| Frontend | React 19, TypeScript, Vite, Tailwind CSS, Monaco Editor |\n| Backend | FastAPI, Python 3.13, WebSocket, Motor (async MongoDB) |\n| Auth | GitHub OAuth, JWT (python-jose) |\n| Database | MongoDB 7 |\n| Code Execution | Piston (self-hosted, sandboxed) |\n| Problem Source | alfa-leetcode-api + LeetCode GraphQL |\n| Orchestration | Docker Compose |\n\n## Quick Start\n\n### Prerequisites\n\n- Docker Desktop\n- Python 3.13+\n- Node.js 20+ with pnpm\n\n### Run with Docker Compose (full stack)\n\n```bash\ngit clone https://github.com/Sagargupta16/code-arena.git\ncd code-arena\ncp .env.example .env\n# Fill in GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET (see Auth Setup below)\ndocker compose up -d\n```\n\n### Run locally (dev mode)\n\n```bash\n# Start MongoDB and LeetCode API via Docker\ndocker compose up mongodb leetcode-api -d\n\n# Fill in .env with GitHub OAuth credentials and set:\n#   MONGO_URI=mongodb://localhost:27017/code_arena\n#   LEETCODE_API_URL=http://localhost:3000\n#   VITE_API_URL=  (leave empty)\n#   VITE_WS_URL=   (leave empty)\n\n# Start both backend and frontend\npnpm install\npnpm dev\n```\n\n- Frontend: http://localhost:5173\n- Backend API docs: http://localhost:8000/docs\n\n### Auth Setup (GitHub OAuth)\n\n1. Go to https://github.com/settings/developers\n2. Click **New OAuth App**\n3. Fill in:\n   - **Application name:** `Code Arena`\n   - **Homepage URL:** `http://localhost:5173`\n   - **Authorization callback URL:** `http://localhost:5173/auth/callback`\n4. Copy **Client ID** and generate a **Client Secret**\n5. Add them to `.env`:\n   ```\n   GITHUB_CLIENT_ID=your-client-id\n   GITHUB_CLIENT_SECRET=your-client-secret\n   ```\n\n## Development\n\n```bash\n# Both backend + frontend (from root)\npnpm dev\n\n# Backend only\ncd backend \u0026\u0026 pip install -r requirements.txt \u0026\u0026 uvicorn main:app --reload --port 8000\n\n# Frontend only\ncd frontend \u0026\u0026 pnpm install \u0026\u0026 pnpm dev\n\n# Run backend tests\ncd backend \u0026\u0026 python -m pytest tests/ -v\n\n# Run a single test\ncd backend \u0026\u0026 python -m pytest tests/test_scoring.py -v\n```\n\n## Project Structure\n\n```\ncode-arena/\n  docker-compose.yml           # MongoDB, Piston, LeetCode API, backend, frontend\n  leetcode-api.Dockerfile      # Custom build for alfa-leetcode-api\n  package.json                 # Root scripts (pnpm dev runs both)\n  backend/\n    main.py                    # FastAPI app entry point\n    app/\n      config.py                # Pydantic settings from .env\n      db.py                    # MongoDB connection (Motor)\n      deps.py                  # Auth dependency (JWT verification)\n      routes/                  # auth, rooms, problems, users\n      services/                # auth, judge, problem, room, scoring\n      models/                  # Pydantic models (user, room, problem, submission)\n      ws/                      # WebSocket handlers + connection manager\n    tests/                     # 21 tests (auth, judge, problems, rooms, scoring, ws)\n  frontend/\n    src/\n      pages/                   # Landing, Login, AuthCallback, Dashboard, Lobby, Arena, Results\n      components/              # Editor, ProblemPanel, TestResults, Timer, Navbar, etc.\n      hooks/                   # useAuth, useWebSocket, useTimer\n      services/                # REST API client, WebSocket client\n      context/                 # AuthContext (GitHub OAuth + JWT)\n      types/                   # TypeScript interfaces\n```\n\n## How It Works\n\n1. **Sign in** with GitHub OAuth\n2. **Create a room** -- pick difficulty, mode (blind/live), timer settings\n3. **Share the code** -- friends join with the 6-character room code\n4. **Start the match** -- host starts, a random LeetCode problem is fetched with real function signatures\n5. **Compete** -- write and submit code in the LeetCode-style editor\n6. **Results** -- scored by speed, attempts, and test cases passed\n\n## Scoring\n\n- **Full Solve:** `1000 - seconds - (50 * failed_attempts)`, minimum 100\n- **Partial (fallback):** when nobody fully solves, scored by `(passed/total) * 1000 - time_penalty`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagargupta16%2Fcode-arena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagargupta16%2Fcode-arena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagargupta16%2Fcode-arena/lists"}