Master Data Structures & Algorithms with AI-Driven Insights
Features β’ Getting Started β’ API Documentation β’ Contributing
CodeMentor AI is an intelligent coding assistant that revolutionizes how you learn and solve LeetCode problems. Powered by Google's Gemini AI, it provides:
- π― Comprehensive Problem Analysis - Deep dive into problem statements with AI-powered insights
- π§ Intelligent Learning Path - Step-by-step guidance tailored to your learning style
- β‘ Optimized Solutions - Industry-standard code with best practices
- π Performance Metrics - Detailed time and space complexity analysis
- π Interview Preparation - Real-world problem-solving techniques
Whether you're preparing for FAANG interviews, strengthening your DSA fundamentals, or exploring algorithmic thinking, CodeMentor AI is your ultimate learning companion!
- Smart Problem Breakdown - Gemini AI analyzes and explains problems in simple terms
- Multiple Approaches - Learn different solutions from brute force to optimal
- Code Explanation - Line-by-line breakdown of the solution
- Step-by-Step Guidance - Clear progression from problem understanding to implementation
- Pattern Recognition - Identify common problem-solving patterns
- Complexity Analysis - Detailed Big-O notation for time and space
- Secure Authentication - JWT-based login system
- Problem History - Access previously solved problems
- MongoDB Integration - Scalable data persistence
- RESTful API - Clean and documented endpoints
- Error Handling - Comprehensive error management
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Coming Soon) β
β React.js + Tailwind CSS + TypeScript β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β REST API
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Express.js Backend β
β β
β ββββββββββββββ ββββββββββββββββ βββββββββββββββββββ β
β β Routes ββββΆβ Controllers ββββΆβ Middleware β β
β β Layer β β (Business β β (Auth/Logging) β β
β ββββββββββββββ β Logic) β βββββββββββββββββββ β
β ββββββββ¬ββββββββ β
β β β
β ββββββββΌββββββββ β
β β Models β β
β β (Schemas) β β
β ββββββββββββββββ β
ββββββββββββ¬βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββββββ ββββββββββββββββββββββββββββ
β Gemini AI API β β MongoDB Atlas/Local β
β β β β
β β’ Problem Analysis β β β’ User Authentication β
β β’ Solution Generationβ β β’ Problem Storage β
β β’ Code Explanation β β β’ Progress Tracking β
ββββββββββββββββββββββββ ββββββββββββββββββββββββββββ
Ensure you have the following installed on your system:
- Node.js (v14.x or higher) - Download
- npm (v6.x or higher) or yarn (v1.22.x or higher)
- MongoDB - Local Installation or MongoDB Atlas
- Google Gemini API Key - Get your free API key
- Git - Download
git clone https://github.com/nikhilxagr/Code-Mentor-AI.git
cd Code-Mentor-AIcd backend
npm installCreate a .env file in the backend directory:
# Server Configuration
PORT=5000
NODE_ENV=development
# Database Configuration
MONGO_URI=mongodb://localhost:27017/codementor
# For MongoDB Atlas: mongodb+srv://<username>:<password>@cluster.mongodb.net/codementor
# Google Gemini AI
GEMINI_API_KEY=your_gemini_api_key_here
# JWT Authentication
JWT_SECRET=your_super_secret_jwt_key_here
JWT_EXPIRE=7d
# CORS Settings
CORS_ORIGIN=http://localhost:3000Local MongoDB:
mongodMongoDB Atlas:
- Copy your connection string from Atlas dashboard
- Update
MONGO_URIin.env
npm startFor development with auto-reload:
npm run devYour server should now be running on http://localhost:5000 π
| Technology | Version | Purpose |
|---|---|---|
| Node.js | v14+ | JavaScript runtime environment |
| Express.js | v4.18+ | Fast, unopinionated web framework |
| MongoDB | v5.0+ | NoSQL database for data persistence |
| Mongoose | v7.0+ | Elegant MongoDB object modeling |
| Google Gemini AI | Latest | Advanced AI for problem solving |
| bcryptjs | v2.4+ | Secure password hashing |
| jsonwebtoken | v9.0+ | JWT-based authentication |
| dotenv | v16.0+ | Environment variable management |
| cors | v2.8+ | Enable cross-origin requests |
POST /api/solve
Content-Type: application/json
{
"problemNumber": 1
}Response:
{
"success": true,
"problem": {
"number": 1,
"title": "Two Sum",
"difficulty": "Easy"
},
"answer": {
"explanation": "Detailed problem breakdown...",
"approach": "Step-by-step solution approach...",
"solution": "Code implementation with explanation...",
"complexity": {
"time": "O(n)",
"space": "O(n)"
}
}
}GET /api/healthResponse:
{
"status": "success",
"message": "CodeMentor AI is running!",
"timestamp": "2024-01-15T10:30:00Z"
}Code-Mentor-AI/
β
βββ backend/
β βββ config/
β β βββ db.js # MongoDB connection configuration
β β βββ gemini.js # Gemini AI initialization
β β
β βββ controllers/
β β βββ auth.controller.js # Authentication logic
β β βββ solve.controller.js # Problem solving logic
β β
β βββ middleware/
β β βββ auth.middleware.js # JWT verification
β β βββ error.middleware.js # Error handling
β β
β βββ models/
β β βββ User.model.js # User schema
β β βββ Problem.model.js # Problem schema
β β
β βββ routes/
β β βββ auth.routes.js # Authentication routes
β β βββ solve.routes.js # Problem solving routes
β β
β βββ .env # Environment variables (gitignored)
β βββ .env.example # Example environment file
β βββ .gitignore # Git ignore rules
β βββ server.js # Entry point
β βββ package.json # Dependencies
β βββ package-lock.json # Dependency lock file
β
βββ frontend/ # (Coming Soon)
β βββ README.md
β
βββ .gitignore # Root git ignore
βββ LICENSE # MIT License
βββ README.md # This file
1. User Submits Problem Number
β
2. Problem Validation
β
3. Gemini AI Processing
βββ Problem Analysis
βββ Solution Generation
βββ Code Optimization
βββ Complexity Calculation
β
4. Response Formatting
β
5. Return to User
| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
Server port | 5000 | No |
MONGO_URI |
MongoDB connection string | - | Yes |
GEMINI_API_KEY |
Google Gemini API key | - | Yes |
JWT_SECRET |
Secret for JWT signing | - | Yes |
JWT_EXPIRE |
JWT token expiration | 7d | No |
NODE_ENV |
Environment mode | development | No |
CORS_ORIGIN |
Allowed CORS origins | * | No |
Error: MongoNetworkError: failed to connect to serverSolution:
- Check if MongoDB is running:
mongod --version - Verify
MONGO_URIin.env - Ensure IP whitelist in MongoDB Atlas
Error: Invalid API keySolution:
- Verify API key in
.env - Check API quota at Google AI Studio
Error: listen EADDRINUSE: address already in use :::5000Solution:
# Find and kill the process
lsof -ti:5000 | xargs kill -9Contributions make the open-source community thrive! We welcome contributions of all kinds.
-
Fork the Project
git clone https://github.com/nikhilxagr/Code-Mentor-AI.git
-
Create Feature Branch
git checkout -b feature/AmazingFeature
-
Make Changes
- Write clean, documented code
- Follow existing code style
-
Commit Changes
git commit -m 'Add: Amazing new feature' -
Push to Branch
git push origin feature/AmazingFeature
-
Open Pull Request
- Backend API with Express.js
- MongoDB Integration
- Gemini AI Integration
- User Authentication System
- Frontend Development (React.js)
- User Dashboard
- Progress Tracking
- Problem Recommendation System
Distributed under the MIT License. See LICENSE for more information.
![]() Nikhil Agrawal Full Stack Developer |
![]() Gaurav Kumar Yadav Full Stack Developer |
Special thanks to:
- Google Gemini AI - For powerful AI capabilities
- LeetCode - For the amazing problem database
- MongoDB - For robust database solutions
- Express.js - For the excellent web framework
- Open Source Community - For continuous inspiration
Need help? We're here for you!
- π Bug Reports: GitHub Issues
- π¬ Discussions: GitHub Discussions
If CodeMentor AI helped you ace your interviews or improve your coding skills, give it a βοΈ!

