Notes ·
CodeAtlas: a hotspot ranking from the import graph and git history, and a validator for the LLM on top
If you want to know where in a TypeScript codebase to look first, "complex" and "changes often" are two separate answers that you usually read in two separate tools. This post is about CodeAtlas, which fuses them into one deterministic ranking and then lets an LLM write a short narrative that is rejected, finding by finding, if its numbers do not match the computed model. I built it as one person directing AI coding agents, held to tests and review by a separate AI agent.
The problem
Dependency graphs tell you what is coupled. Git history tells you what moves. A file that is complex and also touched in most commits is a better place to start a review than either list alone. The README is clear that this is not a novel idea; ArchMind, CodeMap and others do parts of it. What I wanted was the two signals in one score, with no model involved in computing it.
What it does
The engine (packages/engine) builds the import graph with dependency-cruiser, computes fan-in, fan-out, instability, cycles (Tarjan) and blast radius, reads cyclomatic complexity with ts-morph and churn from git log, and fuses them:
hotspot_score = percentile-rank(complexity) x percentile-rank(churn)
percentile-rank(x) = |{ v in population : v < x }| / (n - 1) The design decision worth explaining is percentile rank instead of min-max scaling. With churn values [1, 2, 3, 4, 5, 200], min-max puts the five ordinary files between 0.000 and 0.020, so one outlier flattens the whole ranking. Percentile rank gives them 0.0 to 0.8. ADR 0004 also rules out z-scores: they are signed, and in a product two below-average values would multiply into a positive score. The trade-off, written in the ADR, is that rank can exaggerate small differences when a population has low variance. Because the score is a rank product, it says where a file sits relative to the others, not how bad it is in absolute terms.
One LLM call then reads only the structured JSON, never source code. A validator checks each finding three ways: schema, whether the cited module_id exists, and whether the cited value is within 0.01 of the computed one. A finding that fails is dropped, logged and shown struck through. It checks cited modules and numbers, not the wording of the prose.
How it is tested
On a fresh clone, 108 tests pass. The engine runs without an API key:
npm ci
npm test --workspaces --if-present
npm run analyze --workspace=@codeatlas/engine -- . --summary report.md --out analysis.json CodeAtlas runs on its own repository in CI as a quality gate, with a maximum hotspot score of 0.95. Measured on 2026-11-30 with full history, the maximum is 0.9198, and the top hotspot is the web API route. The gate is deliberately loose: a comment in the workflow notes that legitimately complex test files already score about 0.87, so it catches an extreme regression and not ordinary work. Checking out with fetch-depth: 0 matters, because a shallow clone reads as zero churn.
Some of the more useful tests came from bugs found while building. dependency-cruiser counted one file twice behind macOS's /var to /private/var symlink; Next.js prerendered the live dashboard as static HTML until the page was marked dynamic. The README describes both with their fixes.
What the security audit found
Before opening the repository, an audit found four problems, all fixed:
- Credentials in the remote URL. A git remote such as
https://user:token@host/repowould have been copied into the report, the LLM prompt and an unauthenticated API response. The engine now clears the username and password before the URL is stored (analyze-repository.ts,readRepoUrl, with tests for https, scp-style and missing remotes). - The read endpoint was not behind the access token. Only
POST /api/analyzecheckedCODEATLAS_ANALYZE_TOKEN;GETnow checks it too. - A failed LLM run did not start the cooldown. The call may already have been paid for, so the limit on paid runs had a hole. The cooldown now begins when a run starts.
- Docker Compose listened on all interfaces. The port is now bound to
127.0.0.1.
The first of these is the one I would have missed on my own: the URL looked like harmless metadata.
Limits and what is not done
- TypeScript and JavaScript only. No auth, billing or multi-tenancy; it is a single-user tool.
- The Docker Compose files and Dockerfile were reviewed but not run end to end. I ran the dashboard with
npm run devinstead. - The LLM narrative needs an
ANTHROPIC_API_KEY; the engine, tests and CI gate do not. - The dashboard pages are server-rendered and public. For a private repository, put the app behind authentication or a private network, and do not push the Docker image to a public registry, since it contains the
.gitdirectory. - The validator proves a citation is grounded, not that the prose is wise. Whether hotspot rank predicts where bugs live is not measured here.
Code: https://github.com/basartuncay/CodeAtlas
Türkçe özet
CodeAtlas, TypeScript ve JavaScript depolarında bağımlılık grafiği, bağlaşım ve kararsızlık metriklerini Git değişim sıklığıyla tek bir deterministik "sıcak nokta" sıralamasında birleştiren bir araç. Birleştirmede min-max yerine yüzdelik sıra kullanıldı, çünkü tek bir aşırı değer diğer tüm dosyaların puanını sıfıra yaklaştırıyor. Bir LLM yalnızca yapılandırılmış JSON'u okuyup kısa bir anlatı yazıyor; doğrulayıcı, alıntılanan modül ve sayı hesaplanan modelle uyuşmayan bulguları reddediyor. Temiz klonda 108 test geçiyor; araç kendi deposunda tam geçmişle 0,9198 en yüksek puan veriyor (eşik 0,95). Yayın öncesi denetimde uzak depo URL'sindeki kimlik bilgilerinin rapora ve LLM istemine sızacağı, okuma uç noktasının erişim belirteci dışında kaldığı, başarısız bir LLM çalıştırmasının bekleme süresini başlatmadığı ve Docker Compose'un tüm arayüzleri dinlediği bulundu ve düzeltildi. Docker dosyaları uçtan uca çalıştırılmadı.