๐Ÿ’ป Code Assistant Bot

Advanced AI-powered coding assistant for code generation, debugging, and explanations. Features code generation in 16+ programming languages, debugging assistance, code explanations, syntax checking, code analysis, GitHub integration, code optimization, code conversion, code testing, and beautiful web interface.
Try Interactive Demo

๐Ÿ“– Project Overview

Code Assistant Bot is an advanced AI-powered coding assistant that integrates OpenAI API with Flask to create an intelligent code generation and analysis platform. This project offers code generation in 16+ programming languages, debugging assistance with error identification and fixes, code explanations with detailed logic breakdowns, syntax checking across multiple languages, code analysis with quality metrics and complexity scoring, GitHub integration for repository search and exploration, code optimization for performance and memory, code conversion between 10+ languages, code testing with automated validation, security scanning for vulnerabilities, and comprehensive code quality metrics. Perfect for developers, coding platforms, programming education, and businesses requiring intelligent coding assistance.

โšก Quick Facts

๐ŸŽฏ Type: AI-Powered Code Assistant with Code Generation
๐Ÿค– AI Features: OpenAI API, Code Generation, Debugging, Code Analysis, GitHub Integration, Code Optimization
โšก Setup Time: ~5 minutes
๐Ÿ“ฆ Backend: Python with Flask
๐ŸŽจ Frontend: HTML5, CSS3, JavaScript
๐Ÿง  AI Model: OpenAI GPT-3.5 Turbo
๐Ÿ“ฑ Platform: Web Browser
๐Ÿ”ง Technologies: Python, Flask, OpenAI API, AST, Requests
25+
Files
5000+
Lines of Code
20+
Advanced Features
16+
Languages
Developer: Molla Samser | Website: rskworld.in | Email: help@rskworld.in
Difficulty Level: Intermediate - Perfect for developers learning Python, Flask, OpenAI API integration, code generation, debugging tools, and AI-powered coding assistance.

โœจ Features

Core Features

๐Ÿ’ป Code Generation

Generate code in 16+ programming languages including Python, JavaScript, TypeScript, Java, C++, C, C#, PHP, Ruby, Go, Rust, HTML, CSS, SQL, Swift, and Kotlin.

๐Ÿ› Debugging Assistance

Advanced debugging tools to identify and fix code errors with detailed explanations and suggestions.

๐Ÿ“– Code Explanations

Get detailed explanations of code logic and functionality to understand complex code structures.

โœ… Syntax Checking

Real-time syntax validation across multiple programming languages to catch errors before execution.

Advanced Features

๐Ÿ“Š Code Analysis

Comprehensive code quality, complexity, and metrics analysis with cyclomatic and cognitive complexity scoring.

๐Ÿ” Security Scanning

Detect common security vulnerabilities and hardcoded secrets in your code automatically.

โšก Code Optimization

Performance, memory, and readability optimization with intelligent code improvement suggestions.

๐Ÿ”„ Code Conversion

Convert code between 10+ programming languages while preserving logic and structure.

๐Ÿงช Code Testing

Automated testing with syntax validation, unit tests, integration tests, and security scanning.

๐ŸŒ GitHub Integration

Search and explore repositories with language filtering and keyword search capabilities.

๐Ÿ“ˆ Quality Metrics

Code quality scoring and improvement suggestions with detailed metrics and reports.

๐Ÿ” Language Auto-Detection

Smart recognition of programming languages from code with confidence scoring.

๐Ÿ’พ Code History

Save and export code snippets and analysis results for record-keeping and reference.

๐Ÿ“Š Session Analytics

Track code generation statistics, language usage, and performance metrics in real-time.

๐Ÿ”’ Security Features

Rate limiting, input validation, CORS configuration, and secure API key management.

โšก Real-time Processing

Fast AI responses with real-time code processing for smooth coding assistance.

๐Ÿ› ๏ธ Technologies

Python

Core programming language for code assistant platform

Language

Flask

Python web framework for backend API

Framework

OpenAI API

AI model integration for intelligent code generation

AI API

AST

Python Abstract Syntax Tree for code analysis

Analysis

Requests

HTTP client for GitHub API integration

HTTP

python-dotenv

Environment variable management for configuration

Config

Prism.js

Syntax highlighting for code display

Frontend

Modular Architecture

Clean, modular code structure with utility modules

Architecture

๐Ÿ“ฆ Installation Guide - Step by Step

โฑ๏ธ Installation Time: ~5 minutes

Follow these simple steps to set up the Code Assistant Bot on your system.

๐Ÿ“‹ Prerequisites

๐Ÿ Python 3.8+

Python 3.8 or higher required for the code assistant platform

Download: Python

๐ŸŒ Web Browser

Modern web browser (Chrome, Firefox, Safari, Edge) for accessing the code assistant platform

Recommended: Latest version of Chrome or Firefox

๐ŸŒ OpenAI API Key

Get your API key from OpenAI Platform (required for AI features)

Get Key: OpenAI Platform

๐ŸŒ Internet Connection

Required for Flask server and OpenAI API calls

๐Ÿš€ Step-by-Step Installation

๐Ÿ“Œ Step 1: Download or Clone the Project

Option A: Download ZIP

  1. Download the project ZIP file from the repository
  2. Extract it to your desired location (e.g., C:\Projects\code-assistant-bot or ~/Projects/code-assistant-bot)
  3. Navigate to the extracted folder

Option B: Clone with Git

git clone https://github.com/rskworld/code-assistant-bot.git
cd code-assistant-bot
โœ… Step 2: Install Python Dependencies

Install required Python packages using pip.

# Install dependencies
pip install -r requirements.txt
๐Ÿ”‘ Step 3: Set Up API Keys

Configure your OpenAI API key in the environment file.

  1. Copy .env.example to .env
  2. Edit .env and add your API key:
    • OPENAI_API_KEY=sk-your-openai-key-here
    • FLASK_ENV=development (optional)
    • PORT=5000 (optional, default is 5000)
  3. Get your OpenAI API key from OpenAI Platform
  4. Optionally get Google Translate API key for enhanced translations
  5. Make sure your API key has sufficient credits for testing
๐Ÿš€ Step 4: Start the Flask Server

Start the Flask backend server by running app.py.

# Start Flask server
python app.py

# The server will start on http://localhost:5000
๐ŸŒ Step 5: Open Frontend

Open the HTML file in your browser or use a local web server.

Method 1: Direct File Opening

  1. Open index.html in your browser

Method 2: Using Local Web Server (Recommended)

# In a new terminal, start HTTP server
python -m http.server 8000

# Then open: http://localhost:8000

โœ… Installation Complete!

Congratulations! You've successfully set up the Code Assistant Bot. The bot is ready to use with all features including:

  • OpenAI API integration for intelligent code generation
  • Code generation in 16+ programming languages
  • Debugging assistance with error identification
  • Code explanations with detailed logic breakdowns
  • Syntax checking across multiple languages
  • Code analysis with quality metrics
  • GitHub integration for repository search
  • Code optimization and conversion
  • Security scanning and testing

Next Steps:

  1. Ensure the Flask server is running (Step 4)
  2. Open the frontend in your browser (Step 5)
  3. Start generating code or analyzing code to test the assistant
  4. Explore all the features, language options, and coding tools!

๐Ÿ”ง Troubleshooting Installation

โŒ API Key Issues

Solution: Ensure your .env file contains a valid OPENAI_API_KEY starting with sk-. Check API key has sufficient credits.

โŒ Flask Server Not Starting

Solution: Check Python version (3.8+), verify dependencies installed with pip install -r requirements.txt, ensure port 5000 is available.

โŒ Connection Errors

Solution: Verify Flask server is running on port 5000, check script.js has correct API_BASE_URL, ensure CORS is enabled in Flask.

โŒ Import Errors

Solution: Reinstall dependencies, check virtual environment is activated, verify all packages in requirements.txt are installed.

๐Ÿ“š Usage Guide - Step by Step

๐ŸŽฏ Getting Started with Code Assistant Bot

Step-by-Step Usage Instructions

๐Ÿ“ Step 1: Start Backend Server

  1. Ensure Flask server is running: python run.py
  2. Check server status at http://localhost:5000
  3. You should see the Code Assistant Bot interface

๐ŸŒ Step 2: Open Frontend

  1. Open http://localhost:5000 in your web browser
  2. You should see the Code Assistant Bot interface with:
    • Code editor area with syntax highlighting
    • Text input field for code generation
    • Language selection dropdown
    • Quick action buttons for different features
    • Features panel with coding capabilities
    • Statistics cards showing code generation stats
    • Send button

๐Ÿ’ป Step 3: Start Coding

  1. Code Generation: Describe the code you want to generate and select a programming language
  2. Debugging: Paste your code and any error messages to get debugging assistance
  3. Code Explanation: Paste code to get detailed explanations of its functionality
  4. Try These:
    • "Generate a Python function to calculate factorial"
    • "Debug this JavaScript code: [paste code]"
    • "Explain this Python code: [paste code]"
    • "Check syntax for this Java code: [paste code]"
    • "Search GitHub for Python web scraping repositories"
  5. View Results: The assistant will provide code, explanations, or analysis based on your request

โš™๏ธ Step 4: Explore Features

Try out the code assistant features:

  • Code Generation: Generate code in 16+ programming languages
  • Debugging: Get help identifying and fixing code errors
  • Code Analysis: Analyze code quality, complexity, and metrics
  • Syntax Checking: Validate syntax across multiple languages
  • GitHub Integration: Search and explore repositories
  • Code Optimization: Optimize code for performance and readability

๐Ÿ’ป Using the Code Assistant Bot

You can interact with the Code Assistant Bot through the web interface:

# Example Interactions User: "Generate a Python function to calculate factorial" Bot: [Generated Python code with explanation] User: "Debug this code: [paste code with error]" Bot: [Error identification and fix suggestions] User: "Explain this code: [paste code]" Bot: [Detailed explanation of code logic] User: "Check syntax for this JavaScript code: [paste code]" Bot: [Syntax validation results] User: "Search GitHub for Python web scraping" Bot: [List of relevant repositories]
# Quick Action Buttons - Generate Code: Generate code from description - Debug Code: Get debugging assistance - Explain Code: Get code explanations - Check Syntax: Validate code syntax - Analyze Code: Analyze code quality - Search GitHub: Search repositories

๐Ÿ“Š Features Usage

๐Ÿ’ป Code Generation

Generate code in 16+ languages - the assistant creates code from natural language descriptions

๐Ÿ› Debugging

Get debugging assistance with error identification and fix suggestions

๐Ÿ“– Code Explanations

Get detailed explanations of code logic and functionality

โœ… Syntax Checking

Real-time syntax validation across multiple programming languages

๐Ÿ“Š Code Analysis

Comprehensive code quality, complexity, and metrics analysis

๐ŸŒ GitHub Integration

Search and explore repositories with language filtering

โšก Code Optimization

Optimize code for performance, memory, and readability

๐Ÿ”„ Code Conversion

Convert code between 10+ programming languages

๐Ÿš€ Advanced Features & Capabilities

The Code Assistant Bot includes advanced AI capabilities, code analysis tools, and developer features. Here's what you can do:

๐Ÿ’ป Intelligent Code Generation

The assistant excels at generating code in 16+ programming languages with intelligent understanding, syntax validation, and best practices. Generate code naturally from descriptions.

๐Ÿ› Advanced Debugging

Identify and fix code errors with detailed explanations and suggestions. The assistant understands error messages and provides context-aware fixes.

๐Ÿ“Š Code Quality Intelligence

Analyze code quality, complexity, and metrics with detailed scoring. The assistant provides improvement suggestions based on industry standards.

๐Ÿ” Security & Testing

Advanced security scanning and automated testing across multiple test types. Detect vulnerabilities and ensure code reliability.

๐Ÿ’ป Code Examples

Basic Code Assistant Bot Integration

// Python Flask backend - app.py from flask import Flask, request, jsonify from utils.code_analyzer import CodeAnalyzer from utils.syntax_checker import SyntaxChecker from utils.github_integration import GitHubIntegration from openai import OpenAI app = Flask(__name__) code_analyzer = CodeAnalyzer() syntax_checker = SyntaxChecker() github_integration = GitHubIntegration() openai_client = OpenAI() @app.route('/api/generate', methods=['POST']) def generate_code(): data = request.json prompt = data.get('prompt', '') language = data.get('language', 'python') # Generate code using OpenAI response = openai_client.chat.completions.create( model='gpt-3.5-turbo', messages=[{ 'role': 'user', 'content': f'Generate {language} code: {prompt}' }] ) generated_code = response.choices[0].message.content return jsonify({ 'code': generated_code, 'language': language, 'success': True }) if __name__ == '__main__': app.run(debug=True, port=5000)

JavaScript Frontend Integration

// Frontend JavaScript - app.js async function generateCode(prompt, language = 'python') { const response = await fetch('http://localhost:5000/api/generate', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ prompt: prompt, language: language }) }); const data = await response.json(); return { code: data.code, language: data.language, success: data.success }; } // Usage generateCode('Create a function to calculate factorial', 'python').then(result => { console.log('Generated Code:', result.code); console.log('Language:', result.language); });

Complete Code Assistant Bot Example

// Code Assistant Bot Class class CodeAssistantBot { constructor(apiUrl) { this.apiUrl = apiUrl || 'http://localhost:5000'; this.codeHistory = []; this.currentLanguage = 'python'; } async generateCode(prompt, language = 'python') { const response = await fetch(`${this.apiUrl}/api/generate`, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ prompt: prompt, language: language }) }); const data = await response.json(); // Update code history this.codeHistory.push({ prompt: prompt, code: data.code, language: language, timestamp: new Date() }); return { code: data.code, language: language, success: data.success }; } async debugCode(code, errorMessage = '') { const response = await fetch(`${this.apiUrl}/api/debug`, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ code: code, error_message: errorMessage }) }); return await response.json(); } async explainCode(code) { const response = await fetch(`${this.apiUrl}/api/explain`, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({code: code}) }); return await response.json(); } clearHistory() { this.codeHistory = []; } } // Usage const codeBot = new CodeAssistantBot(); codeBot.generateCode('Create a function to calculate factorial', 'python').then(result => { console.log('Generated Code:', result.code); console.log('Language:', result.language); });

Configuration Example

// Frontend config - app.js const CodeAssistantConfig = { api: { baseUrl: 'http://localhost:5000', endpoints: { generate: '/api/generate', debug: '/api/debug', explain: '/api/explain', syntaxCheck: '/api/syntax-check', analyze: '/api/analyze', githubSearch: '/api/github/search' } }, languages: { supported: ['python', 'javascript', 'typescript', 'java', 'cpp', 'c', 'csharp', 'php', 'ruby', 'go', 'rust', 'html', 'css', 'sql', 'swift', 'kotlin'], default: 'python' }, model: { default: 'gpt-3.5-turbo', maxTokens: 2000, temperature: 0.7 }, ui: { animationDuration: 300, codeDisplayDelay: 500 } }; // Access configuration console.log(CodeAssistantConfig.languages.supported);
# Backend config - config.py import os from dotenv import load_dotenv load_dotenv() class Config: OPENAI_API_KEY = os.getenv('OPENAI_API_KEY') GITHUB_TOKEN = os.getenv('GITHUB_TOKEN', '') DEFAULT_MODEL = 'gpt-3.5-turbo' DEFAULT_MAX_TOKENS = 2000 DEFAULT_TEMPERATURE = 0.7 SUPPORTED_LANGUAGES = ['python', 'javascript', 'typescript', 'java', 'cpp', 'c', 'csharp', 'php', 'ruby', 'go', 'rust', 'html', 'css', 'sql', 'swift', 'kotlin'] DEFAULT_LANGUAGE = 'python' MAX_CODE_LENGTH = 10000

๐Ÿ”— OpenAI API Integration

OpenAI API Integration

The application integrates with OpenAI's GPT API for advanced code generation and analysis. The backend uses Python Flask to handle API calls, code generation, debugging, code analysis, and GitHub integration, while the frontend uses JavaScript for user interactions and code display.

Available APIs & Technologies

API/Technology Type Description
OpenAI GPT API AI API Advanced code generation and analysis
GitHub API Repository API Search and explore repositories
AST Python Library Code analysis and parsing
Flask REST API Backend Python Flask server for API endpoints
LocalStorage Browser API Store settings and code history
Prism.js Frontend Library Syntax highlighting for code display

Backend API Endpoints

# Flask Backend - app.py @app.route('/api/generate', methods=['POST']) def generate(): data = request.json prompt = data.get('prompt', '') language = data.get('language', 'python') result = code_assistant.generate_code(prompt, language) return jsonify(result) @app.route('/api/debug', methods=['POST']) def debug(): data = request.json code = data.get('code', '') error_message = data.get('error_message', '') result = code_assistant.debug_code(code, error_message) return jsonify(result) @app.route('/api/explain', methods=['POST']) def explain(): data = request.json code = data.get('code', '') result = code_assistant.explain_code(code) return jsonify(result) @app.route('/api/syntax-check', methods=['POST']) def syntax_check(): data = request.json code = data.get('code', '') language = data.get('language', 'python') result = syntax_checker.check(code, language) return jsonify(result) @app.route('/api/analyze', methods=['POST']) def analyze(): data = request.json code = data.get('code', '') language = data.get('language', 'python') result = code_analyzer.analyze(code, language) return jsonify(result) @app.route('/api/github/search', methods=['POST']) def github_search(): data = request.json query = data.get('query', '') language = data.get('language', '') result = github_integration.search(query, language) return jsonify(result) @app.route('/health', methods=['GET']) def health(): return jsonify({ 'status': 'healthy', 'openai_configured': bool(os.getenv('OPENAI_API_KEY')) })
// Frontend JavaScript - API Integration async function generateCode(prompt, language = 'python') { try { const response = await fetch('http://localhost:5000/api/generate', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ prompt: prompt, language: language }) }); if (!response.ok) { throw new Error('API request failed'); } const data = await response.json(); return { code: data.code, language: data.language, success: data.success }; } catch (error) { console.error('Error:', error); return {error: error.message}; } } // Debug code async function debugCode(code, errorMessage = '') { const response = await fetch('http://localhost:5000/api/debug', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ code: code, error_message: errorMessage }) }); return await response.json(); } // Explain code async function explainCode(code) { const response = await fetch('http://localhost:5000/api/explain', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({code: code}) }); return await response.json(); }

Browser Compatibility

// Check Code Assistant API Connection async function checkHealth() { try { const response = await fetch('http://localhost:5000/health'); const data = await response.json(); console.log('Server Status:', data.status); console.log('OpenAI Configured:', data.openai_configured); return data.openai_configured; } catch (error) { console.error('Health check failed:', error); return false; } } // Get supported languages const SUPPORTED_LANGUAGES = [ 'python', 'javascript', 'typescript', 'java', 'cpp', 'c', 'csharp', 'php', 'ruby', 'go', 'rust', 'html', 'css', 'sql', 'swift', 'kotlin' ]; // Recommended setup: // - Backend: Python 3.8+ with Flask, OpenAI API, AST // - Frontend: Modern browsers (Chrome, Edge, Safari, Firefox) // - Code Display: Prism.js for syntax highlighting // - GitHub Integration: GitHub token (optional)

โš™๏ธ Configuration

Configuration in this application is handled through environment variables and settings files:

Environment Variables

Create a .env file in the project root (copy from .env.example):

# .env file OPENAI_API_KEY=sk-your-openai-api-key-here GITHUB_TOKEN=your-github-token-here FLASK_ENV=development SECRET_KEY=your-secret-key-here PORT=5000 MAX_CODE_LENGTH=10000

Note: Get your API keys from OpenAI Platform and GitHub Settings. Never commit your .env file to version control.

Python Configuration (config.py)

The config.py file contains configuration settings:

# config.py import os from dotenv import load_dotenv load_dotenv() class Config: OPENAI_API_KEY = os.getenv('OPENAI_API_KEY') GITHUB_TOKEN = os.getenv('GITHUB_TOKEN', '') DEFAULT_MODEL = 'gpt-3.5-turbo' DEFAULT_MAX_TOKENS = 2000 DEFAULT_TEMPERATURE = 0.7 SUPPORTED_LANGUAGES = ['python', 'javascript', 'typescript', 'java', 'cpp', 'c', 'csharp', 'php', 'ruby', 'go', 'rust', 'html', 'css', 'sql', 'swift', 'kotlin'] DEFAULT_LANGUAGE = 'python' MAX_CODE_LENGTH = 10000

Frontend Configuration

Edit app.js to configure API endpoint:

// app.js const API_BASE_URL = 'http://localhost:5000'; const DEFAULT_MODEL = 'gpt-3.5-turbo'; const DEFAULT_MAX_TOKENS = 2000; const DEFAULT_TEMPERATURE = 0.7; const SUPPORTED_LANGUAGES = ['python', 'javascript', 'typescript', 'java', 'cpp', 'c', 'csharp', 'php', 'ruby', 'go', 'rust', 'html', 'css', 'sql', 'swift', 'kotlin']; const DEFAULT_LANGUAGE = 'python';

Browser LocalStorage Settings

User settings are automatically saved to browser's local storage:

// Settings are saved automatically localStorage.setItem('codeAssistantSettings', JSON.stringify({ model: 'gpt-3.5-turbo', maxTokens: 2000, temperature: 0.7, language: 'python', syntaxHighlighting: true, codeFormatting: true, autoSave: true })); // Load settings const settings = JSON.parse(localStorage.getItem('codeAssistantSettings'));

Runtime Configuration

Configure settings through the web interface:

  • Language: Select preferred programming language (16+ languages supported)
  • Code Generation: Configure code generation parameters
  • Syntax Highlighting: Enable/disable syntax highlighting
  • Code Formatting: Enable/disable automatic code formatting
  • GitHub Integration: Configure GitHub token for repository search
  • Code Analysis: Enable/disable code quality analysis

All settings are saved automatically and persist across browser sessions.

๐Ÿ“ Project Structure

The Code Assistant Bot follows a clean, organized structure for easy navigation and maintenance.

code-assistant-bot/
โ”œโ”€โ”€ code-assistant-bot/
โ”‚   โ”œโ”€โ”€ templates/
โ”‚   โ”‚   โ””โ”€โ”€ index.html      # Main HTML interface
โ”‚   โ”œโ”€โ”€ static/
โ”‚   โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ style.css   # Modern styling
โ”‚   โ”‚   โ””โ”€โ”€ js/
โ”‚   โ”‚       โ””โ”€โ”€ app.js      # Frontend logic
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ code_analyzer.py    # Code analysis
โ”‚   โ”‚   โ”œโ”€โ”€ code_optimizer.py   # Code optimization
โ”‚   โ”‚   โ”œโ”€โ”€ code_converter.py   # Language conversion
โ”‚   โ”‚   โ”œโ”€โ”€ code_tester.py      # Code testing
โ”‚   โ”‚   โ”œโ”€โ”€ github_integration.py # GitHub API
โ”‚   โ”‚   โ”œโ”€โ”€ syntax_checker.py   # Syntax validation
โ”‚   โ”‚   โ”œโ”€โ”€ code_formatter.py   # Code formatting
โ”‚   โ”‚   โ”œโ”€โ”€ code_documenter.py  # Documentation
โ”‚   โ”‚   โ”œโ”€โ”€ code_reviewer.py    # Code review
โ”‚   โ”‚   โ””โ”€โ”€ code_comparator.py  # Code comparison
โ”‚   โ”œโ”€โ”€ app.py              # Flask backend server
โ”‚   โ”œโ”€โ”€ config.py           # Configuration settings
โ”‚   โ”œโ”€โ”€ run.py              # Application runner
โ”‚   โ””โ”€โ”€ requirements.txt    # Python dependencies
โ”œโ”€โ”€ demo/
โ”‚   โ”œโ”€โ”€ index.html          # Documentation page
โ”‚   โ”œโ”€โ”€ demo.html           # Interactive demo
โ”‚   โ”œโ”€โ”€ style.css           # Demo styling
โ”‚   โ””โ”€โ”€ script.js           # Demo scripts
โ”œโ”€โ”€ .env                    # Environment variables
โ””โ”€โ”€ README.md               # Project documentation

๐Ÿ“„ Frontend Files

Location: code-assistant-bot/templates/ and code-assistant-bot/static/

  • templates/index.html - Main UI interface with code editor
  • static/css/style.css - Modern gradient styling
  • static/js/app.js - JavaScript functionality

๐Ÿ Backend Files

Location: code-assistant-bot/

  • app.py - Flask server & API endpoints
  • config.py - Configuration settings
  • run.py - Application entry point
  • utils/code_analyzer.py - Code analysis
  • utils/code_optimizer.py - Code optimization
  • utils/github_integration.py - GitHub integration
  • utils/syntax_checker.py - Syntax validation

โš™๏ธ Configuration

Setup: Configure these files for your environment

  • .env - Environment variables (API keys)
  • requirements.txt - Python dependencies
  • config.py - Application configuration

๐Ÿ”ง Troubleshooting

API Key Issues

  • Ensure your .env file contains a valid OPENAI_API_KEY starting with sk-
  • Optionally add GOOGLE_TRANSLATE_API_KEY for enhanced translations
  • Check that the API key is correctly formatted and not expired
  • Verify your API key has sufficient credits in OpenAI Platform
  • Make sure the .env file is in the project root directory
  • Restart the Flask server after updating the API key

Flask Server Issues

  • Server not starting: Check Python version (3.8+), verify dependencies installed with pip install -r requirements.txt
  • Port 5000 in use: Change port in .env file or stop other applications using port 5000
  • Import errors: Ensure virtual environment is activated, reinstall dependencies
  • CORS errors: Verify Flask-CORS is installed and enabled in app.py
  • Connection refused: Check firewall settings, ensure server is running on correct port

Frontend Connection Issues

  • Failed to fetch: Ensure Flask server is running, check API_BASE_URL in chatbot.js
  • CORS errors: Make sure Flask-CORS is installed and configured in backend
  • Server offline indicator: Check server status at http://localhost:5000
  • Port mismatch: Verify frontend API_BASE_URL matches backend port
  • Code analysis not working: Ensure all dependencies are installed: pip install -r requirements.txt
  • GitHub integration errors: Check GitHub token if using enhanced repository search

Common Issues

  • API key not found: Create .env file from .env.example and add your API keys
  • Module not found: Install dependencies with pip install -r requirements.txt
  • Code analysis errors: Ensure all dependencies are installed: pip install -r requirements.txt
  • GitHub integration errors: Check GitHub token if using repository search: pip install requests
  • Response errors: Check API key validity, verify credits, check OpenAI API status
  • Syntax checking not working: Verify syntax_checker module is properly configured
  • Code generation errors: Check OpenAI API key and model availability

๐Ÿ“‹ Requirements

Backend Requirements: - Python 3.8 or higher - Flask web framework - OpenAI Python SDK - Flask-CORS for CORS support - AST for code analysis - Requests for GitHub API Frontend Requirements: - Modern Web Browser (Chrome, Edge, Safari, Firefox) - JavaScript ES6+ support - LocalStorage API - Prism.js for syntax highlighting API Requirements: - OpenAI API Key (get from platform.openai.com) - GitHub Token (optional, for enhanced repository search) - Active internet connection for API calls Python Dependencies (see requirements.txt): - openai - flask - flask-cors - python-dotenv - requests - astroid - pylint Optional Dependencies: - GitHub token for repository search - Additional code analysis libraries

Browser Compatibility: Chrome, Edge, Safari, or Firefox (Chrome/Edge recommended for best performance).

Python Version: Python 3.8 or higher required for backend server.

Internet Connection: Required for OpenAI API calls and CDN resources.

๐ŸŽฏ Use Cases

๐Ÿ’ป Code Generation

Generate code in 16+ programming languages from natural language descriptions

๐Ÿ› Debugging Tools

Advanced debugging assistance with error identification and fix suggestions

๐Ÿ“š Programming Education

Educational coding platforms and programming learning tools

๐Ÿ”ง Developer Tools

Integrate code generation and analysis capabilities into development workflows

๐ŸŒ IDE Integration

Add code assistance features to IDEs and code editors

๐Ÿ“Š Code Quality Analysis

Track code quality metrics, complexity scores, and improvement suggestions

๐Ÿ” Code Review

Automated code review and quality assessment for development teams

โšก Code Optimization

Performance and memory optimization tools for code improvement

๐Ÿ’ฌ Support

For support, questions, or more projects:

๐Ÿ“„ License

This project is provided as-is for educational and development purposes.

MIT License - See LICENSE file for details.