Skip to content

dhruvmkolhe/codeMAX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


 ██████╗ ██████╗ ██████╗ ███████╗███╗   ███╗ █████╗ ██╗  ██╗
██╔════╝██╔═══██╗██╔══██╗██╔════╝████╗ ████║██╔══██╗╚██╗██╔╝
██║     ██║   ██║██║  ██║█████╗  ██╔████╔██║███████║ ╚███╔╝ 
██║     ██║   ██║██║  ██║██╔══╝  ██║╚██╔╝██║██╔══██║ ██╔██╗ 
╚██████╗╚██████╔╝██████╔╝███████╗██║ ╚═╝ ██║██║  ██║██╔╝ ██╗
 ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝     ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

The Open-Source Competitive Coding Platform — Code. Analyze. Dominate.

License: MIT Node.js React MongoDB PRs Welcome Open Source


codeMAX is a fully open-source, industry-grade competitive programming platform — free for everyone, forever.
Built with love by developers, for developers. Solve problems, compete in contests, analyze your code, and climb the leaderboard.


🚀 Live Demo · 📖 Documentation · 🐛 Report Bug · ✨ Request Feature


📋 Table of Contents


✨ Features

🧠 Code Intelligence

  • Multi-language Code Execution — Run C, C++, Java, Python, JavaScript securely
  • Static Code Analysis — Deep analysis of code quality, complexity, and patterns
  • Real-time Output — Instant execution feedback via WebSocket streaming
  • Code Playground — Scratch-pad environment to test ideas freely

🏆 Competitive Features

  • Problem Library — Curated problems with Difficulty, Tags & Editorial support
  • Live Contests — Time-boxed contests with real-time participant tracking
  • Global Leaderboard — Dynamic ranking with rating & submission statistics
  • Submission History — Track every submission with detailed verdict & timing

👤 User Experience

  • Authentication — Secure JWT-based login & registration
  • User Profiles — Stats, activity heatmap, and solved problem counts
  • Dark / Light Mode — Gorgeous theme switcher with OS preference detection
  • Responsive Design — Pixel-perfect on desktop, tablet, and mobile

⚙️ Platform & Infrastructure

  • WebSocket Support — Real-time updates for contests and live execution
  • RESTful API — Fully documented, versioned REST API
  • MongoDB Atlas Ready — Works with both local MongoDB and Atlas cloud
  • Helmet Security — Production-hardened HTTP security headers


🛠️ Tech Stack

Frontend

Technology Purpose
React 18 UI framework with hooks and concurrent features
Vite Lightning-fast build tool and dev server
Tailwind CSS Utility-first CSS with custom design tokens
Zustand Lightweight global state management
React Router v6 Client-side routing with nested layouts
React Hot Toast Beautiful notification toasts

Backend

Technology Purpose
Node.js 18+ JavaScript runtime
Express.js RESTful API framework
MongoDB + Mongoose NoSQL database with schema modeling
WebSocket (ws) Real-time bidirectional communication
JWT Stateless authentication tokens
Helmet HTTP security headers
Morgan HTTP request logging

📁 Project Structure

codemax/
├── 📦 package.json              # Root workspace config (runs client + server)
├── 📄 README.md
├── 🔒 .gitignore
│
├── client/                      # React frontend (Vite + Tailwind)
│   ├── src/
│   │   ├── App.jsx              # Root app with routing
│   │   ├── index.css            # Global styles & design tokens
│   │   ├── main.jsx             # React entry point
│   │   ├── store/               # Zustand state stores (auth, theme)
│   │   ├── components/
│   │   │   └── Layout.jsx       # App shell with navbar & sidebar
│   │   └── pages/
│   │       ├── Home.jsx         # Landing dashboard
│   │       ├── Problems.jsx     # Problem listing with filters
│   │       ├── ProblemSolve.jsx # Split-pane code editor + problem view
│   │       ├── Playground.jsx   # Free-form code sandbox
│   │       ├── Contests.jsx     # Live contest browser
│   │       ├── Leaderboard.jsx  # Global rankings
│   │       ├── Profile.jsx      # User profile & stats
│   │       ├── Login.jsx        # Authentication
│   │       └── Register.jsx     # User registration
│   └── tailwind.config.js       # Custom color system & animations
│
└── server/                      # Node.js + Express backend
    ├── src/
    │   ├── index.js             # App entry, middleware, WebSocket init
    │   ├── config/
    │   │   └── database.js      # MongoDB connection setup
    │   ├── models/
    │   │   ├── User.model.js    # User schema (auth, stats, ratings)
    │   │   ├── Problem.model.js # Problem schema (test cases, editorial)
    │   │   ├── Submission.model.js  # Submission schema (verdict, timing)
    │   │   └── Contest.model.js # Contest schema (problems, participants)
    │   ├── routes/
    │   │   ├── auth.routes.js       # /api/auth — login, register, refresh
    │   │   ├── problem.routes.js    # /api/problems — CRUD & search
    │   │   ├── submission.routes.js # /api/submissions — submit & history
    │   │   ├── contest.routes.js    # /api/contests — contest management
    │   │   ├── leaderboard.routes.js# /api/leaderboard — rankings
    │   │   ├── compiler.routes.js   # /api/compiler — code execution
    │   │   └── user.routes.js       # /api/users — profile & stats
    │   ├── services/
    │   │   ├── codeExecutor.service.js    # Sandboxed multi-language runner
    │   │   └── staticAnalyzer.service.js  # Code quality & pattern analysis
    │   ├── middleware/
    │   │   └── error.middleware.js  # Global error handling
    │   ├── utils/
    │   │   └── logger.js            # Structured logging utility
    │   └── websocket/
    │       └── index.js             # WebSocket handlers for real-time features
    └── .env                         # Environment configuration (see below)

⚡ Quick Start

Prerequisites

Make sure you have the following installed:

  • Node.js >= 18.0.0Download
  • MongoDB >= 7.0 (local) or a MongoDB Atlas account
  • npm >= 9.0.0 (comes with Node.js)

1. Clone the Repository

git clone https://github.com/your-username/codemax.git
cd codemax

2. Install All Dependencies

npm run install:all

This single command installs dependencies for the root, client, and server in one shot.

3. Configure Environment Variables

# Copy the example env file
cp server/.env.example server/.env

Edit server/.env with your settings (see Configuration below).

4. Start the Development Servers

npm run dev

This concurrently starts:


🔧 Configuration

server/.env — Environment Variables

# ── Server ─────────────────────────────────────
PORT=5000
NODE_ENV=development

# ── Database ───────────────────────────────────
# Local MongoDB
MONGODB_URI=mongodb://127.0.0.1:27017/codemax

# OR: MongoDB Atlas (cloud)
# MONGODB_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/codemax

# ── Authentication ──────────────────────────────
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRES_IN=7d

# ── CORS ───────────────────────────────────────
CORS_ORIGIN=http://localhost:5173

# ── Rate Limiting ──────────────────────────────
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX=100

⚠️ Never commit your .env file. It is already listed in .gitignore.


📡 API Reference

All API endpoints are prefixed with /api.

Authentication — /api/auth

Method Endpoint Description Auth Required
POST /api/auth/register Register a new user No
POST /api/auth/login Login and receive JWT No
POST /api/auth/refresh Refresh access token Yes
POST /api/auth/logout Invalidate token Yes

Problems — /api/problems

Method Endpoint Description Auth Required
GET /api/problems List all problems (with filters) No
GET /api/problems/:slug Get problem by slug No
POST /api/problems Create a new problem Admin
PUT /api/problems/:id Update a problem Admin
DELETE /api/problems/:id Delete a problem Admin

Submissions — /api/submissions

Method Endpoint Description Auth Required
POST /api/submissions Submit a solution Yes
GET /api/submissions Get submission history Yes
GET /api/submissions/:id Get submission details Yes

Compiler — /api/compiler

Method Endpoint Description Auth Required
POST /api/compiler/run Execute code (sandbox) Yes
POST /api/compiler/analyze Run static analysis Yes

Contests — /api/contests

Method Endpoint Description Auth Required
GET /api/contests List all contests No
GET /api/contests/:id Get contest details No
POST /api/contests/:id/register Register for a contest Yes

Leaderboard — /api/leaderboard

Method Endpoint Description Auth Required
GET /api/leaderboard Global rankings No
GET /api/leaderboard/contest/:id Contest-specific leaderboard No

🎨 UI & Theming

codeMAX uses a fully customizable Tailwind CSS design system with:

  • Primary color: Indigo (#6366f1) — buttons, links, accents
  • Accent color: Cyan (#22d3ee) — highlights, badges, glow effects
  • Dark mode: Slate-based palette with glassmorphism effects
  • Light mode: Clean white/gray with vibrant primary contrast

Toggling Themes

The theme toggle is available in the top navigation bar. The selected preference is persisted locally via Zustand.

Custom Color Tokens

Defined in client/tailwind.config.js:

colors: {
  primary: { /* Indigo scale 50–950 */ },
  accent:  { /* Cyan scale 50–950 */ },
  dark:    { /* Slate scale — adapts per theme */ }
}

🤝 Contributing

We welcome contributions of all kinds — bug fixes, new features, documentation improvements, and more!

How to Contribute

  1. Fork this repository
  2. Create a feature branch: git checkout -b feat/amazing-feature
  3. Commit your changes: git commit -m "feat: add amazing feature"
  4. Push to your fork: git push origin feat/amazing-feature
  5. Open a Pull Request — we'll review it as soon as possible!

Contribution Guidelines

  • Follow the existing code style and naming conventions
  • Write meaningful commit messages (we follow Conventional Commits)
  • Add comments for complex logic
  • Test your changes before submitting a PR
  • For large changes, open an issue first to discuss the approach

Good First Issues

Look for issues tagged with good first issue — these are great starting points for new contributors!


🛡️ Security

If you discover a security vulnerability, please do not open a public issue. Instead, email us directly so we can address it responsibly before public disclosure.


📄 License

This project is licensed under the MIT License — see the LICENSE file for full details.

MIT License — Free to use, modify, and distribute.
Attribution appreciated but not required.

Made with ❤️ for the developer community

codeMAX is free and open-source — forever.

Star this repo if you find it useful — it helps more developers discover codeMAX!


About

can consider it as template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors