Your intelligent coding companion powered by OpenAI
Features • Tech Stack • Getting Started • Screenshots • Contributing
CodeMentor is a modern, full-stack web application that provides AI-powered coding assistance. Built with Next.js, Express, MongoDB, and OpenAI's GPT, it offers real-time chat functionality with syntax highlighting, code formatting, and persistent conversation history.
- 🔐 Secure Authentication: JWT-based auth with refresh tokens
- 💬 Real-time AI Chat: Powered by OpenAI GPT for intelligent responses
- 🎨 Modern UI/UX: Beautiful glass morphism design with smooth animations
- 📝 Code Highlighting: Syntax highlighting for multiple programming languages
- 💾 Persistent History: Save and manage all your conversations
- 📱 Responsive Design: Works seamlessly on desktop and mobile devices
- 🌓 Dark/Light Mode: Automatic theme detection and manual toggle
- ⚡ Optimistic Updates: Instant UI feedback for better user experience
- 🔍 Markdown Support: Rich text formatting in messages
- ⌨️ Keyboard Shortcuts: Quick actions for power users
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- UI Components: Custom components with Radix UI
- State Management: React Query (TanStack Query)
- Animations: Framer Motion
- Forms: React Hook Form + Zod validation
- HTTP Client: Axios
- Framework: Express.js
- Language: TypeScript
- Database: MongoDB with Mongoose
- Authentication: JWT (jsonwebtoken)
- AI Integration: OpenAI API
- Security: Helmet, CORS, bcrypt
- Validation: Zod
- Rate Limiting: express-rate-limit
- Node.js 18+
- MongoDB (local or Atlas)
- OpenAI API key
- Git
-
Clone the repository
git clone https://github.com/yourusername/codementor.git cd codementor -
Install dependencies
# Install backend dependencies cd server npm install # Install frontend dependencies cd ../client npm install
-
Environment Setup
Backend (.env):
cd server cp .env.example .envEdit
server/.env:# Server NODE_ENV=development PORT=5000 # Database DATABASE_TYPE=mongodb MONGODB_URI=mongodb://localhost:27017/codementor # OpenAI OPENAI_API_KEY=your-openai-api-key OPENAI_MODEL=gpt-4-turbo-preview # Security JWT_SECRET=your-super-secret-jwt-key JWT_REFRESH_SECRET=your-super-secret-refresh-key JWT_EXPIRES_IN=24h JWT_REFRESH_EXPIRES_IN=7d BCRYPT_ROUNDS=12 # CORS CORS_ORIGIN=http://localhost:3000
Frontend (.env.local):
cd ../client echo "NEXT_PUBLIC_API_URL=http://localhost:5000/api" > .env.local
-
Run the application
In separate terminals:
# Terminal 1 - Backend cd server npm run dev # Terminal 2 - Frontend cd client npm run dev
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000/api
codementor/
├── client/ # Next.js frontend
│ ├── app/ # App router pages
│ ├── components/ # React components
│ ├── lib/ # Utilities and hooks
│ └── public/ # Static assets
└── server/ # Express backend
├── src/
│ ├── controllers/ # Route controllers
│ ├── models/ # MongoDB models
│ ├── routes/ # API routes
│ ├── services/ # Business logic
│ └── middleware/ # Express middleware
└── dist/ # Compiled JavaScript
- Modify
tailwind.config.jsfor custom styling - Update
next.config.jsfor Next.js settings - Customize theme in
app/globals.css
- Adjust rate limiting in
app.ts - Modify OpenAI settings in
services/openai.service.ts - Configure CORS origins for production
POST /api/auth/signup- Register new userPOST /api/auth/login- Login userPOST /api/auth/refresh- Refresh access tokenGET /api/auth/profile- Get user profile
POST /api/chats- Create new chatGET /api/chats- Get user's chatsGET /api/chats/:id- Get chat messagesPOST /api/chats/:id/messages- Send messagePATCH /api/chats/:id- Update chat titleDELETE /api/chats/:id- Delete chat
- Set environment variables in your platform
- Ensure MongoDB Atlas connection
- Update CORS origins for production
- Connect GitHub repository
- Set
NEXT_PUBLIC_API_URLto production API - Deploy
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the GPT API
- Next.js team for the amazing framework
- All contributors and users of CodeMentor
For support, email kuldeepsingh21070@gmail.com or open an issue in this repository.
⭐ Star this repository





