The AI Code Analyzer is a Flask-based web application that allows users to upload code files(supported files types are .cpp, .java, .txt, .py, .c) or paste code snippets for analysis. The app provides insights into potential bottlenecks, optimizations, and best practices to improve the quality of the submitted code.
- File Upload: Upload a code file for analysis.
- Code Snippet Input: Directly paste code snippets for immediate evaluation.
- Code Analysis: Identifies potential bottlenecks, suggests optimizations, and highlights best practices.
- Syntax Highlighting: Displays analyzed code snippets with syntax highlighting using Highlight.js.
- User-Friendly Interface: Responsive design for seamless use across devices.
- Upload or Paste Code: Choose between uploading a file or pasting your code snippet directly into the provided text area.
- Analyze Code: Click the "Analyze Code" button.
- View Results: Get a detailed analysis of your code, including:
- Potential bottlenecks.
- Suggested optimizations.
- Refactored code examples.
- Backend: Flask (Python)
- Frontend: HTML, CSS, Highlight.js for syntax highlighting.
- Deployment: Render
- Python 3.10
pip(Python package manager)- A
.envfile containing necessary environment variables
- Clone the repository:
git clone https://github.com/ManaswiniGupta/AI-Code-Analyzer.git cd AI-Code-Analyzer - Install dependencies: Use
pipto install the required dependenciespip install -r requirements.txt
- Set up environment variables:
- Create a
.envfile in the root directory and add your environment variables, such as the API key.GROQ_API_KEY=your-api-key-here
- Ensure
.envis listed in .gitignore to keep it private.
To start the Flask server, run the following command:
flask runThe application will be available at http://127.0.0.1:5000.
This application is configured to use Gunicorn for production environments. To run with Gunicorn:
gunicorn app:appThis application can be deployed on Render. Be sure to include gunicorn in requirements.txt to ensure compatibility.
app.py: Main application file for Flask server setup and endpointstemplates/: HTML templates for the web interfacestatic/: Static files such as CSS for stylingrequirements.txt: Python dependencies.env: Contains environment variables (should be added to .gitignore)