Skip to content

vipul752/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ LeetCode Platform - Problem Solving & Learning Hub

πŸ“š Description

LeetCode Platform is a comprehensive coding challenge platform that provides users with an interactive environment to solve algorithmic problems, track their progress, and enhance their coding skills. This platform combines the best features of coding platforms with AI-powered assistance and video tutorial integration.

Key Benefits:

  • 🎯 Structured coding challenges with multiple difficulty levels
  • πŸ€– AI-powered doubt resolution and learning assistance
  • πŸ“Ή Integrated video tutorial system for better learning
  • πŸ“Š Comprehensive progress tracking and user statistics
  • πŸ” Secure authentication with role-based access control
  • ⚑ High-performance caching with Redis for optimal user experience

πŸ› οΈ Tech Stack

Backend Technologies

  • Runtime: Node.js (v18+)
  • Framework: Express.js
  • Database: MongoDB with Mongoose
  • Cache: Redis
  • Authentication: JWT + Express Sessions
  • File Storage: Cloudinary (for video content)
  • Rate Limiting: Express Rate Limit + Redis
  • AI Integration: Google Generative AI (@google/genai)

Development Tools

  • Script Runner: Nodemon (development)
  • Environment Management: dotenv
  • Input Validation: validator.js
  • Security: bcrypt, cors, cookie-parser

✨ Features

πŸ‘₯ User Management

  • βœ… User Registration & Login: Secure authentication system
  • πŸ‘€ Profile Management: Complete user profile CRUD operations
  • πŸ” Role-based Access: Admin and regular user roles
  • πŸ“Š User Statistics: Track solved problems and performance metrics

🧩 Problem Management

  • πŸ“ Problem Creation: Admin can create coding challenges
  • 🏷️ Categorized Problems: Easy, Medium, Hard difficulty levels
  • 🏷️ Tagged Content: Array, LinkedList, DP, Graph, String, Stack, Queue, Heap, Tree
  • πŸ§ͺ Test Cases: Visible and hidden test cases for comprehensive evaluation
  • πŸ’» Multi-language Support: Initial code templates and reference solutions

πŸ”„ Code Execution & Submission

  • ▢️ Code Running: Test your code against visible test cases
  • ✍️ Code Submission: Submit solutions for evaluation
  • πŸ“ˆ Execution Results: Detailed feedback on submission performance
  • ⚑ Rate Limiting: Prevents abuse with intelligent submission throttling

πŸ€– AI-Powered Learning

  • 🧠 Doubt Resolution: AI chatbot for instant problem-solving assistance
  • πŸ’‘ Learning Guidance: Contextual help for algorithmic challenges
  • πŸ” Smart Responses: Google Generative AI integration for accurate solutions

πŸŽ₯ Video Tutorial System

  • πŸ“Ή Video Content: Upload and manage educational video content
  • πŸ”— Problem Integration: Link videos to specific coding problems
  • ☁️ Cloud Storage: Secure video hosting with Cloudinary
  • πŸ—‘οΈ Content Management: Admin controls for video content lifecycle

πŸ”’ Security & Performance

  • πŸ›‘οΈ JWT Authentication: Secure token-based authentication
  • πŸͺ Session Management: Express sessions with secure cookie handling
  • 🚫 CORS Protection: Cross-origin request security
  • ⚑ Redis Caching: Enhanced performance with intelligent caching
  • 🚦 Rate Limiting: Prevents API abuse and ensures fair usage

πŸš€ Installation Guide

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (local or cloud instance)
  • Redis server
  • npm or yarn package manager

Step-by-Step Setup

  1. Clone the Repository

    git clone <your-repository-url>
    cd Leetcodeβœ…
  2. Install Dependencies

    npm install
  3. Environment Configuration Create a .env file in the root directory:

    # Database Configuration
    MONGODB_URI=mongodb://localhost:27017/leetcode-platform
    REDIS_URL=redis://localhost:6379
    
    # Server Configuration
    PORT=5000
    SESSION_SECRET=your-super-secret-session-key
    
    # JWT Configuration
    JWT_SECRET=your-jwt-secret-key
    
    # AI Configuration
    GOOGLE_AI_API_KEY=your-google-ai-api-key
    
    # Cloudinary Configuration (for video uploads)
    CLOUDINARY_CLOUD_NAME=your-cloudinary-name
    CLOUDINARY_API_KEY=your-cloudinary-api-key
    CLOUDINARY_API_SECRET=your-cloudinary-secret
  4. Start Development Server

    npm run dev
  5. Verify Installation Visit http://localhost:5000/test to confirm the backend is running successfully.

πŸ“– Usage

Starting the Application

# Development mode (with auto-restart)
npm run dev

# Production mode
npm start

Basic API Usage

  1. Register a new user:

    curl -X POST http://localhost:5000/user/register \
      -H "Content-Type: application/json" \
      -d '{"firstName":"John","lastName":"Doe","email":"john@example.com","password":"password123"}'
  2. Login:

    curl -X POST http://localhost:5000/user/login \
      -H "Content-Type: application/json" \
      -d '{"email":"john@example.com","password":"password123"}'
  3. Get all problems:

    curl -X GET http://localhost:5000/problem/getAllProblem \
      -H "Authorization: Bearer YOUR_JWT_TOKEN"

πŸ“Έ Screenshot Placeholder: Add application screenshots here

πŸ“ Folder Structure

Leetcodeβœ…/
β”œβ”€β”€ src/                          # Source code
β”‚   β”œβ”€β”€ controller/               # Route controllers
β”‚   β”‚   β”œβ”€β”€ ai.controller.js      # AI chatbot functionality
β”‚   β”‚   β”œβ”€β”€ problem.controller.js # Problem management
β”‚   β”‚   β”œβ”€β”€ submission.controller.js # Code execution & submission
β”‚   β”‚   β”œβ”€β”€ user.controller.js    # User authentication & management
β”‚   β”‚   └── video.controller.js   # Video content management
β”‚   β”œβ”€β”€ middleware/               # Custom middleware
β”‚   β”‚   β”œβ”€β”€ adminMiddleware.js    # Admin role verification
β”‚   β”‚   β”œβ”€β”€ redisRateLimiter.js   # Request rate limiting
β”‚   β”‚   └── userMiddleware.js     # User authentication
β”‚   β”œβ”€β”€ model/                    # Database models
β”‚   β”‚   β”œβ”€β”€ problem.js           # Problem schema
β”‚   β”‚   β”œβ”€β”€ solutionVideo.js      # Video metadata schema
β”‚   β”‚   β”œβ”€β”€ submission.js         # Submission schema
β”‚   β”‚   └── user.js              # User schema
β”‚   β”œβ”€β”€ routes/                   # API route definitions
β”‚   β”‚   β”œβ”€β”€ ai.js                # AI chatbot routes
β”‚   β”‚   β”œβ”€β”€ problemCreator.js     # Problem CRUD routes
β”‚   β”‚   β”œβ”€β”€ submission.js         # Code execution routes
β”‚   β”‚   β”œβ”€β”€ userAuth.js           # Authentication routes
β”‚   β”‚   └── videoCreator.js      # Video management routes
β”‚   β”œβ”€β”€ config/                   # Configuration files
β”‚   β”‚   β”œβ”€β”€ db.js                # MongoDB connection
β”‚   β”‚   └── redis.js             # Redis connection
β”‚   β”œβ”€β”€ utils/                    # Utility functions
β”‚   β”‚   β”œβ”€β”€ problemUtility.js     # Problem-specific utilities
β”‚   β”‚   └── validator.js          # Input validation utilities
β”‚   └── index.js                  # Application entry point
β”œβ”€β”€ node_modules/                 # Dependencies
β”œβ”€β”€ package.json                  # Project configuration
β”œβ”€β”€ package-lock.json            # Dependency lock file
└── README.md                    # Project documentation

πŸ”— API Endpoints

Authentication (/user)

Method Endpoint Description Auth Required
POST /user/register Register a new user No
POST /user/login User login No
POST /user/logout User logout Yes
GET /user/check Verify user session Yes
GET /user/getProfile Get user profile Yes
PUT /user/updateProfile Update user profile Yes
DELETE /user/deleteProfile Delete user account Yes
POST /user/admin/register Admin registration Admin

Problem Management (/problem)

Method Endpoint Description Auth Required
POST /problem/create Create new problem Admin
PUT /problem/update/:id Update problem Admin
DELETE /problem/delete/:id Delete problem Admin
GET /problem/getProblem/:id Get problem by ID Yes
GET /problem/getAllProblem Get all problems Yes
GET /problem/userProblem Get user's solved problems Yes
GET /problem/submittedProblem/:pid Get submission history Yes
GET /problem/userStats Get user statistics Yes

Code Submission (/submission)

Method Endpoint Description Auth Required
POST /submission/run/:id Run code against visible test cases Yes
POST /submission/submit/:id Submit code for evaluation Yes

AI Assistant (/ai)

Method Endpoint Description Auth Required
POST /ai/chat Chat with AI for doubt resolution Yes

Video Management (/video)

Method Endpoint Description Auth Required
GET /video/create/:id Generate upload signature Admin
POST /video/save Save video metadata Admin
DELETE /video/delete/:videoId Delete video content Admin

🀝 Contributing

We welcome contributions! Please follow these steps:

Getting Started

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test thoroughly
  4. Commit with descriptive messages: git commit -m 'Add amazing feature'
  5. Push to your branch: git push origin feature/amazing-feature
  6. Open a Pull Request

Development Guidelines

  • πŸ“ Follow existing code style and conventions
  • πŸ§ͺ Write tests for new features
  • πŸ“š Update documentation for API changes
  • πŸ” Test your changes locally before submitting
  • πŸ’‘ Ensure backward compatibility for existing APIs

Code Standards

  • Use ESLint for code formatting
  • Write descriptive commit messages
  • Add JSDoc comments for new functions
  • Follow RESTful API design principles

πŸ‘¨β€πŸ’» Contact / Author

Developer: Vipul Kumar
Email: vipulvipul65845@gmail.com

Connect with me:


⭐ Star this repository if you found it helpful!


Built with ❀️ for the coding community

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published