Upload any code file β AI automatically splits it into logical blocks β Displays as an interactive Notebook with explanations and difficulty ratings
Features Β· Quick Start Β· Switching AI Providers Β· Project Structure Β· Roadmap
- Structured LLM output via Pydantic models β cells are always well-formed, never free-form text
- Smart code chunking β boundary-aware splitting for files over 8,000 characters; each chunk analyzed independently and merged seamlessly
- Per-block difficulty rating β LLM scores each cell 1 (easy) / 2 (medium) / 3 (complex), visualized as colored dots
- Whole-file summary β 3β5 sentence architectural overview generated after cell analysis
- Automatic comment stripping β pre-processing removes comments before sending to LLM, reducing token usage and improving signal quality
- Multi-block error recovery β a failed chunk inserts an error placeholder instead of aborting the entire analysis
- Retry logic β exponential backoff (up to 2 retries) on LLM failures
- Single-cell follow-up Q&A β select any cell and ask the AI a targeted question about it
- Tokyo Night dark theme β unified color palette across all components (header, code, explanation, summary)
- Carbon-style cell headers β macOS traffic-light dots, colored left border per cell type, type badge
- Syntax highlighting β
highlight.jsatom-one-dark theme with line numbers viahighlightjs-line-numbers.js - Collapsible cells β click β on any cell header to collapse/expand; button label updates accordingly
- One-click code copy β β button per cell, with clipboard fallback for older browsers, flashes β on success
- Sticky search bar β real-time client-side search across title, type, explanation and code preview; shows match count and a β clear button
- Skeleton loading screen β shimmer placeholder cards shown while the LLM processes, eliminates blank-page waiting
- Streaming summary output β summary text streams token-by-token into the UI with a blinking cursor
- iframe height auto-adapt β
ResizeObserver+postMessagereports real content height to Streamlit, eliminating scrollbars and empty space
Supports 60+ languages across 10 categories:
| Category | Extensions |
|---|---|
| Web | .html .css .scss .js .ts .vue |
| Systems | .c .cpp .cs .rs .go .zig |
| JVM | .java .kt .scala .groovy |
| Scripting | .py .rb .php .lua .jl .pl |
| Shell | .sh .bash .zsh .ps1 .bat |
| Mobile | .swift .dart .m |
| Data / Query | .sql .graphql .proto |
| Config | .yaml .toml .xml .tf .ini |
| Functional | .hs .ex .erl .clj .ml .fs |
| Other | .r .vb .asm .nim .md |
- Persistent JSON history β every analysis saved with filename, language, line count, char count, cell count, elapsed time, timestamp, summary and full cell data
- History sidebar β browse last 20 analyses; load or delete individually, or clear all at once
- Return-to-home button β one click to reset state without page refresh
- Markdown export β download the entire notebook as a structured
.mdfile with fenced code blocks, emoji headers and difficulty stars
Switch between models from the sidebar without restarting:
- DeepSeek Chat β general-purpose, best for mixed-language files
- DeepSeek Coder β code-specialized model, higher accuracy on logic-heavy files
- Python 3.10+
- A DeepSeek API key (platform.deepseek.com)
git clone https://github.com/yourname/code-notebook.git
cd code-notebook
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtCreate a .env file in the project root:
DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxstreamlit run app.pyOpen http://localhost:8501 in your browser.
streamlit>=1.32.0
langchain-deepseek>=0.1.0
langchain-core>=0.2.0
langgraph>=0.1.0
pydantic>=2.0.0
python-dotenv>=1.0.0The LLM layer is fully abstracted through LangChain. Swapping providers requires only two changes.
pip install langchain-openai# app.py β replace init_llm()
from langchain_openai import ChatOpenAI
@st.cache_resource
def init_llm(model_name: str):
return ChatOpenAI(model=model_name, temperature=0.2)
MODEL_OPTIONS = {
"GPT-4o": "gpt-4o",
"GPT-4o Mini": "gpt-4o-mini",
}OPENAI_API_KEY=sk-...pip install langchain-anthropicfrom langchain_anthropic import ChatAnthropic
@st.cache_resource
def init_llm(model_name: str):
return ChatAnthropic(model=model_name, temperature=0.2)
MODEL_OPTIONS = {
"Claude 3.5 Sonnet": "claude-3-5-sonnet-20241022",
"Claude 3 Haiku": "claude-3-haiku-20240307",
}ANTHROPIC_API_KEY=sk-ant-...pip install langchain-google-genaifrom langchain_google_genai import ChatGoogleGenerativeAI
@st.cache_resource
def init_llm(model_name: str):
return ChatGoogleGenerativeAI(model=model_name, temperature=0.2)
MODEL_OPTIONS = {
"Gemini 1.5 Pro": "gemini-1.5-pro",
"Gemini 1.5 Flash": "gemini-1.5-flash",
}GOOGLE_API_KEY=AIza...pip install langchain-ollama
ollama pull codellamafrom langchain_ollama import ChatOllama
@st.cache_resource
def init_llm(model_name: str):
return ChatOllama(model=model_name, temperature=0.2)
MODEL_OPTIONS = {
"CodeLlama 13B": "codellama:13b",
"Llama 3.1 8B": "llama3.1:8b",
}Note: Local models may not reliably support
with_structured_output(). If structured output fails, add a JSON extraction fallback inanalyzer().
code-notebook/
βββ app.py # Main Streamlit application
β βββ LangGraph pipeline (file_loader β preprocessor β analyzer β summarizer)
β βββ render_notebook() β iframe-based Notebook renderer
β βββ followup_llm() β single-cell Q&A
β βββ export_markdown() β Markdown export builder
β βββ Streamlit UI layout
β
βββ lang_config.py # Language definitions and cell style palette
β βββ LANG_MAP β extension β (display name, comment style, hljs name)
β βββ COMMENT_STRIP_TYPE β extension β strip strategy
β βββ _EXT_TO_STRIP β flattened lookup dict
β βββ CELL_STYLES β Tokyo Night color tokens per cell type
β
βββ styles.css # All visual styles (Tokyo Night design system)
β βββ CSS custom properties (:root)
β βββ Animation keyframes
β βββ Badge, stream box, skeleton components
β βββ Notebook cell (header, code, explanation)
β βββ Search bar, collapse, toolbar buttons
β βββ Streamlit sidebar overrides
β
βββ code_history/ # Auto-created; stores analysis JSON files
β βββ YYYYMMDD_HHMMSS_filename.json
β
βββ .env # API keys (not committed)
βββ requirements.txt
βββ README.md
Upload File
β
βΌ
βββββββββββββββ ββββββββββββββββ βββββββββββββββββββ ββββββββββββββ
β file_loader ββββββΆβ preprocessor ββββββΆβ analyzer ββββββΆβ summarizer β
β β β β β β β β
β Detect lang β β Strip β β Smart chunk β β 3-5 sent. β
β Decode file β β comments β β LLM structured β β overview β
β Count lines β β Extract β β output per chunkβ β β
β β β keywords β β Merge paired β β β
βββββββββββββββ ββββββββββββββββ β tags β ββββββββββββββ
βββββββββββββββββββ
β
βΌ
render_notebook()
βββββββββββββββββββ
β Build full HTML β
β Inject via JS β
β hljs highlight β
β Line numbers β
β Search / Fold / β
β Copy / Resize β
βββββββββββββββββββ
- Collapse all β single button to fold/unfold all cells at once
- Filter by type β pill buttons to show only
function,class, etc. - Filter by difficulty β show only complex (βββ) cells for quick review
- Jump-to-cell index β floating mini-map / table of contents on the right
- History search β search across all saved history files by filename or language
- Multi-file ZIP upload β analyze entire projects, generate per-file notebooks
- Call graph visualization β
mermaid.jsdiagram of function/class relationships - Test suggestion β auto-generate pytest / Jest stubs for
functioncells - GitHub URL input β paste a raw GitHub URL and analyze directly without downloading
- PDF export β print-ready PDF via
weasyprintor browser print API - Persistent user sessions β SQLite backend to persist history across restarts
- VS Code extension β right-click any selection β "Explain with Code Notebook"
- Git diff mode β upload two versions of a file, explain only what changed
- Collaborative annotation β shared read-only URL where multiple users can add comments
- Learning path generator β given a multi-file project, recommend reading order by dependency depth
- Incremental re-analysis β re-analyze only modified cells when a file is re-uploaded
The UI is built on the Tokyo Night color palette, consistent across all components:
| Token | Value | Used for |
|---|---|---|
--bg-base |
#1a1b26 |
Page background, explanation area |
--bg-surface |
#1e2030 |
Cards, summary box, stream box |
--code-bg |
#1e1e2e |
Code block background |
--accent-blue |
#7aa2f7 |
import cells, info cards, search focus |
--accent-green |
#9ece6a |
function cells, done badges |
--accent-purple |
#bb9af7 |
class cells |
--accent-orange |
#ff9e64 |
constant cells |
--accent-yellow |
#e0af68 |
Summary box border, export stars |
--accent-pink |
#f7768e |
decorator cells |
--accent-teal |
#2ac3de |
config cells |
- Fork the repository
- Create a feature branch:
git checkout -b feat/my-feature - Commit your changes:
git commit -m 'feat: add my feature' - Push to the branch:
git push origin feat/my-feature - Open a Pull Request
Please keep PRs focused β one feature or fix per PR. CSS changes should preserve the Tokyo Night design tokens defined in :root.
MIT Β© 2026 β see LICENSE for details.