/Code-Fix

An AI-powered agent that automatically detects, explains, and fixes issues in AI-generated or human-written code — from syntax errors to security flaws — with safe, test-backed patches.

Primary LanguageJavaScript

Code Fix

Intelligent code analysis and automated fixing tool with AI enhancement

A professional, full-stack code analysis application that detects and fixes issues in your code across multiple programming languages. Features real-time analysis, LLM enhancement, Supabase backend integration, and Docker deployment.

Code Fix Version License

✨ Features

🔍 Real-time Code Analysis

  • Live Detection Engine: Analyzes your actual code input, not pre-trained responses
  • Multi-language Support: JavaScript, TypeScript, Python, Java, SQL
  • 26+ Detection Rules: Comprehensive issue identification across all categories
  • Instant Results: Get analysis results in under 2 seconds

🛠️ Automated Code Fixing

  • Smart Fixes: Automatically applies improvements to detected issues
  • Before/After Comparison: See exactly what was changed and why
  • One-click Copy: Copy fixed code to clipboard instantly
  • Detailed Explanations: Understand each fix with clear descriptions

📊 Professional Dashboard

  • Severity Classification: Critical, High, Medium, Low issue prioritization
  • Category Grouping: Security, Performance, Quality, Syntax organization
  • Visual Statistics: Color-coded metrics and progress indicators
  • Interactive UI: Hover effects, smooth animations, professional design

🎯 Issue Detection Categories

Security Vulnerabilities

  • SQL Injection detection in database queries
  • XSS (Cross-Site Scripting) vulnerability identification
  • Hard-coded secrets and API keys detection
  • Unprotected API endpoints and authentication issues

Performance Issues

  • Inefficient algorithm complexity (O(n²) vs O(n log n))
  • Memory leaks and resource management problems
  • Unnecessary computations and blocking operations
  • Database query optimization opportunities

Code Quality Problems

  • Missing error handling and try-catch blocks
  • Poor naming conventions and code structure
  • Missing documentation and comments
  • Debug code left in production (console.log, print statements)

Syntax Errors

  • Missing semicolons, colons, and brackets
  • Indentation and formatting inconsistencies
  • Deprecated syntax usage (var vs let/const)
  • Type-related issues and loose equality comparisons

Logical Bugs

  • Off-by-one errors in loops and arrays
  • Missing WHERE clauses in SQL operations
  • Null pointer and undefined reference issues
  • Incorrect conditional logic and flow control

🚀 Quick Start

⚡ Super Quick Start (Recommended)

# One command to install and start everything!
npm run quick-start

This automatically installs dependencies and starts the development server at http://localhost:3002

📋 Manual Setup Options

Option 1: Development Mode (Hot Reload)

# Install dependencies
npm install

# Start development server with auto-reload
npm run dev

# Access at http://localhost:3002

Option 2: Production Mode

# Install dependencies
npm install

# Start production server
npm start

# Access at http://localhost:3002

Option 3: Docker (Container Deployment)

# Start with Docker Compose
docker-compose up --build

# Access at http://localhost:3002

Option 2: Node.js

# Clone and install
git clone <repository-url>
cd code-fix
npm install

# Configure environment
cp .env.example .env
# Edit .env with your configuration

# Start server
npm start

# Access at http://localhost:3000

Option 3: Quick Start Scripts

# Linux/Mac
./start.sh

# Windows
start.bat

Configuration Required

Edit .env file with your API keys:

  • Supabase: Database integration
  • OpenAI/LLM API: Enhanced AI analysis
  • Other settings: Rate limiting, security

💻 Usage Guide

Step-by-Step Workflow

  1. Input Your Code

    • Paste or type code in the input textarea
    • The placeholder "write code you want to fix" will guide you
    • Code area auto-resizes as you type
  2. Select Language

    • Choose from: Python, JavaScript, TypeScript, Java, SQL
    • Language-specific analysis rules will be applied
    • Different detection patterns for each language
  3. Run Analysis

    • Click the "⚡ Analyze & Fix Code" button
    • Real-time processing takes 1-2 seconds
    • Loading animation shows progress
  4. Review Results

    • Analysis Summary: See total issues by severity level
    • Issues Detected: Detailed list with descriptions and line numbers
    • Fixed Code: Improved version with applied fixes
    • Fixes Applied: List of all improvements made
  5. Copy Fixed Code

    • Use "Copy Fixed Code" button for instant clipboard copy
    • Visual feedback confirms successful copy operation
    • Paste improved code into your project

Keyboard Shortcuts

  • Ctrl/Cmd + Enter: Analyze code
  • Ctrl/Cmd + C: Copy fixed code (when results visible)

🏗️ Project Structure


code-fix/
├── 📄 index.html                    # Clean HTML with empty input
├── 🎨 styles.css                    # Neon purple design with animations
├── ⚡ script.js                     # Advanced analysis engine (26+ rules)
├── 🚀 server.js                     # Express server with dev messages
├── 📦 package.json                  # Updated with dev scripts
├── 🔧 start.js                      # Quick start automation
├── 🐳 Dockerfile                    # Production container
├── 🐳 docker-compose.yml            # Orchestration
├── ⚙️ .env                          # Environment config
├── ⚙️ .env.example                  # Environment template
├── 🔧 healthcheck.js                # Health monitoring
├── 📚 README.md                     # Comprehensive docs
├── 📊 PROJECT_COMPLETION_REPORT.md  # Detailed analysis
├── 📋 QUICK_START.md                # Quick start guide
├── 📊 PROJECT_STATUS.md             # Current status
├── 🚀 deploy.sh                     # Unix deployment
├── 🚀 deploy.bat                    # Windows deployment
└── 📁 node_modules/                 # Dependencies


Full-Stack Architecture

  • Frontend: HTML5, CSS3, Vanilla JavaScript with neon purple design
  • Backend: Node.js + Express.js with comprehensive API
  • Database: Supabase (PostgreSQL) for analysis history and statistics
  • AI Enhancement: OpenAI/LLM integration for advanced analysis
  • Deployment: Docker + Docker Compose + Nginx ready

🔧 Backend Features

API Endpoints

  • POST /api/analyze - Analyze code with LLM enhancement
  • GET /api/history/:userId - Get analysis history
  • GET /api/analysis/:analysisId - Get specific analysis
  • GET /api/stats/:userId - User statistics and metrics
  • GET /health - Health check endpoint

Database Integration (Supabase)

  • Analysis Storage: Save all code analyses with metadata
  • User Statistics: Track usage patterns and improvements
  • History Tracking: Access previous analyses and results
  • Performance Metrics: Monitor analysis trends over time

LLM Enhancement

  • OpenAI Integration: GPT-3.5/4 for advanced code analysis
  • Alternative APIs: Support for custom LLM endpoints
  • Intelligent Insights: Architectural improvements and best practices
  • Fallback System: Local analysis if LLM unavailable

Security & Performance

  • Rate Limiting: Prevent API abuse with configurable limits
  • Input Validation: Secure handling of code input and parameters
  • Error Handling: Comprehensive error management and logging
  • Health Monitoring: Built-in health checks and monitoring

🔧 Technical Details

Analysis Engine

The core CodeAnalyzer class provides intelligent code analysis:

class CodeAnalyzer {
    analyzeCode(code, language) {
        // Real-time pattern matching
        // Language-specific rule application
        // Issue severity classification
        // Automated fix generation
    }
}

Detection Algorithms

JavaScript/TypeScript Analysis

  • Missing semicolon detection with regex patterns
  • Console.log statement identification for production cleanup
  • Loose equality (==) vs strict equality (===) checking
  • Variable declaration analysis (var vs let/const)
  • Error handling validation around risky operations

Python Analysis

  • Missing colon detection in function/class definitions
  • Print statement identification for logging recommendations
  • Bare except clause detection for better error handling
  • Docstring presence validation for documentation
  • String formatting analysis for SQL injection prevention

SQL Analysis

  • SELECT * query detection for performance optimization
  • Missing WHERE clause identification in UPDATE/DELETE
  • Dynamic SQL construction analysis for injection prevention
  • Query efficiency pattern recognition

Generic Analysis

  • TODO/FIXME comment detection for incomplete code
  • Line length analysis for readability standards
  • Code complexity measurement and optimization suggestions

Fix Generation System

Automated fixes are applied based on detected issues:

generateFixes() {
    // Pattern-based code transformation
    // Security vulnerability patching
    // Performance optimization application
    // Documentation generation
}

🎨 Design Philosophy

Professional UI/UX

  • Clean Interface: Minimal, distraction-free design
  • Intuitive Workflow: Logical step-by-step process
  • Visual Feedback: Clear indicators for all user actions
  • Responsive Design: Works perfectly on desktop and mobile

Color-Coded System

  • 🔴 Critical Issues: Red - Security vulnerabilities, syntax errors
  • 🟠 High Issues: Orange - Logic bugs, missing error handling
  • 🟡 Medium Issues: Yellow - Code quality, documentation gaps
  • 🔵 Low Issues: Blue - Style improvements, minor optimizations

Typography & Spacing

  • Modern Fonts: SF Mono, Monaco for code; System fonts for UI
  • Proper Hierarchy: Clear heading structure and text sizing
  • Comfortable Spacing: Adequate padding and margins for readability
  • Professional Shadows: Subtle depth without overwhelming design

🌟 Advanced Features

Real-time Intelligence

  • Dynamic Analysis: Results change based on your actual code input
  • Context Awareness: Understands language-specific patterns and idioms
  • Confidence Scoring: AI confidence levels for each detected issue
  • Progressive Enhancement: More sophisticated analysis as code complexity increases

Language-Specific Intelligence

  • JavaScript: ES6+ syntax awareness, async/await patterns, modern best practices
  • Python: PEP 8 compliance, Pythonic idioms, exception handling patterns
  • SQL: Database-specific optimizations, security best practices, performance tuning
  • Java: Object-oriented patterns, exception handling, coding conventions

Performance Optimization

  • Efficient Parsing: Fast regex-based pattern matching
  • Minimal Memory Usage: Lightweight analysis algorithms
  • Instant Results: Sub-2-second analysis for most code samples
  • Scalable Architecture: Handles code files of various sizes

🔒 Security & Privacy

Client-Side Processing

  • No Data Transmission: All analysis happens in your browser
  • Complete Privacy: Your code never leaves your device
  • Offline Capable: Works without internet connection
  • No Tracking: Zero analytics or user data collection

Security Best Practices

  • Input Sanitization: Safe handling of all user input
  • XSS Prevention: Proper output encoding and validation
  • CSP Ready: Content Security Policy compatible
  • HTTPS Compatible: Secure deployment ready

📱 Browser Compatibility

Supported Browsers

  • Chrome 60+ (Recommended)
  • Firefox 55+
  • Safari 12+
  • Edge 79+
  • Opera 47+

Mobile Support

  • iOS Safari: Full functionality on iPhone/iPad
  • Android Chrome: Complete feature support
  • Responsive Design: Adapts to all screen sizes
  • Touch Optimized: Proper button sizes and interactions

🎯 Use Cases

For Developers

  • Code Review: Quick quality assessment before commits
  • Learning Tool: Understand best practices and common mistakes
  • Debugging Aid: Identify potential issues early in development
  • Refactoring Helper: Improve existing code quality systematically

For Teams

  • Code Standards: Enforce consistent coding practices
  • Security Audits: Identify vulnerabilities before deployment
  • Performance Optimization: Find and fix performance bottlenecks
  • Documentation: Ensure proper code documentation standards

For Education

  • Teaching Tool: Demonstrate good vs bad coding practices
  • Student Assessment: Evaluate code quality in assignments
  • Best Practices: Learn industry-standard coding conventions
  • Language Learning: Understand language-specific patterns

🚀 Deployment Options

Static Hosting

# Vercel
vercel --prod

# Netlify
netlify deploy --prod --dir=.

# GitHub Pages
# Push to gh-pages branch

# AWS S3
aws s3 sync . s3://your-bucket --delete

Local Development

# Python
python -m http.server 8000

# Node.js
npx serve .

# PHP
php -S localhost:8000

Docker Deployment

FROM nginx:alpine
COPY . /usr/share/nginx/html
EXPOSE 80

🤝 Contributing

Development Guidelines

  • Follow existing code style and patterns
  • Test across multiple browsers before submitting
  • Ensure accessibility compliance (WCAG 2.1 AA)
  • Maintain responsive design principles
  • Document any new features or changes

Adding New Language Support

  1. Add language option to HTML select element
  2. Implement language-specific analysis in CodeAnalyzer
  3. Add appropriate fix generation patterns
  4. Test with various code samples
  5. Update documentation

Reporting Issues

  • Provide specific code samples that cause problems
  • Include browser version and operating system
  • Describe expected vs actual behavior
  • Check existing issues before creating new ones

📄 License

MIT License - Feel free to use, modify, and distribute as needed.

🙏 Acknowledgments

  • Font Awesome for professional icons
  • Modern CSS techniques for responsive design
  • Vanilla JavaScript for maximum compatibility
  • Open Source Community for inspiration and best practices

Code Fix - Making your code better, one analysis at a time. 🚀

Built with ❤️ using pure web technologies for maximum compatibility and performance.

🔧

Troubleshooting

NPM Commands Not Working?

If you get "npm is not recognized", Node.js is not installed:

  1. Install Node.js: Download from nodejs.org
  2. Run Setup Script: setup-windows.bat (Windows) or setup-linux.sh (Linux/Mac)
  3. Verify Installation: node --version and npm --version

Quick Start Without Node.js

For immediate testing, open standalone.html in your browser for basic functionality.

Your Supabase Database

Your database is already configured! Just add your anon key:

SUPABASE_URL=https://rprxqhxtlbdkqzxgbdvg.supabase.co
SUPABASE_ANON_KEY=your_anon_key_here
DATABASE_URL=postgresql://postgres:Pak469702@db.rprxqhxtlbdkqzxgbdvg.supabase.co:5432/postgres

Get your anon key: Supabase Dashboard → Settings → API → Copy anon/public key

Database Setup

  1. Go to your Supabase SQL Editor
  2. Copy and paste contents of supabase-schema.sql
  3. Click "Run" to create tables

Common Issues

  • Port in use: Change PORT=3001 in .env
  • Dependencies fail: Run npm cache clean --force then npm install
  • Connection issues: Check your Supabase anon key and network

For detailed troubleshooting, see TROUBLESHOOTING.md


🎯 Summary

Code Fix is now a complete, production-ready application with:

  • 🎨 Neon purple UI with professional animations
  • 🧠 AI-enhanced analysis with LLM integration
  • 💾 Supabase backend (your database is ready!)
  • 🐳 Docker deployment with full orchestration
  • 🔒 Enterprise security with rate limiting
  • 📱 Mobile-responsive design

Your Supabase database is already connected - just add your anon key and you're ready to go! 🚀