Skip to content

Manvith-kumar16/MLCode

Repository files navigation

ML Code Logo

ML Code

The LeetCode for Machine Learning Engineers

Practice real-world ML challenges, compete on the leaderboard, and level up your data science skills.

Live Demo Backend GitHub

React TypeScript Vite Node.js MongoDB TailwindCSS


🧠 What is ML Code?

ML Code is an interactive coding platform specifically designed for Machine Learning and Data Science practitioners. Inspired by LeetCode, it offers a curated set of ML problems spanning topics like Classification, Regression, Deep Learning, NLP, Computer Vision, and more β€” with a built-in Python code editor, real-time code execution, and a competitive leaderboard.


✨ Features

Feature Description
🧩 ML Problem Set Curated problems across 10+ ML topics with difficulty tiers
⚑ In-Browser Code Editor Monaco Editor (VS Code engine) with Python 3 support and light/dark toggle
πŸš€ Code Execution Run and submit code against hidden test cases in real time
πŸ“Š Dashboard Personal stats, activity heatmap, and recent submissions at a glance
πŸ† Leaderboard Live global rankings with a visual podium for the top 3
πŸ‘€ Profile Page Detailed profile with rank, streak, solved stats, badges, and heatmap
πŸ“ Submissions Page Full history of all submissions with status filtering & code preview
πŸ’¬ Discussion Per-problem discussion threads (post, view, delete your comments)
πŸ’‘ Hints Two-level hints per problem, revealed on demand
πŸ” Authentication Email/password and Google OAuth sign-in
πŸŒ™ Premium Dark UI Glassmorphism design, ambient glow backgrounds, smooth animations
πŸ“± Responsive Works across desktop and tablet screens

πŸ—οΈ Tech Stack

Frontend

Technology Purpose
React 18 + TypeScript UI framework
Vite 5 Build tool & dev server
Tailwind CSS 3 Utility-first styling
Framer Motion Animations
Monaco Editor (@monaco-editor/react) In-browser code editor
React Router v6 Client-side routing
TanStack Query Server state management
Lucide React Icon library
Radix UI + shadcn/ui Headless UI components
Sonner Toast notifications
date-fns Date formatting
React Markdown + remark-gfm Problem description rendering

Backend

Technology Purpose
Node.js + Express REST API server
MongoDB + Mongoose Database & ODM
JSON Web Tokens (JWT) Authentication
bcryptjs Password hashing
google-auth-library Google OAuth verification
dotenv Environment config

πŸ“ Project Structure

MLCode/
β”œβ”€β”€ src/                        # Frontend source
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ Index.tsx           # Landing page
β”‚   β”‚   β”œβ”€β”€ Problems.tsx        # Problem list with filters
β”‚   β”‚   β”œβ”€β”€ ProblemDetail.tsx   # Code editor + problem view
β”‚   β”‚   β”œβ”€β”€ Dashboard.tsx       # User dashboard
β”‚   β”‚   β”œβ”€β”€ Leaderboard.tsx     # Global rankings
β”‚   β”‚   β”œβ”€β”€ Profile.tsx         # User profile
β”‚   β”‚   β”œβ”€β”€ Submissions.tsx     # Submission history
β”‚   β”‚   β”œβ”€β”€ SignIn.tsx          # Login page
β”‚   β”‚   β”œβ”€β”€ SignUp.tsx          # Registration page
β”‚   β”‚   └── EditProfile.tsx     # Profile settings
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/                 # shadcn/ui components
β”‚   β”‚   β”œβ”€β”€ AppSidebar.tsx      # Navigation sidebar
β”‚   β”‚   β”œβ”€β”€ DifficultyBadge.tsx # Easy/Medium/Hard badge
β”‚   β”‚   β”œβ”€β”€ RecentSubmissions.tsx
β”‚   β”‚   └── SubmissionHeatmap.tsx
β”‚   └── App.tsx                 # Routes configuration
β”‚
β”œβ”€β”€ server/                     # Backend source
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ User.js             # User schema
β”‚   β”‚   β”œβ”€β”€ Problem.js          # Problem schema
β”‚   β”‚   β”œβ”€β”€ Submission.js       # Submission schema
β”‚   β”‚   └── Discussion.js       # Discussion/comment schema
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth.js             # Auth + user routes
β”‚   β”‚   β”œβ”€β”€ problems.js         # Problem CRUD routes
β”‚   β”‚   β”œβ”€β”€ submissions.js      # Submission routes
β”‚   β”‚   β”œβ”€β”€ discussions.js      # Discussion routes
β”‚   β”‚   β”œβ”€β”€ execute.js          # Code execution route
β”‚   β”‚   └── verifyToken.js      # JWT middleware
β”‚   β”œβ”€β”€ services/               # Execution service
β”‚   └── index.js                # Express app entry
β”‚
β”œβ”€β”€ vercel.json                 # Vercel SPA routing config
β”œβ”€β”€ .env                        # Frontend env vars
└── vite.config.ts

πŸš€ Getting Started

Prerequisites

  • Node.js v18+
  • MongoDB (local or MongoDB Atlas)
  • A Google Cloud project with OAuth 2.0 credentials

1. Clone the repository

git clone https://github.com/Manvith-kumar16/MLCode.git
cd MLCode

2. Set up the Backend

cd server
npm install

Create server/.env:

MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/mlcode
GOOGLE_CLIENT_ID=your_google_oauth_client_id
PORT=5001

Start the server:

npm run dev

3. Set up the Frontend

# From the project root
npm install

Create .env in the root:

VITE_API_URL=http://localhost:5001

Start the dev server:

npm run dev

The app will be available at http://localhost:5173


🌐 API Reference

Auth Routes β€” /api/auth

Method Endpoint Description
POST /signup Register with email & password
POST /signin Login with email & password
POST /google Login / register via Google OAuth
GET /me Get current user profile (auth required)
PUT /me Update profile (auth required)
GET /leaderboard Get top 10 users by points
GET /rank/:userId Get a user's global rank

Problems Routes β€” /api/problems

Method Endpoint Description
GET / List all problems
GET /:id Get single problem by problemId

Submissions Routes β€” /api/submissions

Method Endpoint Description
POST /submit Submit solution for judging
GET /user/:userId Get all submissions for a user
GET /stats/:userId Get heatmap data for a user
GET /problem/:problemId Get submissions for a problem

Execution Routes β€” /api/execute

Method Endpoint Description
POST /:problemId Run code without submitting

Discussion Routes β€” /api/discussions

Method Endpoint Description
GET /:problemId Get all comments for a problem
POST / Post a new comment (auth required)
DELETE /:commentId Delete your comment (auth required)

🚒 Deployment

Backend β†’ Render

  1. Connect your GitHub repo to render.com
  2. Set Root Directory to server
  3. Build command: npm install | Start command: npm start
  4. Add environment variables: MONGO_URI, GOOGLE_CLIENT_ID, PORT

Frontend β†’ Vercel

  1. Import repo at vercel.com β†’ root directory .
  2. Framework: Vite | Build: npm run build | Output: dist
  3. Add env variable: VITE_API_URL=https://your-render-backend.onrender.com
  4. Add your Vercel domain to Google Cloud Console β†’ Authorized Origins

πŸ” Environment Variables

Frontend (.env)

VITE_API_URL=https://mlcode-snkb.onrender.com

Backend (server/.env)

MONGO_URI=mongodb+srv://...
GOOGLE_CLIENT_ID=...apps.googleusercontent.com
PORT=5001

πŸ“œ License

This project is open source and available under the MIT License.

About

A LeetCode-style coding platform for Machine Learning - practice real-world ML problems with a built-in Python editor, real-time code execution, leaderboard, and submission tracking.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors