A small web app that analyzes Python and Java source code and produces human-friendly, line-level explanations at three knowledge levels (ELI5, Beginner, Developer).
Live demo: https://explain-my-code-w3sj.onrender.com (hosted on Render's free tier — first load may take 30–60s while the instance wakes up)
- Multi-level explanations: ELI5, Beginner, Developer
- Interactive highlighting: hover keywords to see explanations
- Rule-based parsing: lightweight keyword templates (no AI required)
- Supports Python and Java (easy to extend)
- Backend: Python (Flask)
- Frontend: HTML, CSS, JavaScript
- Scan each line for known language keywords/patterns
- Match detected patterns to template explanations
- Render highlighted lines with tooltip text for quick reading
Recommended: use Python 3.10+ (the project uses 3.13 in runtime.txt but 3.10+ works fine).
Install and run:
git clone https://github.com/ethanzhoucool/explain-my-code.git
cd explain-my-code
python3 -m venv .venv # optional, recommended
source .venv/bin/activate # macOS / Linux
pip install -r requirements.txt
python3 app.pyOpen your browser at: http://127.0.0.1:5000
explain-my-code/
├── app.py # Flask application (entrypoint)
├── Procfile # Gunicorn start command for Render
├── requirements.txt # Python dependencies
├── runtime.txt # Python runtime used on Render
├── templates/ # Jinja2 HTML templates
├── static/ # CSS and JS
└── explainer/ # language-specific rules and templates
├── python_rules.py
└── java_rules.py
Add keywords and text templates in explainer/python_rules.py and explainer/java_rules.py. Each feature has multi-level template text (ELI5 / beginner / developer) and an optional color.
- The parser is intentionally simple and rule-based — it works well for quick explanations but won't fully parse complex syntax.
- Future ideas: add more languages, improve parsing with tokenizers (or optional LSP/AST use), and add unit tests.
MIT