help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
code-assistant-bot
/
templates
RSK World
code-assistant-bot
Code Assistant Bot - Python + Flask + OpenAI API + Code Generation + Debugging + Code Analysis + GitHub Integration
templates
  • index.html31.8 KB
.gitignoreREADME.mdsetup.cpython-313.pycsyntax_checker.pyRELEASE_NOTES.md__init__.py
.gitignore
Raw Download
Find: Go to:
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Virtual Environment
venv/
env/
ENV/
env.bak/
venv.bak/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Environment variables
.env
.env.local
.env.*.local

# Logs
*.log
logs/
*.log.*

# Database
*.db
*.sqlite
*.sqlite3

# Flask
instance/
.webassets-cache

# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# Celery
celerybeat-schedule
celerybeat.pid

# SageMath
*.sage.py

# Spyder
.spyderproject
.spyproject

# Rope
.ropeproject

# mkdocs
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre
.pyre/

# OS
Thumbs.db
.DS_Store

# Project specific
code_assistant_bot.log
*.pyc
.python-version
103 linesโ€ข956 B
text
README.md
Raw Download

README.md

# Code Assistant Bot

**AI-powered coding assistant for code generation, debugging, and explanations**

![Code Assistant Bot](code-assistant-bot.png)

**Author:** RSK World
**Founder:** Molla Samser
**Designer & Tester:** Rima Khatun
**Contact:** help@rskworld.in | +91 93305 39277
**Website:** [https://rskworld.in](https://rskworld.in)
**Year:** 2026

---

## ๐Ÿ“‹ Project Overview

Code Assistant Bot is an advanced AI-powered coding assistant that helps developers with:
- **Code Generation** - Generate code from natural language descriptions
- **Debugging Assistance** - Find bugs and get suggestions for fixes
- **Code Explanations** - Understand complex code with detailed explanations
- **Syntax Checking** - Validate syntax across multiple programming languages
- **Code Analysis** - Analyze code quality, complexity, and metrics
- **GitHub Integration** - Search and explore repositories

Perfect for coding platforms, developer tools, and programming education.

---

## ๐Ÿš€ Features

### Core Features
- โœ… **Code Generation** - Generate code in 16+ programming languages
- โœ… **Debugging Help** - Identify and fix code errors
- โœ… **Code Explanations** - Get detailed explanations of code logic
- โœ… **Syntax Validation** - Check syntax errors in real-time
- โœ… **Code Analysis** - Analyze code quality and complexity
- โœ… **GitHub Search** - Search repositories by language and keywords

### Supported Languages
- Python, JavaScript, TypeScript, Java
- C++, C, C#, PHP, Ruby, Go, Rust
- HTML, CSS, SQL, Swift, Kotlin

### Advanced Features
- ๐ŸŽฏ **Intelligent Code Analysis** - Cyclomatic complexity, cognitive complexity
- ๐Ÿ” **Security Scanning** - Detect common security vulnerabilities
- ๐Ÿ“Š **Quality Metrics** - Code quality scoring and suggestions
- ๐ŸŒ **GitHub Integration** - Search and explore repositories
- ๐Ÿ“ฑ **Responsive Design** - Works on all devices
- ๐ŸŽจ **Modern UI** - Beautiful, intuitive interface

---

## ๐Ÿ› ๏ธ Technologies Used

### Backend
- **Python 3.8+** - Core programming language
- **Flask** - Web framework
- **OpenAI API** - AI-powered code processing
- **AST** - Python code analysis
- **Requests** - HTTP client for GitHub API

### Frontend
- **HTML5** - Semantic markup
- **CSS3** - Modern styling with animations
- **JavaScript ES6+** - Interactive functionality
- **Bootstrap 5** - Responsive UI framework
- **Font Awesome** - Icon library
- **Prism.js** - Syntax highlighting

### Development Tools
- **pytest** - Testing framework
- **black** - Code formatting
- **flake8** - Linting
- **python-dotenv** - Environment management

---

## ๐Ÿ“ฆ Installation

### Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- OpenAI API key

### Step 1: Clone the Repository
```bash
git clone https://github.com/your-repo/code-assistant-bot.git
cd code-assistant-bot
```

### Step 2: Create Virtual Environment
```bash
python -m venv venv

# Windows
venv\Scripts\activate

# macOS/Linux
source venv/bin/activate
```

### Step 3: Install Dependencies
```bash
pip install -r requirements.txt
```

### Step 4: Environment Configuration
```bash
# Copy environment template
cp .env.example .env

# Edit .env file with your configuration
# Add your OpenAI API key
OPENAI_API_KEY=your_openai_api_key_here
```

### Step 5: Run the Application
```bash
python app.py
```

The application will be available at `http://localhost:5000`

---

## ๐Ÿ”ง Configuration

### Environment Variables
Create a `.env` file with the following variables:

```env
# OpenAI API Configuration
OPENAI_API_KEY=your_openai_api_key_here

# Flask Configuration
SECRET_KEY=your_secret_key_here
FLASK_ENV=development
PORT=5000

# GitHub API Configuration (Optional)
GITHUB_TOKEN=your_github_personal_access_token_here

# Application Configuration
MAX_CODE_LENGTH=10000
RATE_LIMIT_PER_MINUTE=60
LOG_LEVEL=INFO
```

### OpenAI API Setup
1. Visit [OpenAI Platform](https://platform.openai.com/)
2. Create an account or sign in
3. Generate an API key
4. Add the API key to your `.env` file

### GitHub Token Setup (Optional)
1. Visit [GitHub Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens)
2. Generate a new token with `public_repo` scope
3. Add the token to your `.env` file for higher rate limits

---

## ๐Ÿ“– Usage Guide

### Code Generation
1. Select "Generate Code" from the action dropdown
2. Choose your programming language
3. Describe the code you want to generate
4. Click "Generate Code"

### Debugging
1. Select "Debug Code" from the action dropdown
2. Paste your code in the input area
3. Optionally add any error messages
4. Click "Debug Code"

### Code Explanation
1. Select "Explain Code" from the action dropdown
2. Paste the code you want to understand
3. Click "Explain Code"

### Syntax Checking
1. Select "Check Syntax" from the action dropdown
2. Paste your code
3. Click "Check Syntax"

### GitHub Search
1. Enter search terms in the GitHub search box
2. Optionally filter by programming language
3. Click "Search" to explore repositories

---

## ๐Ÿ—๏ธ Project Structure

```
code-assistant-bot/
โ”œโ”€โ”€ app.py # Main Flask application
โ”œโ”€โ”€ config.py # Configuration settings
โ”œโ”€โ”€ requirements.txt # Python dependencies
โ”œโ”€โ”€ .env.example # Environment template
โ”œโ”€โ”€ utils/ # Utility modules
โ”‚ โ”œโ”€โ”€ __init__.py
โ”‚ โ”œโ”€โ”€ code_analyzer.py # Code analysis utilities
โ”‚ โ”œโ”€โ”€ github_integration.py # GitHub API integration
โ”‚ โ””โ”€โ”€ syntax_checker.py # Syntax checking utilities
โ”œโ”€โ”€ templates/ # HTML templates
โ”‚ โ””โ”€โ”€ index.html # Main frontend interface
โ”œโ”€โ”€ static/ # Static assets
โ”‚ โ”œโ”€โ”€ css/
โ”‚ โ”‚ โ””โ”€โ”€ style.css # Custom styling
โ”‚ โ””โ”€โ”€ js/
โ”‚ โ””โ”€โ”€ app.js # Frontend JavaScript
โ”œโ”€โ”€ tests/ # Test files (optional)
โ””โ”€โ”€ README.md # This file
```

---

## ๐Ÿ”Œ API Endpoints

### Core Endpoints
- `POST /api/generate` - Generate code from prompt
- `POST /api/debug` - Debug code and provide fixes
- `POST /api/explain` - Explain code functionality
- `POST /api/syntax-check` - Check code syntax
- `POST /api/analyze` - Analyze code quality
- `POST /api/github/search` - Search GitHub repositories
- `GET /api/languages` - Get supported languages
- `GET /health` - Health check endpoint

### Request Format
```json
{
"code": "your code here",
"language": "python",
"prompt": "description for code generation",
"error_message": "optional error message for debugging"
}
```

### Response Format
```json
{
"success": true,
"result": "processed result",
"language": "python",
"timestamp": "2026-01-09T22:33:00"
}
```

---

## ๐Ÿงช Testing

### Run Tests
```bash
# Install test dependencies
pip install pytest pytest-flask

# Run all tests
pytest

# Run with coverage
pytest --cov=utils
```

### Manual Testing
1. Start the application: `python app.py`
2. Open browser to `http://localhost:5000`
3. Test each feature through the web interface
4. Verify API endpoints using tools like Postman

---

## ๐Ÿš€ Deployment

### Production Deployment

#### Using Docker
```dockerfile
FROM python:3.9-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
EXPOSE 5000

CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
```

#### Using Gunicorn
```bash
# Install gunicorn
pip install gunicorn

# Run production server
gunicorn --bind 0.0.0.0:5000 app:app
```

#### Environment Setup
- Set `FLASK_ENV=production`
- Use a proper WSGI server like Gunicorn
- Configure reverse proxy (Nginx/Apache)
- Set up SSL certificates
- Configure monitoring and logging

---

## ๐Ÿ”’ Security Considerations

### API Key Security
- Never expose OpenAI API keys in frontend code
- Use environment variables for sensitive data
- Rotate API keys regularly
- Monitor API usage for unusual activity

### Input Validation
- Code length is limited to 10,000 characters
- Input sanitization for all user inputs
- Rate limiting to prevent abuse
- Error handling without exposing system details

### Best Practices
- Use HTTPS in production
- Implement proper authentication if needed
- Regular security updates
- Monitor for vulnerabilities

---

## ๐Ÿค Contributing

We welcome contributions! Please follow these guidelines:

### Development Setup
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Submit a pull request

### Code Style
- Follow PEP 8 for Python code
- Use Black for code formatting
- Add comments for complex logic
- Include docstrings for functions

### Commit Messages
- Use clear, descriptive commit messages
- Start with a verb (Fix, Add, Update, etc.)
- Include issue numbers when applicable

---

## ๐Ÿ“ License

This project is part of RSK World's educational resources.

**ยฉ 2026 RSK World. All rights reserved.**

**Developed by:** Molla Samser
**Designed & Tested by:** Rima Khatun

**Contact Information:**
- **Email:** help@rskworld.in
- **Phone:** +91 93305 39277
- **Address:** Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India - 713147
- **Website:** [https://rskworld.in](https://rskworld.in)

---

## ๐ŸŒŸ Acknowledgments

- **OpenAI** - For providing the powerful GPT API
- **GitHub** - For repository search functionality
- **Bootstrap** - For the responsive UI framework
- **Prism.js** - For syntax highlighting
- **Font Awesome** - For beautiful icons

---

## ๐Ÿ“ž Support

For support, questions, or feedback:

- ๐Ÿ“ง **Email:** help@rskworld.in
- ๐ŸŒ **Website:** [https://rskworld.in](https://rskworld.in)
- ๐Ÿ“ฑ **Phone:** +91 93305 39277

---

**Made with โค๏ธ by RSK World**

*Empowering developers with AI-powered tools since 2026*
utils/syntax_checker.py
Raw Download
Find: Go to:
"""
Syntax Checker Utility for Code Assistant Bot
Author: RSK World (https://rskworld.in)
Founder: Molla Samser
Designer & Tester: Rima Khatun
Contact: help@rskworld.in, +91 93305 39277
Year: 2026
"""

import ast
import re
import subprocess
import tempfile
import os
from typing import Dict, List, Any, Tuple

class SyntaxChecker:
    """
    Utility class for checking syntax errors in various programming languages
    """
    
    def __init__(self):
        self.supported_languages = [
            'python', 'javascript', 'java', 'cpp', 'c', 'csharp',
            'php', 'ruby', 'go', 'rust', 'typescript', 'html', 'css'
        ]
    
    def check_syntax(self, code: str, language: str) -> Dict[str, Any]:
        """
        Check syntax for the given code and language
        """
        try:
            if language not in self.supported_languages:
                return {
                    'valid': False,
                    'error': f'Language {language} is not supported',
                    'errors': [],
                    'warnings': []
                }
            
            # Language-specific syntax checking
            if language == 'python':
                return self._check_python_syntax(code)
            elif language in ['javascript', 'typescript']:
                return self._check_javascript_syntax(code, language)
            elif language == 'java':
                return self._check_java_syntax(code)
            elif language in ['cpp', 'c']:
                return self._check_cpp_syntax(code, language)
            elif language == 'csharp':
                return self._check_csharp_syntax(code)
            elif language == 'php':
                return self._check_php_syntax(code)
            elif language == 'ruby':
                return self._check_ruby_syntax(code)
            elif language == 'go':
                return self._check_go_syntax(code)
            elif language == 'rust':
                return self._check_rust_syntax(code)
            elif language == 'html':
                return self._check_html_syntax(code)
            elif language == 'css':
                return self._check_css_syntax(code)
            else:
                return {
                    'valid': True,
                    'error': None,
                    'errors': [],
                    'warnings': ['Syntax checking not implemented for this language']
                }
                
        except Exception as e:
            return {
                'valid': False,
                'error': f'Syntax checking failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_python_syntax(self, code: str) -> Dict[str, Any]:
        """Check Python syntax using AST"""
        try:
            # Parse the code
            ast.parse(code)
            
            # Additional checks
            warnings = self._check_python_style(code)
            
            return {
                'valid': True,
                'error': None,
                'errors': [],
                'warnings': warnings
            }
            
        except SyntaxError as e:
            return {
                'valid': False,
                'error': 'Syntax error detected',
                'errors': [{
                    'line': e.lineno or 0,
                    'column': e.offset or 0,
                    'message': e.msg or 'Unknown syntax error'
                }],
                'warnings': []
            }
        except Exception as e:
            return {
                'valid': False,
                'error': f'Parse error: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_javascript_syntax(self, code: str, language: str) -> Dict[str, Any]:
        """Check JavaScript/TypeScript syntax"""
        try:
            # Basic syntax checks using regex patterns
            errors = []
            warnings = []
            
            # Check for unmatched brackets
            bracket_pairs = {'(': ')', '[': ']', '{': '}'}
            stack = []
            
            for i, char in enumerate(code):
                if char in bracket_pairs:
                    stack.append((char, i))
                elif char in bracket_pairs.values():
                    if not stack:
                        errors.append({
                            'line': code[:i].count('\n') + 1,
                            'column': i - code.rfind('\n', 0, i) - 1,
                            'message': f'Unmatched closing bracket: {char}'
                        })
                    else:
                        open_bracket, _ = stack.pop()
                        expected_close = bracket_pairs[open_bracket]
                        if char != expected_close:
                            errors.append({
                                'line': code[:i].count('\n') + 1,
                                'column': i - code.rfind('\n', 0, i) - 1,
                                'message': f'Expected {expected_close} but found {char}'
                            })
            
            # Check for unclosed brackets
            for open_bracket, pos in stack:
                errors.append({
                    'line': code[:pos].count('\n') + 1,
                    'column': pos - code.rfind('\n', 0, pos) - 1,
                    'message': f'Unclosed bracket: {open_bracket}'
                })
            
            # Check for common issues
            if '==' in code and '===' not in code:
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'Consider using === instead of == for strict equality'
                })
            
            # Check for missing semicolons (basic check)
            lines = code.split('\n')
            for i, line in enumerate(lines):
                stripped = line.strip()
                if (stripped and 
                    not stripped.endswith(('{', '}', ';', ',', '(', ')', '[', ']')) and
                    not any(keyword in stripped for keyword in ['if', 'for', 'while', 'function', 'else', 'try', 'catch', 'finally', 'class', 'return', 'break', 'continue']) and
                    not stripped.startswith('//') and
                    not stripped.startswith('/*')):
                    warnings.append({
                        'line': i + 1,
                        'column': len(line),
                        'message': 'Missing semicolon at end of line'
                    })
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'Syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'JavaScript syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_java_syntax(self, code: str) -> Dict[str, Any]:
        """Check Java syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for class declaration
            if not re.search(r'\bclass\s+\w+', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No class declaration found'
                })
            
            # Check for main method
            if not re.search(r'public\s+static\s+void\s+main\s*\(\s*String\s*\[\s*\]\s*\w+\s*\)', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No main method found'
                })
            
            # Check for unmatched brackets
            bracket_errors = self._check_brackets(code)
            errors.extend(bracket_errors)
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'Syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'Java syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_cpp_syntax(self, code: str, language: str) -> Dict[str, Any]:
        """Check C/C++ syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for main function
            if not re.search(r'int\s+main\s*\(', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No main function found'
                })
            
            # Check for include statements
            if not re.search(r'#include\s*<[^>]+>', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No include statements found'
                })
            
            # Check for unmatched brackets
            bracket_errors = self._check_brackets(code)
            errors.extend(bracket_errors)
            
            # Check for missing semicolons
            lines = code.split('\n')
            for i, line in enumerate(lines):
                stripped = line.strip()
                if (stripped and 
                    not stripped.endswith(('{', '}', ';', ',', '(', ')', '[', ']', ':', '//')) and
                    not any(keyword in stripped for keyword in ['if', 'for', 'while', 'else', 'switch', 'case', 'default', 'return', 'break', 'continue', 'using', 'namespace']) and
                    not stripped.startswith('#') and
                    not stripped.startswith('//')):
                    warnings.append({
                        'line': i + 1,
                        'column': len(line),
                        'message': 'Missing semicolon at end of line'
                    })
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'Syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'C/C++ syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_csharp_syntax(self, code: str) -> Dict[str, Any]:
        """Check C# syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for class declaration
            if not re.search(r'\bclass\s+\w+', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No class declaration found'
                })
            
            # Check for Main method
            if not re.search(r'static\s+void\s+Main\s*\(', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No Main method found'
                })
            
            # Check for using statements
            if not re.search(r'using\s+\w+(?:\.\w+)*\s*;', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No using statements found'
                })
            
            # Check for unmatched brackets
            bracket_errors = self._check_brackets(code)
            errors.extend(bracket_errors)
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'Syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'C# syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_php_syntax(self, code: str) -> Dict[str, Any]:
        """Check PHP syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for PHP tags
            if not re.search(r'<\?php', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No PHP opening tag found'
                })
            
            # Check for unmatched brackets
            bracket_errors = self._check_brackets(code)
            errors.extend(bracket_errors)
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'Syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'PHP syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_ruby_syntax(self, code: str) -> Dict[str, Any]:
        """Check Ruby syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for unmatched brackets
            bracket_errors = self._check_brackets(code)
            errors.extend(bracket_errors)
            
            # Check for end statements
            do_count = len(re.findall(r'\bdo\b', code))
            end_count = len(re.findall(r'\bend\b', code))
            
            if do_count != end_count:
                errors.append({
                    'line': 0,
                    'column': 0,
                    'message': f'Mismatched do/end blocks: {do_count} do, {end_count} end'
                })
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'Syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'Ruby syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_go_syntax(self, code: str) -> Dict[str, Any]:
        """Check Go syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for package declaration
            if not re.search(r'package\s+\w+', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No package declaration found'
                })
            
            # Check for main function
            if not re.search(r'func\s+main\s*\(', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No main function found'
                })
            
            # Check for unmatched brackets
            bracket_errors = self._check_brackets(code)
            errors.extend(bracket_errors)
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'Syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'Go syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_rust_syntax(self, code: str) -> Dict[str, Any]:
        """Check Rust syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for fn main
            if not re.search(r'fn\s+main\s*\(', code):
                warnings.append({
                    'line': 0,
                    'column': 0,
                    'message': 'No main function found'
                })
            
            # Check for unmatched brackets
            bracket_errors = self._check_brackets(code)
            errors.extend(bracket_errors)
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'Syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'Rust syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_html_syntax(self, code: str) -> Dict[str, Any]:
        """Check HTML syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for unmatched tags
            tag_pattern = r'<(/?)([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>'
            tags = re.finditer(tag_pattern, code)
            
            stack = []
            for match in tags:
                is_closing = match.group(1) == '/'
                tag_name = match.group(2).lower()
                position = match.start()
                
                # Skip self-closing tags
                if match.group(0).endswith('/>') or tag_name in ['br', 'hr', 'img', 'meta', 'link', 'input']:
                    continue
                
                if is_closing:
                    if not stack or stack[-1] != tag_name:
                        errors.append({
                            'line': code[:position].count('\n') + 1,
                            'column': position - code.rfind('\n', 0, position) - 1,
                            'message': f'Unexpected closing tag: {tag_name}'
                        })
                    else:
                        stack.pop()
                else:
                    stack.append(tag_name)
            
            # Check for unclosed tags
            for tag in stack:
                errors.append({
                    'line': 0,
                    'column': 0,
                    'message': f'Unclosed tag: {tag}'
                })
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'HTML syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'HTML syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_css_syntax(self, code: str) -> Dict[str, Any]:
        """Check CSS syntax (basic checks)"""
        try:
            errors = []
            warnings = []
            
            # Check for unmatched braces
            open_braces = code.count('{')
            close_braces = code.count('}')
            
            if open_braces != close_braces:
                errors.append({
                    'line': 0,
                    'column': 0,
                    'message': f'Unmatched braces: {open_braces} opening, {close_braces} closing'
                })
            
            # Check for invalid selectors (basic check)
            selector_pattern = r'([^{]+)\s*\{'
            matches = re.finditer(selector_pattern, code)
            
            for match in matches:
                selector = match.group(1).strip()
                if not selector:
                    errors.append({
                        'line': code[:match.start()].count('\n') + 1,
                        'column': match.start() - code.rfind('\n', 0, match.start()) - 1,
                        'message': 'Empty selector found'
                    })
            
            return {
                'valid': len(errors) == 0,
                'error': None if len(errors) == 0 else 'CSS syntax errors detected',
                'errors': errors,
                'warnings': warnings
            }
            
        except Exception as e:
            return {
                'valid': False,
                'error': f'CSS syntax check failed: {str(e)}',
                'errors': [{'line': 0, 'column': 0, 'message': str(e)}],
                'warnings': []
            }
    
    def _check_brackets(self, code: str) -> List[Dict[str, Any]]:
        """Check for unmatched brackets"""
        errors = []
        bracket_pairs = {'(': ')', '[': ']', '{': '}'}
        stack = []
        
        for i, char in enumerate(code):
            if char in bracket_pairs:
                stack.append((char, i))
            elif char in bracket_pairs.values():
                if not stack:
                    errors.append({
                        'line': code[:i].count('\n') + 1,
                        'column': i - code.rfind('\n', 0, i) - 1,
                        'message': f'Unmatched closing bracket: {char}'
                    })
                else:
                    open_bracket, _ = stack.pop()
                    expected_close = bracket_pairs[open_bracket]
                    if char != expected_close:
                        errors.append({
                            'line': code[:i].count('\n') + 1,
                            'column': i - code.rfind('\n', 0, i) - 1,
                            'message': f'Expected {expected_close} but found {char}'
                        })
        
        # Check for unclosed brackets
        for open_bracket, pos in stack:
            errors.append({
                'line': code[:pos].count('\n') + 1,
                'column': pos - code.rfind('\n', 0, pos) - 1,
                'message': f'Unclosed bracket: {open_bracket}'
            })
        
        return errors
    
    def _check_python_style(self, code: str) -> List[Dict[str, Any]]:
        """Check Python code style issues"""
        warnings = []
        lines = code.split('\n')
        
        for i, line in enumerate(lines):
            stripped = line.strip()
            
            # Check line length
            if len(line) > 79:
                warnings.append({
                    'line': i + 1,
                    'column': 80,
                    'message': f'Line too long ({len(line)} > 79 characters)'
                })
            
            # Check for trailing whitespace
            if line.endswith(' ') or line.endswith('\t'):
                warnings.append({
                    'line': i + 1,
                    'column': len(line),
                    'message': 'Trailing whitespace'
                })
            
            # Check for missing docstring in functions
            if stripped.startswith('def ') and ':' in stripped:
                next_line = lines[i + 1] if i + 1 < len(lines) else ''
                if not next_line.strip().startswith('"""') and not next_line.strip().startswith("'''"):
                    warnings.append({
                        'line': i + 1,
                        'column': len(stripped),
                        'message': 'Missing docstring in function'
                    })
        
        return warnings
652 linesโ€ข24.3 KB
python
RELEASE_NOTES.md
Raw Download

RELEASE_NOTES.md

# Code Assistant Bot - Release Notes

## Version 1.0.0 - Initial Release
**Release Date:** January 2026
**Repository:** [https://github.com/rskworld/code-assistant-bot](https://github.com/rskworld/code-assistant-bot)

---

## ๐ŸŽ‰ What's New

### Core Features
- โœ… **Code Generation** - AI-powered code generation from natural language descriptions
- โœ… **Code Debugging** - Intelligent bug detection and fix suggestions
- โœ… **Code Explanation** - Detailed explanations of code logic and functionality
- โœ… **Syntax Checking** - Real-time syntax validation for 16+ programming languages
- โœ… **Code Analysis** - Comprehensive code quality, complexity, and metrics analysis
- โœ… **Code Optimization** - Performance, memory, readability, and security optimizations
- โœ… **Code Conversion** - Convert code between multiple programming languages
- โœ… **Code Testing** - Syntax, unit, integration, performance, and security testing

### Advanced Features
- ๐ŸŽจ **Code Formatting** - Beautify and format code for multiple languages
- ๐Ÿ“ **Documentation Generation** - Auto-generate docstrings and comments
- ๐Ÿ” **Code Review** - Automated code review with issue detection and suggestions
- ๐Ÿ”„ **Code Comparison** - Side-by-side code comparison with diff visualization
- ๐Ÿ”— **GitHub Integration** - Search and explore GitHub repositories

### Supported Languages
- Python, JavaScript, TypeScript, Java
- C++, C, C#, PHP, Ruby, Go, Rust
- HTML, CSS, SQL, Swift, Kotlin

---

## ๐Ÿš€ Key Highlights

### Modern Tech Stack
- **Backend:** Python 3.9+, Flask 2.3.3, OpenAI API
- **Frontend:** HTML5, CSS3, JavaScript ES6+, Bootstrap 5
- **Features:** Real-time processing, syntax highlighting, responsive design

### Developer Experience
- Clean, intuitive user interface
- Real-time code processing
- Comprehensive error handling
- Detailed result visualization
- Export and download capabilities

### Security & Quality
- Input validation and sanitization
- Secure API key handling
- Error handling and logging
- Code security scanning
- Best practices enforcement

---

## ๐Ÿ“ฆ Installation

```bash
# Clone the repository
git clone https://github.com/rskworld/code-assistant-bot.git
cd code-assistant-bot

# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Set environment variables
export OPENAI_API_KEY=your_api_key_here
export SECRET_KEY=your_secret_key_here

# Run the application
python run.py
```

---

## ๐Ÿ”ง Configuration

Create a `.env` file with:
```env
OPENAI_API_KEY=your_openai_api_key
SECRET_KEY=your_secret_key
FLASK_ENV=development
PORT=5000
```

---

## ๐Ÿ“š Documentation

- **README.md** - Complete project documentation
- **FEATURES.md** - Detailed feature descriptions
- **DEPLOYMENT.md** - Deployment instructions
- **CHANGELOG.md** - Version history

---

## ๐ŸŒ Deployment

### Heroku
```bash
git push heroku main
```

### Vercel
```bash
vercel deploy
```

### Docker
```bash
docker build -t code-assistant-bot .
docker run -p 5000:5000 code-assistant-bot
```

---

## ๐Ÿค Contributing

We welcome contributions! Please see our contributing guidelines.

---

## ๐Ÿ“ž Support

- **Website:** [https://rskworld.in](https://rskworld.in)
- **Email:** help@rskworld.in
- **Phone:** +91 93305 39277

---

## ๐Ÿ‘ฅ Credits

- **Author:** RSK World
- **Founder:** Molla Samser
- **Designer & Tester:** Rima Khatun
- **Year:** 2026

---

## ๐Ÿ“„ License

See LICENSE file for details.

---

## ๐Ÿ”— Links

- **GitHub Repository:** [https://github.com/rskworld/code-assistant-bot](https://github.com/rskworld/code-assistant-bot)
- **Website:** [https://rskworld.in](https://rskworld.in)
- **Documentation:** See README.md

---

**Thank you for using Code Assistant Bot! ๐Ÿš€**
utils/__init__.py
Raw Download
Find: Go to:
"""
Utils package for Code Assistant Bot
Author: RSK World (https://rskworld.in)
Founder: Molla Samser
Designer & Tester: Rima Khatun
Contact: help@rskworld.in, +91 93305 39277
Year: 2026
"""

from .code_analyzer import CodeAnalyzer
from .github_integration import GitHubIntegration
from .syntax_checker import SyntaxChecker
from .code_optimizer import CodeOptimizer
from .code_converter import CodeConverter
from .code_tester import CodeTester
from .code_formatter import CodeFormatter
from .code_documenter import CodeDocumenter
from .code_reviewer import CodeReviewer
from .code_comparator import CodeComparator

__all__ = [
    'CodeAnalyzer', 
    'GitHubIntegration', 
    'SyntaxChecker',
    'CodeOptimizer',
    'CodeConverter',
    'CodeTester',
    'CodeFormatter',
    'CodeDocumenter',
    'CodeReviewer',
    'CodeComparator'
]
33 linesโ€ข874 B
python
๐Ÿš€ Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work โค๏ธ

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer