Skip to content

praxshant/CodeMentor

Repository files navigation

CodeMentor 🚀

AI-Powered Code Analysis Using GPT-2 Transfer Learning

CodeMentor is a full-stack web application that analyzes code snippets for bugs, provides fixes, and suggests industry-standard improvements using advanced AI technology. Built with Flask (Python) backend and React frontend, it leverages Hugging Face's GPT-2 model for intelligent code analysis.

Project Structure

CodeMentor/
├── backend/                 # Flask application (API, DB, analyzer)
├── frontend/                # React + TypeScript app (Vite + Tailwind)
└── README.md

Cleanup Summary

To keep the project lean and immediately runnable, unused and duplicated files were removed/simplified:

  • Removed Tailwind CDN and inline config from frontend/public/index.html to rely on local Tailwind build.
  • Simplified frontend/package.json to only essential dependencies (React, ReactDOM) and dev tooling (Vite, TypeScript, ESLint, Tailwind toolchain).
  • Simplified frontend/src/App.tsx to a self-contained minimal app (no external component or context dependencies).
  • Suggested deletion of duplicate/unreferenced files (see Optional Cleanup below) to avoid confusion.

Requirements

  • Python 3.10+
  • Node.js 18+

Backend: Run Locally

REACT_APP_BACKEND_URL=https://your-backend-url.onrender.com
  1. Deploy: Vercel will automatically build and deploy your frontend

📁 Project Structure

CodeMentor/
├── backend/
│   ├── app.py              # Main Flask application
│   ├── analyzer.py         # GPT-2 code analysis logic
│   ├── requirements.txt    # Python dependencies
│   ├── Dockerfile         # Docker configuration
│   └── Procfile          # Render deployment config
├── frontend/
│   ├── public/
│   │   └── index.html     # Main HTML file
│   ├── src/
│   │   ├── components/    # React components
│   │   │   ├── CodeInput.js      # Code submission form
│   │   │   ├── ResultsDisplay.js # Analysis results display
│   │   │   └── Navbar.js         # Navigation component
│   │   ├── App.js         # Main React component
│   │   ├── App.css        # Custom styles
│   │   └── index.js       # React entry point
│   ├── package.json       # Node.js dependencies
│   └── vercel.json        # Vercel deployment config
├── README.md              # Project documentation
└── .gitignore            # Git ignore file

🔍 How It Works

Code Analysis Process

  1. Code Submission: User submits code via the web interface
  2. Backend Processing: Flask receives the code and passes it to the analyzer
  3. AI Analysis: GPT-2 model analyzes the code using transfer learning
  4. Pattern Detection: Identifies bugs, potential issues, and improvement opportunities
  5. Results Generation: Creates structured analysis with bugs, fixes, and suggestions
  6. Response: Returns comprehensive results to the frontend

AI Model Details

  • Model: GPT-2 (pre-trained on diverse text data)
  • Transfer Learning: Fine-tuned for code analysis tasks
  • Analysis Types:
    • Syntax error detection
    • Logical issue identification
    • Code quality assessment
    • Best practice suggestions
    • Performance optimization tips

🧪 Testing

Backend Testing

cd backend
python -m pytest tests/  # If tests are implemented

Frontend Testing

cd frontend
npm test  # If tests are implemented

🔒 Security Features

  • Input Validation: All code inputs are validated and sanitized
  • CORS Protection: Configured for secure cross-origin requests
  • Error Handling: Comprehensive error handling without exposing sensitive information
  • Rate Limiting: Built-in protection against abuse (can be enhanced)

🚧 Limitations & Considerations

  • Model Size: GPT-2 model requires significant memory (~500MB)
  • Analysis Depth: Focuses on structural and pattern-based analysis
  • Language Support: Primarily optimized for Python, with basic support for other languages
  • Performance: First analysis may be slower due to model loading

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Hugging Face: For providing the GPT-2 model and transformers library
  • Flask: For the robust Python web framework
  • React: For the powerful frontend library
  • Tailwind CSS: For the beautiful utility-first CSS framework
  • Render & Vercel: For free hosting services

📞 Support

  • Issues: Create an issue on GitHub
  • Discussions: Use GitHub Discussions for questions
  • Documentation: Check the code comments and this README

🔮 Future Enhancements

  • Support for more programming languages
  • Advanced code optimization suggestions
  • Integration with IDEs and code editors
  • Custom model training capabilities
  • Real-time collaborative analysis
  • Code review workflow integration

Built with ❤️ using React, Flask, and GPT-2 AI technology

CodeMentor - Your AI-powered coding companion

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published