Complete step-by-step guide to set up CodeMentor AI locally or in production.
- Node.js 16+ with npm
- Python 3.9 or higher
- Git
- Docker & Docker Compose (optional, for containerized setup)
- Groq API Key (free from https://console.groq.com)
git clone https://github.com/shoaib1522/CodeMentor-AI-Intelligent-Code-Review-Assistant.git
cd CodeMentorAIcd backend
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install -r ../requirements.txt# Create .env file in backend directory
cat > .env << 'ENVFILE'
GROQ_API_KEY=your_groq_api_key_here
MONGODB_URL=mongodb://localhost:27017
DATABASE_NAME=codementor
API_HOST=0.0.0.0
API_PORT=8000
FRONTEND_URL=http://localhost:5173
ENVFILEReplace your_groq_api_key_here with your actual Groq API key.
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000You should see:
Uvicorn running on http://0.0.0.0:8000
Application startup complete
cd frontendnpm installnpm run devYou should see:
VITE v4.x.x ready in xxx ms
➜ Local: http://localhost:5173/
Open your browser and go to: http://localhost:5173
You should see the CodeMentor AI interface with:
- Code editor on the left
- Settings panel
- Results panel on the right
# From project root
cp .env.example .env
# Edit .env with your Groq API key
nano .env # or use your preferred editordocker-compose up -d# Check running containers
docker-compose ps
# View logs
docker-compose logs -f
# Test backend API
curl http://localhost:8000/health- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- Swagger Docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
docker-compose down
# To remove volumes (database):
docker-compose down -v- Open http://localhost:5173
- Select language: Python
- Paste this code:
def get_user_by_id(user_id):
import sqlite3
conn = sqlite3.connect('users.db')
cursor = conn.cursor()
query = "SELECT * FROM users WHERE id = " + str(user_id)
cursor.execute(query)
return cursor.fetchone()- Click "Analyze"
- Results should show SQL Injection vulnerability
- Language: Python
- Paste:
class Config:
DB_PASSWORD = "SuperSecret123!"
API_KEY = "sk_live_abcd1234"- Click "Analyze"
- Should detect hardcoded credentials
- Language: JavaScript
- Paste:
function displayComment(comment) {
document.getElementById('comments').innerHTML = `<p>${comment}</p>`;
}- Click "Analyze"
- Should detect XSS vulnerability
| Variable | Description | Default |
|---|---|---|
| GROQ_API_KEY | API key from Groq console | Required |
| MONGODB_URL | MongoDB connection string | mongodb://localhost:27017 |
| DATABASE_NAME | Database name in MongoDB | codementor |
| API_HOST | Backend server host | 0.0.0.0 |
| API_PORT | Backend server port | 8000 |
| FRONTEND_URL | Frontend application URL | http://localhost:5173 |
Solution: Ensure .env file exists in backend directory with correct API key.
cd backend
cat .env # Check file contentsSolution: MongoDB is not running. Either:
- Start MongoDB locally
- Use Docker:
docker-compose up -d - Remove MongoDB requirement from code
Solution: Change port in frontend:
npm run dev -- --port 3000Solution: Reinstall dependencies:
cd backend
pip install -r ../requirements.txt --force-reinstallSolution: Clear and reinstall:
cd frontend
rm -rf node_modules package-lock.json
npm installSolution:
- Check backend is running:
curl http://localhost:8000/health - Check API server logs
- Restart backend server
Once backend is running, visit: http://localhost:8000/docs
Alternative docs: http://localhost:8000/redoc
See DEPLOYMENT.md for detailed instructions.
- Connect GitHub repository
- Configure environment variables
- Set build commands
- Deploy
- Launch Ubuntu instance
- Install Docker and Docker Compose
- Clone repository
- Configure .env
- Run
docker-compose up -d
# Build optimized bundle
cd frontend
npm run build
# Preview production build
npm run preview- Enable caching for repeated analyses
- Implement rate limiting
- Use connection pooling for MongoDB
# View real-time logs
docker-compose logs -f backend
# View specific service
docker-compose logs -f frontend# Connect to MongoDB
docker-compose exec mongodb mongosh
# View databases
show databases
# Use codementor database
use codementor
# View collections
show collections- Read README.md for project overview
- Check CONTRIBUTING.md for development guidelines
- Explore API docs at http://localhost:8000/docs
- Create issues or PRs for improvements
- Check FAQ in README.md
- Open an issue on GitHub
- Review existing issues and discussions
- Contact maintainers
Happy coding! 🚀