Skip to content

genus-lang/CPDuel-frontend

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

62 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CP Duel

CP Duel is a modern, competitive programming duel platform where users can challenge each other to real-time coding battles, view live leaderboards, and experience a LeetCode-like problem-solving interface.


πŸš€ Features

  • 1v1 Coding Duels with real-time status tracking
  • Tournament Bracket Playoffs with bracket visualization
  • Multi-tier Leaderboards (Round, Semi-final, Final, and Winner)
  • LeetCode-style Problem Solving UI with integrated code editor
  • Real-time Timer and opponent status monitoring
  • Firebase Authentication with protected routes
  • Practice Sheets for different algorithmic topics (DP, Graphs, Trees, Range Queries)
  • Contest Management with create/join functionality
  • Statistics Dashboard for performance tracking
  • Responsive, dark-themed UI optimized for all devices

πŸ“ Project Structure

cp-duel/
β”œβ”€β”€ πŸ“„ README.md                    # Project documentation
β”œβ”€β”€ πŸ“„ package.json                 # Node.js dependencies and scripts
β”œβ”€β”€ πŸ“„ vite.config.js               # Vite build configuration
β”œβ”€β”€ πŸ“„ eslint.config.js             # ESLint linting configuration
β”œβ”€β”€ πŸ“„ vercel.json                  # Vercel deployment configuration
β”œβ”€β”€ πŸ“„ index.html                   # Main HTML entry point
β”‚
β”œβ”€β”€ πŸ“ public/                      # Static assets served directly
β”‚   β”œβ”€β”€ πŸ–ΌοΈ images.png               # Platform images/screenshots
β”‚   β”œβ”€β”€ πŸ–ΌοΈ react.svg                # React logo
β”‚   └── πŸ–ΌοΈ vite.svg                 # Vite logo
β”‚
└── πŸ“ src/                         # Source code directory
    β”œβ”€β”€ πŸ“„ App.jsx                  # Main application component with routing
    β”œβ”€β”€ πŸ“„ main.jsx                 # React application entry point
    β”œβ”€β”€ πŸ“„ index.css                # Global CSS styles and Tailwind imports
    β”‚
    β”œβ”€β”€ πŸ“ assets/                  # Static assets used in components
    β”‚   β”œβ”€β”€ πŸ–ΌοΈ gfg.svg              # GeeksforGeeks logo
    β”‚   └── πŸ–ΌοΈ lc.svg               # LeetCode logo
    β”‚
    β”œβ”€β”€ πŸ“ components/              # Reusable React components
    β”‚   β”œβ”€β”€ πŸ” login.jsx            # User login form component
    β”‚   β”œβ”€β”€ πŸ” Signup.jsx           # User registration form component
    β”‚   β”œβ”€β”€ πŸ›‘οΈ ProtectedRoute.jsx   # Route protection wrapper component
    β”‚   β”œβ”€β”€ 🧭 Navbar.jsx           # Navigation header component
    β”‚   β”œβ”€β”€ 🦢 Footer.jsx           # Site footer component
    β”‚   β”œβ”€β”€ πŸ† ContestList.jsx      # Display list of available contests
    β”‚   β”œβ”€β”€ 🎯 ContestCard.jsx      # Individual contest display card
    β”‚   β”œβ”€β”€ 🏁 ContestBracket.jsx   # Tournament bracket visualization
    β”‚   β”œβ”€β”€ πŸ“Š LeaderboardCard.jsx  # Individual leaderboard entry
    β”‚   β”œβ”€β”€ βž• CreateContest.jsx    # Contest creation form
    β”‚   β”œβ”€β”€ πŸ“ CreateProblem.jsx    # Problem creation form
    β”‚   β”œβ”€β”€ πŸ“‹ ProblemForm.jsx      # Problem input/editing form
    β”‚   β”œβ”€β”€ πŸ“œ ProblemList.jsx      # List of problems display
    β”‚   β”œβ”€β”€ ⭐ FavoriteList.jsx     # User's favorite problems
    β”‚   β”œβ”€β”€ πŸ‘οΈ ViewQuestionComponent.tsx # Problem viewing interface
    β”‚   └── πŸ“ ui/                  # UI component library (Radix UI components)
    β”‚
    β”œβ”€β”€ πŸ“ pages/                   # Page-level components (route destinations)
    β”‚   β”œβ”€β”€ 🏠 HomePage.jsx         # Landing page with platform overview
    β”‚   β”œβ”€β”€ πŸ† ContestPage.jsx      # Contest lobby and management
    β”‚   β”œβ”€β”€ πŸ₯Š ContestStartPage.tsx # Live contest interface with code editor
    β”‚   β”œβ”€β”€ 🏁 ContestBracketPage.jsx # Tournament bracket view
    β”‚   β”œβ”€β”€ πŸ“Š ContestLeaderboardPage.jsx # Contest-specific leaderboards
    β”‚   β”œβ”€β”€ πŸ… LeaderboardPage.jsx  # Global platform leaderboards
    β”‚   β”œβ”€β”€ πŸ“š SheetsPage.jsx       # Practice sheets overview
    β”‚   β”œβ”€β”€ 🧠 DPSheetPage.jsx      # Dynamic Programming practice sheet
    β”‚   β”œβ”€β”€ πŸ•ΈοΈ GraphSheetPage.jsx   # Graph algorithms practice sheet
    β”‚   β”œβ”€β”€ 🌳 TreeSheetPage.jsx    # Tree algorithms practice sheet
    β”‚   β”œβ”€β”€ πŸ“Š RangeQuerySheetPage.jsx # Range query algorithms practice sheet
    β”‚   β”œβ”€β”€ πŸ“ˆ StatsPage.jsx        # User statistics and analytics
    β”‚   └── πŸ’» ProblemSolvingPage.tsx # Individual problem solving interface
    β”‚
    β”œβ”€β”€ πŸ“ contexts/                # React Context providers
    β”‚   └── πŸ” AuthContext.jsx      # Authentication state management
    β”‚
    β”œβ”€β”€ πŸ“ hooks/                   # Custom React hooks
    β”‚   └── πŸ”— useApi.js            # API interaction custom hook
    β”‚
    β”œβ”€β”€ πŸ“ config/                  # Configuration files
    β”‚   └── 🌐 server.js            # Server configuration settings
    β”‚
    β”œβ”€β”€ πŸ“ utils/                   # Utility functions and helpers
    β”‚   β”œβ”€β”€ 🌐 apiClient.js         # HTTP client for API requests
    β”‚   β”œβ”€β”€ πŸ“Š contestLeaderboardData.js # Contest leaderboard data handlers
    β”‚   β”œβ”€β”€ 🧠 dpSections.js        # Dynamic Programming section data
    β”‚   β”œβ”€β”€ πŸ… leaderboardData.js   # Global leaderboard data handlers
    β”‚   β”œβ”€β”€ πŸ“ problemData.js       # Problem data management
    β”‚   β”œβ”€β”€ πŸ› οΈ utils.jsx            # General utility functions
    β”‚   └── πŸ“ firebase/            # Firebase integration
    β”‚       └── πŸ”₯ firebase.js      # Firebase configuration and initialization
    β”‚
    β”œβ”€β”€ πŸ“ styles/                  # Component-specific stylesheets
    β”‚   └── 🎨 login.css            # Login component specific styles
    β”‚
    β”œβ”€β”€ πŸ“ data/                    # Static data files and mock data
    └── πŸ“ lib/                     # Third-party library configurations

πŸ—οΈ Architecture Overview

Frontend Framework

  • React 19.1.0 with functional components and hooks
  • Vite 6.3.5 for fast development and optimized builds
  • React Router DOM 7.6.0 for client-side routing and navigation

State Management

  • React Context API for global authentication state
  • Custom hooks for API interactions and data fetching
  • Local storage for token persistence

Styling & UI

  • Tailwind CSS 4.1.6 for utility-first styling
  • Radix UI components for accessible, unstyled UI primitives
  • React Icons for consistent iconography
  • Responsive design with mobile-first approach

Code Editor Integration

  • Monaco Editor (VS Code editor) for in-browser code editing
  • React Monaco Editor wrapper for React integration
  • Syntax highlighting and IntelliSense support

Authentication & Security

  • Firebase Authentication for user management
  • Protected routes with authentication guards
  • token management with automatic refresh
  • Secure API communication with token-based auth

Data Visualization

  • Recharts for statistics and performance charts
  • React Circular Progressbar for timer and progress indicators
  • Custom tournament brackets with SVG-based visualization

Development Tools

  • ESLint for code quality and consistency
  • TypeScript support for select components
  • Hot Module Replacement for fast development
  • Environment variables for configuration management

πŸ”§ Key Components Breakdown

Authentication System

  • AuthContext.jsx: Centralized authentication state with Firebase integration
  • login.jsx & Signup.jsx: User authentication forms with validation
  • ProtectedRoute.jsx: Route guard component for authenticated access

Contest Management

  • ContestPage.jsx: Main contest interface with lobby functionality
  • ContestStartPage.tsx: Live contest environment with real-time features
  • CreateContest.jsx: Contest creation with customizable parameters
  • ContestBracket.jsx: Tournament bracket visualization and progression

Problem Solving Interface

  • ProblemSolvingPage.tsx: Full-featured coding environment
  • ViewQuestionComponent.tsx: Problem statement renderer with LaTeX support
  • Monaco Editor integration for code editing with syntax highlighting

Practice Sheets System

  • Topic-specific practice sheets (DP, Graphs, Trees, Range Queries)
  • Curated problem sets for algorithmic learning
  • Progress tracking and difficulty progression

Leaderboard System

  • Global and contest-specific leaderboards
  • Real-time ranking updates during contests
  • Performance statistics and user analytics

Responsive Navigation

  • Navbar.jsx: Adaptive navigation with authentication state
  • Footer.jsx: Site-wide footer with links and information

πŸ› οΈ Tech Stack

Core Technologies

  • React 19.1.0 - Modern UI library with latest features
  • Vite 6.3.5 - Next-generation frontend tooling
  • Tailwind CSS 4.1.6 - Utility-first CSS framework
  • React Router DOM 7.6.0 - Declarative routing

Development & Build Tools

  • ESLint - Code linting and quality assurance
  • TypeScript - Type safety for critical components
  • Vercel - Deployment and hosting platform

Authentication & Backend

  • Firebase Auth - User authentication and management
  • Socket.io Client - Real-time communication
  • Axios - HTTP client for API requests

UI & Visualization Libraries

  • Monaco Editor - In-browser code editor
  • Radix UI - Primitive UI components
  • Recharts - Data visualization and charts
  • React Icons - Icon library
  • React Toastify - Toast notifications
  • KaTeX & React KaTeX - Mathematical notation rendering

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn package manager
  • Firebase account for authentication setup

Installation

# Clone the repository
git clone <repository-url>
cd cp-duel

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Configure Firebase credentials in .env

# Start development server
npm run dev

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run preview - Preview production build
  • npm run lint - Run ESLint

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 81.3%
  • TypeScript 17.9%
  • Other 0.8%