An API service that accepts a public GitHub repository URL, analyzes its contents in-memory, and returns a structured summary (description, technologies, structure) powered by an LLM via Nebius Token Factory.
- Python 3.10+
uvpackage managerlibmagic(binary file detection)
# Ubuntu / Debian
sudo apt-get install libmagic1
# macOS
brew install libmagic
# Arch
sudo pacman -S file# 1. Install dependencies
uv sync
# 2. Configure API key (get yours at https://tokenfactory.nebius.com)
export NEBIUS_API_KEY=your-key-here
# Optionally raise GitHub rate limits (anonymous: 60 req/hr, with token: 5,000 req/hr)
export GITHUB_TOKEN=your-token-here
# 3. Start the server (require NEBIUS_API_KEY)
make server-start
# 4. Test request
curl -X POST http://localhost:8000/summarize \
-H "Content-Type: application/json" \
-d '{"github_url": "https://github.com/psf/requests"}'
# 5. Quick smoke test: starts server (require NEBIUS_API_KEY) on random port, sends one request, validates response, shuts down
make smoke-test GITHUB_URL=https://github.com/torvalds/linux
# 6. Run all checks: lint + unit + e2e (require NEBIUS_API_KEY)
make test-allSuccess response:
{
"summary": "Requests is a popular Python HTTP library...",
"technologies": ["Python", "urllib3", "certifi", "chardet"],
"structure": "The project follows standard Python package layout..."
}Error response:
{
"status": "error",
"message": "repository not found or private"
}POST /summarize {github_url}
-> parse & validate GitHub URL
-> fetch repo metadata (GitHub API)
-> download zipball into memory (codeload CDN, fallback to API)
-> filter, prioritize, and select files within budget
-> send to LLM with directory tree + file contents
-> return structured JSON
Files are excluded before prioritization:
| Filter | What it removes |
|---|---|
| Ignored patterns | node_modules, vendor, __pycache__, .git, build, dist, target, .venv, .gradle, .next, bazel-out, lock files (*.lock, package-lock.json, yarn.lock), minified assets (*.min.js, *.min.css), generated code (*_pb2.py, *.generated.go), compiled files (*.pyc, *.class, *.o, *.wasm), OS metadata (.DS_Store) etc. (100+ patterns) |
| Binary detection | libmagic MIME sniffing on first 4 KB of each file — non-text MIME types are excluded |
| Per-file size cap | Files exceeding 100 KB uncompressed are excluded from content but still appear in the directory tree. The limit allows reading full linux Makefile (76KB) |
| Archive size cap | Zipball downloads exceeding 1 GiB are rejected during streaming |
Remaining files are classified into priority buckets and selected greedily within a character budget:
| Priority | Category | Examples |
|---|---|---|
| 0 | README | README.md, README.rst, CLAUDE.md, agents.md |
| 1 | Config | pyproject.toml, package.json, Dockerfile, Makefile, go.mod, Cargo.toml |
| 2 | CI | .github/workflows/*.yml, .gitlab-ci.yml, Jenkinsfile |
| 3 | Source code | .py, .js, .ts, .go, .rs, .java, .swift, .c, .cpp, and 60+ extensions |
| 4 | Test files | Source files inside tests/, test/, spec/, __tests__/, etc. |
| 5 | Fixtures | Files in fixtures/, testdata/, mocks/, __fixtures__/, etc. |
| 9 | Other | Remaining text files not matching any category above |
Only priorities 0–4 are selected for seed content. Fixture and other files appear in the directory tree but not in file contents.
Within each bucket, files are sorted by: entry-point boost (main.py, index.js, app.py, etc. first), then shallower directory depth first, then alphabetically. The budget fills greedily in priority order.
| Budget | Default | Purpose |
|---|---|---|
| Seed budget | 200,000 chars | Chars for directory tree + file contents in initial prompt |
| Tree budget | ~20% of seed budget | Directory tree rendering, abridged at deeper levels when over the budget |
| File seed budget | ~80% of seed budget | File contents, filled greedily by priority |
| Exploration budget | 50,000 chars | Additional chars for agentic tool results (unused in oneshot mode) |
The default model is openai/gpt-oss-120b on Nebius Token Factory with reasoning_effort=medium and temperature=0.1. It balances quality, speed, and cost: reliable structured JSON output, ~24s median latency, and zero errors across 48 benchmarked repositories. Heavier frontier reasoning models would likely improve quality, but at disproportionately higher latency and cost — diminishing returns for a synchronous API endpoint. Lighter models would struggle with reliable structured JSON output and nuanced technology identification across diverse repositories. The model was intially picked as a cost-performance sweet spot using a public benchmark, later experiments using own quality pipeline proved the choice was correct.
Selection informed by benchmarking across 48 repositories in 20 languages (full data in experiments/). OpenAI gpt-oss-120b outperforms DeepSeek-V3.2 across all fields (p < 0.0001):
| Field | OpenAI (medium) | DeepSeek (high) | Diff | p-value |
|---|---|---|---|---|
| summary | 7.51 | 6.23 | +1.28 | < 0.0001 |
| technologies | 6.77 | 5.38 | +1.38 | < 0.0001 |
| structure | 7.06 | 5.13 | +1.94 | < 0.0001 |
| holistic | 6.96 | 5.36 | +1.60 | < 0.0001 |
See bench eval design for details.
One attractive idea which didn't work in practice was to allow the model to explore the repository by itself using function calling on virtual file system (on top of in-memory zipball). Unfortunately, this level of autonomy proved challenging to the LLMs of choice, leading to worse quality (even compared to oneshot with less overall budget) and more frequent output failures.
app/
api.py FastAPI app, /summarize endpoint
settings.py Settings, AgentConfig, ModelConfig, Config
model.py Request/response schemas
errors.py Error hierarchy (Error -> 500, ValidationError -> 400)
summarizer/
pipeline.py Dispatcher: fetch repo data, call LLM summarizer
llm.py LLM client: unified loop (oneshot or agentic)
prompt.py System/user message construction
llmtools.py Tool definitions (list_files, read_file, search_text, finish)
zipfs.py In-memory zip-backed VFS
filetree_rules.py File classification policy tables (priority buckets, ignore patterns)
filetree.py Directory tree building, budget allocation, rendering
ziptools.py Zip extraction utilities
github.py URL parsing, metadata fetch, zipball download
text.py String utilities
tests/
unit/ Mocked tests (no network)
e2e/ Integration tests (real APIs)
bench/ Benchmarking pipeline (models.py, paths.py, claude_cli.py, concurrency.py, stats.py, + step modules)
scripts/
bench/ Benchmarking pipeline scripts (download.py, golden.py, run.py, judge.py, pairwise_judge.py, judge_diff.py)
run_experiment.sh Orchestrate multi-config experiments
smoke_test.py Smoke test: start server, one request, validate, shut down
poc_zipball_memory.py Proof-of-concept: measuring RAM overhead of in-memory zipball processing
sample-data/
repos/ Cached repo metadata (zipballs and extracted directories need to be downloaded)
sets/ Benchmark subset definitions (XS, S, M, EVIL)
golden/ Golden reference summaries
results/ Benchmark run outputs
scores/ Judge scores per run
pairwise/ Pairwise comparison results
docs/
plans/ Design and implementation plans
bench-eval-design.md Detailed experiment methodology
experiments/ Experiment configs and conclusions
main.py Uvicorn entrypoint
Makefile All project commands
pyproject.toml Dependencies and project config