AI Error Explainer is a developer tool designed to eliminate debugging headaches. When developers encounter cryptic stack traces, compiler errors, build failures, database exceptions, or server logs, they can paste the raw error output into this application to instantly receive a structured, beginner-accessible, plain-English breakdown with actionable fixes.
When programming, developers frequently face error logs like:
TypeError: Cannot read properties of undefined (reading 'map')
at UserList (http://localhost:5173/src/components/UserList.tsx:14:22)
For beginners, this can be overwhelming. Experienced developers spend valuable time searching forums for root causes.
AI Error Explainer automates this by:
- Identifying What the error means in plain English.
- Explaining Why it happened (Root Cause analysis).
- Extracting Which exact line of code broke.
- Providing Copyable fixed code with defensive programming checks.
- Offering a Step-by-Step Debugging Checklist to verify the fix.
graph TD
User["π¨βπ» Developer pastes error log"] --> Client["React 18 + Vite + Tailwind CSS Frontend"]
Client -->|REST API / JSON| Backend["Node.js 22 + Express + TypeScript Backend"]
subgraph Backend ["Backend Processing Pipeline"]
CORS["CORS & Body Size Limit Middleware"] --> RateLimit["Rate Limiting Middleware"]
RateLimit --> Redaction["Secret Token & API Key Redactor"]
Redaction --> AIService["Pluggable AI Service Engine"]
AIService --> OpenAI["OpenAI Provider (gpt-4o-mini)"]
AIService --> Gemini["Google Gemini Provider (gemini-1.5-flash)"]
AIService --> Anthropic["Anthropic Claude Provider"]
AIService --> Mock["Mock Offline Provider (Keyless Dev)"]
AIService --> JSONParser["Zod JSON Parser & Fallback Recovery"]
JSONParser --> SQLite[("SQLite History Database (better-sqlite3)")]
end
SQLite --> Response["Structured JSON Report Returned to Frontend"]
Response --> UI["Visual Diagnosis Cards, Code Blocks & Checklist"]
- π Multi-Format Error Input: Accepts JavaScript/TypeScript errors, Python tracebacks, Rust compiler errors, Docker build logs, SQL database exceptions, and Linux server errors.
- βοΈ Environment Context Matching: Optional selection for Programming Language, Framework (React, Express, FastAPI, Django, Docker), OS, and Environment runtime.
- π‘οΈ Privacy & Automatic Secret Redaction: Automatically redacts JWTs, AWS credentials, OpenAI/Gemini API keys, connection string passwords, and private RSA keys before sending inputs to AI.
- π Pluggable AI Provider: Abstracted AI layer allowing effortless switching between OpenAI (
gpt-4o-mini), Google Gemini (gemini-1.5-flash), Anthropic Claude, or offline Mock Provider via environment variables (AI_PROVIDER). - β‘ Strict JSON Output & Zero-Crash Fallback: AI outputs are strictly parsed with Zod schemas. If model formatting varies, a fallback recovery parser formats the response without crashing the server.
- πΎ SQLite History & Persistence: Automatically saves analyses into an embedded SQLite database (
better-sqlite3) with search filtering, detail inspection modals, and deletion controls. - π¨ Developer UX & Dark Theme: Built with Inter and JetBrains Mono fonts, responsive layouts, smooth loading skeletons, copy buttons, and fault-tolerant React Error Boundaries.
- Node.js v22.x or higher installed.
- Git installed.
git clone https://github.com/vthish/Code-Error-Explainer.git
cd Code-Error-Explainercd backend
cp .env.example .env
npm install
npm run devThe Backend API server will start at:
http://localhost:3001Note: By default,AI_PROVIDER=mockis active, allowing full testing without needing an OpenAI or Gemini API key!
cd frontend
npm install
npm run devThe Frontend Web App will start at:
http://localhost:5173
Open http://localhost:5173 in your browser to start analyzing errors!
If you have Docker Desktop installed:
docker-compose up -d --build- Frontend Web App:
http://localhost - Backend Health Check:
http://localhost:3001/api/health
To stop the containers:
docker-compose downRun the complete test suite (Health checks, AI Provider logic, Secret Redaction, SQLite CRUD operations):
cd backend
npm testExpected Output:
β tests/ai.test.ts (7 tests)
β tests/health.test.ts (2 tests)
β tests/analysis.test.ts (5 tests)
Test Files 3 passed (3)
Tests 14 passed (14)
| Variable | Default Value | Description |
|---|---|---|
APP_ENV |
development |
Server mode (development | production | test) |
APP_HOST |
0.0.0.0 |
Host IP address binding |
APP_PORT |
3001 |
Backend HTTP port |
FRONTEND_ORIGIN |
http://localhost:5173 |
Allowed CORS origin |
DATABASE_PATH |
./data/error_explainer.db |
Path to embedded SQLite database file |
AI_PROVIDER |
mock |
Active provider (mock | openai | gemini | anthropic) |
OPENAI_API_KEY |
"" |
OpenAI API Key (Required if AI_PROVIDER=openai) |
OPENAI_MODEL |
gpt-4o-mini |
OpenAI Model |
GEMINI_API_KEY |
"" |
Google Gemini API Key (Required if AI_PROVIDER=gemini) |
GEMINI_MODEL |
gemini-1.5-flash |
Gemini Model |
ANTHROPIC_API_KEY |
"" |
Anthropic API Key (Required if AI_PROVIDER=anthropic) |
MAX_ERROR_INPUT_LENGTH |
10000 |
Maximum character length allowed for submitted error text |
RATE_LIMIT_REQUESTS |
30 |
Request limit per IP per minute |
Analyzes an error log and returns structured diagnosis JSON while saving the record.
{
"error_text": "TypeError: Cannot read properties of undefined (reading 'map')",
"language": "TypeScript",
"framework": "React",
"code_context": "const items = data.users.map(u => u.name);"
}{
"id": "anls_98a72f10-4c3e-4d89-9a21-1b2c3d4e5f6a",
"error_text": "TypeError: Cannot read properties of undefined (reading 'map')",
"language": "TypeScript",
"framework": "React",
"result": {
"error_type": "Runtime Error",
"severity": "medium",
"summary": "The application attempted to call .map() on an undefined object property.",
"explanation": "In React, when rendering asynchronous state, 'data' or 'data.users' may initially be undefined before API fetch completes.",
"likely_cause": "The property 'users' on 'data' was undefined when render was invoked.",
"important_lines": [
"TypeError: Cannot read properties of undefined (reading 'map')"
],
"possible_causes": [
"API request has not finished loading when rendering.",
"State was initialized to undefined or null."
],
"solutions": [
{
"title": "Use Optional Chaining & Fallback",
"description": "Safely access items with optional chaining and provide an empty array default."
}
],
"fixed_code": "const items = data?.users ?? [];\nreturn items.map(u => u.name);",
"debug_steps": [
"Log the API response prior to render.",
"Ensure loading state is handled before rendering."
],
"confidence": "high"
},
"created_at": "2026-10-04T00:35:00Z"
}This project is licensed under the MIT License - see the LICENSE file for details.