A powerful AI-powered tool that explains code in plain English. Paste any code snippet and get instant, beginner-friendly explanations powered by Groq's Llama 3.3 70B model.
Try it now: https://ai-code-explainer-demo.netlify.app
// Paste this code:
function fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
console.log(fibonacci(10));AI Explanation:
What this code does: This code calculates the Fibonacci number at position
nusing recursion. The Fibonacci sequence starts with 0, 1, and each subsequent number is the sum of the two preceding ones (0, 1, 1, 2, 3, 5, 8...).Explanation:
- Base case: If
nis 0 or 1, returnndirectly- Recursive case: Add the result of
fibonacci(n-1)andfibonacci(n-2)console.log(fibonacci(10))prints the 10th Fibonacci number (55)
| Feature | Description |
|---|---|
| Multi-Language Support | JavaScript, Python, React/JSX, TypeScript, SQL, C#, PHP, CSS, and more |
| Auto Language Detection | Automatically detects programming language from code patterns |
| Manual Override | Override auto-detection when incorrect |
| Syntax Highlighting | Professional code editor with language-aware highlighting |
| Theme Support | Dark, Light, and System preference themes |
| Sample Code Library | Try with pre-built code samples (JavaScript, Python, React, SQL, C#) |
| One-Click Copy | Copy explanation to clipboard (strips markdown formatting) |
| Regenerate | Generate new explanations if not satisfied |
| Version History | Navigate between multiple explanation versions |
| Keyboard Shortcut | Press Ctrl+Enter to explain instantly |
| Code Validation | Prevents pasting explanation text instead of code |
| Responsive Design | Works on desktop, tablet, and mobile |
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β User Input β --> β React Frontend β --> β Groq API β
β (Code) β β (App.jsx) β β (Llama 3.3) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
v v
βββββββββββββββββββ βββββββββββββββββββ
β Language β β AI Explanation β
β Detection β β (Markdown) β
βββββββββββββββββββ βββββββββββββββββββ
- User pastes code β Code editor captures input with syntax highlighting
- Language detection β Pattern matching identifies language (React hooks, SQL keywords, etc.)
- API request β Code sent to Groq API with system prompt for explanation
- AI processing β Llama 3.3 70B generates structured explanation
- Render response β Markdown parsed and displayed with formatting
| File | Purpose |
|---|---|
App.jsx |
Main React component with state management, UI, and event handlers |
App.css |
Complete styling with CSS variables for theming |
codeExplainer.js |
Groq API integration and prompt engineering |
index.css |
Base styles, scrollbar, and focus states |
config.json |
API key configuration (not committed to git) |
git clone https://github.com/IX-OmkarP/ai-code-explainer.git
cd ai-code-explainer
npm install- Go to console.groq.com/keys
- Sign up/Login and create a new API key
- Copy the key (starts with
gsk_)
cp public/config.example.json public/config.jsonEdit public/config.json:
{
"apiKey": "gsk_your_api_key_here"
}npm run devcode-explainer/
βββ public/
β βββ config.json # API key (create from example)
β βββ config.example.json # Example config template
βββ src/
β βββ App.jsx # Main application component
β βββ App.css # Application styles with theming
β βββ index.css # Base styles and resets
β βββ main.jsx # React entry point
β βββ services/
β βββ codeExplainer.js # Groq API integration
βββ index.html # HTML template
βββ package.json # Dependencies and scripts
βββ vite.config.js # Vite configuration
βββ README.md # This file
| Technology | Purpose |
|---|---|
| React 19 | UI framework with hooks for state management |
| Vite | Fast build tool and dev server |
| Groq API | AI inference with Llama 3.3 70B model |
| @uiw/react-textarea-code-editor | Syntax-highlighted code editor |
| react-markdown | Render AI explanations with formatting |
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
);
}SELECT customers.name, orders.total
FROM customers
INNER JOIN orders ON customers.id = orders.customer_id
WHERE orders.total > 100
ORDER BY orders.total DESC;- AI Disclaimer: AI-generated explanations may contain errors. Always verify critical information.
- Code Only: This tool explains code only. It will not fix, modify, or improve your code.
- Language Detection: If auto-detection is wrong, manually type the correct language for better results.
- API Limits: Groq free tier has rate limits. Wait a moment if you hit limits.
MIT License - feel free to use this project for personal or commercial purposes.
Made with β€οΈ by Omkar Pawar