Skip to content

smebad/Code-Explainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ Code Explainer & Debugger

Python FastAPI Groq Railway License

Paste any code and let AI explain, debug, or improve it instantly. Built with FastAPI and powered by Groq's free Llama 3.3-70B model.

πŸ”— Live Demo


πŸ“Έ App Preview

A clean, dark-themed web interface where developers paste code and get instant AI-powered analysis.

πŸ–₯️ Main Interface

App UI


πŸ§ͺ Test Case Screenshots

🐍 Python β€” Code Improvement

Python Explain

🌐 JavaScript β€” Bugs Found

JavaScript Explain

πŸ—„οΈ SQL β€” Code Explanation

SQL Explain


✨ Features

  • πŸ” Code Explanation - Step-by-step breakdown of what your code does
  • πŸ› Bug Finder - Detects errors, edge cases, and potential issues with fixes
  • ✨ Code Improver - Suggests better patterns, performance improvements, and best practices
  • 🌐 Multi-Language Support - Works with Python, JavaScript, SQL, and more
  • ⚑ Lightning Fast - Powered by Groq's ultra-fast inference engine
  • πŸ†“ 100% Free - Uses Groq's free API tier
  • 🎨 Clean UI - GitHub-inspired dark theme, fully responsive

🎯 Demo

Sample Input

def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

print(fibonacci(10))

Output

✨ AI provides:

  • Step-by-step explanation of the recursive logic
  • Bug detection (inefficiency, no input validation)
  • Improved version using dynamic programming with O(n) complexity

πŸ”— Try it Live


πŸ› οΈ Tech Stack

Technology Purpose
Python 3.8+ Core programming language
FastAPI Backend web framework
Uvicorn ASGI server
Groq API AI model inference (Llama 3.3-70B)
HTML/CSS/JS Frontend interface
python-dotenv Environment variable management
Railway Cloud deployment

πŸš€ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/smebad/Code-Explainer.git
cd Code-Explainer

2️⃣ Create Virtual Environment

Windows:

python -m venv .venv
.venv\Scripts\activate

Mac/Linux:

python3 -m venv .venv
source .venv/bin/activate

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Set Up Environment Variables

Create a .env file in the root directory:

GROQ_API_KEY=your_actual_groq_api_key_here

5️⃣ Run the Application

uvicorn main:app --reload

πŸ“– Usage Guide

Step 1: Paste Your Code

Copy any code snippet into the text area β€” Python, JavaScript, SQL, or any language.

Step 2: Choose an Action

Button What it does
πŸ” Explain Code Breaks down the logic step by step
πŸ› Find Bugs Identifies errors and provides fixed code
✨ Improve Code Suggests optimizations and best practices

Step 3: Read the AI Analysis

Results appear instantly below with detailed, beginner-friendly explanations.


πŸ“ Project Structure

Code-Explainer/
β”‚
β”œβ”€β”€ main.py              ← FastAPI backend (API endpoints & Groq integration)
β”œβ”€β”€ requirements.txt     ← Python dependencies
β”œβ”€β”€ Procfile             ← Deployment configuration
β”œβ”€β”€ .env                 ← Secret API keys (never committed to Git)
β”œβ”€β”€ .gitignore           ← Git ignore rules
β”œβ”€β”€ assets/              ← Screenshots of test cases
└── static/
    └── index.html       ← Frontend UI (HTML, CSS, JavaScript)

πŸ”§ API Reference

POST /analyze

Analyzes code using AI.

Request Body:

{
  "code": "your code here",
  "action": "explain"
}

Actions:

  • explain β€” Step-by-step code explanation
  • debug β€” Bug detection and fixes
  • improve β€” Optimization suggestions

Response:

{
  "result": "AI-generated analysis here..."
}

🌐 Deployment

This app is deployed on Railway for free.


πŸ§ͺ Test Cases

The app has been tested with:

Test Language Result
Fibonacci recursion Python βœ…
Division by zero bug Python βœ…
Array map function JavaScript βœ…
SELECT query SQL βœ…
Empty input validation β€” βœ…

🀝 Contributing

Contributions are welcome! Here's how:

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

Ideas for Contributions

  • 🎨 Syntax highlighting for code input
  • πŸ“‹ Copy button for AI responses
  • 🌍 Support for more programming languages
  • πŸ“„ Export analysis as PDF
  • πŸ•“ Analysis history/session storage
  • πŸ” Rate limiting per user

πŸ› Known Issues & Limitations

  • Rate Limits: Groq free tier has usage limits per minute
  • Cold Starts: Railway free tier may have slow initial load after inactivity
  • Context Length: Very large code files may be truncated

πŸ“ Roadmap

  • 🎨 Syntax highlighting in the code editor
  • πŸ“‹ One-click copy for AI responses
  • πŸ•“ Session history to revisit past analyses
  • 🌍 Multi-language UI support
  • πŸ“„ Export analysis as PDF
  • πŸ” User authentication
  • πŸ“Š Usage analytics dashboard
  • πŸ€– Support for multiple AI models

πŸ“„ License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2026 Syed Muhammad Ebad

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

πŸ‘€ Author

Syed Muhammad Ebad


🌟 Show Your Support

If you found this project helpful:

  • ⭐ Star this repository
  • πŸ› Report bugs via Issues
  • πŸ’‘ Suggest features via Issues
  • πŸ“’ Share with others who might find it useful

πŸ“ž Support & Contact


πŸ”– Tags

code-explainer ai fastapi groq llama python debugging code-review developer-tools generative-ai web-app railway backend


Made with ❀️ by Syed Ebad

⬆ Back to Top

About

An AI-powered web app that instantly explains, debugs, and improves any code you paste. Built with FastAPI and Groq's Llama 3.3-70B, supports Python, JavaScript, SQL and more. Deployed live on Railway.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors