SuperAPI AI Directory

repo-cartographer

Turn a repo into Mermaid or Graphviz architecture diagrams from its file tree, import graph and entry points; also enforces architecture rules in CI.

Open website

About this tool

repo-cartographer is a tool that converts any code repository into an architecture diagram, positioned as "understand any codebase in 60 seconds." It is available in three forms: an MCP server, a command-line tool, and a GitHub Action. It outputs architecture diagrams in Mermaid or Graphviz format and can enforce architecture rules in CI.

Purpose

It provides an LLM with the ability to point at a folder and return an architecture map: languages, frameworks, entry points, modules, and the import graph, rendered as a Mermaid diagram that can be pasted into a PR, documentation, or a getting-started guide. It is model-agnostic and speaks the Model Context Protocol over stdio, making it suitable for Claude Code, Claude Desktop, Cursor, Cline, Copilot, or the OpenAI Agents SDK, without relying on Claude-specific features.

Main capabilities

  • Extracts deterministic facts: file tree, import edges, manifest files, framework detection, entry points, and provides structured JSON plus a draft diagram to the LLM. The server never semantically "understands" the code; the model turns the facts into the final narrative and refined diagram.
  • Output formats: Mermaid (rendered natively by GitHub) and DOT (pipeable to Graphviz, Backstage, etc.), both accompanied by the same shareable HTML page and role-colored modules.
  • Supports .cartographer.yml configuration; the diagram: section provides defaults for --level, --format, and -o, with explicit flags taking precedence.
  • The check command reads a rules file and deterministically flags forbidden cross-boundary imports and dependency cycles, without an LLM, and can safely serve as a merge gate.
  • Baseline mechanism: for an existing codebase, record current violations as an accepted baseline, and subsequently fail the build only on new violations.
  • GitHub Action: a composite action runs check on every PR, fails the build on error-level violations, and posts a sticky comment containing the diagram and violations. The repository itself uses this feature in .github/workflows/architecture.yml.
  • Toolset: map_repo (path in, diagram out) plus four fine-grained tools that let the model refine between generate_diagram and render_diagramImage source.
  • Large repository performance: skip directories such as node_modules, .git, dist, build, venv, pycache, vendor, and all hidden directories; limit the number of scanned files and the bytes read per file; when thresholds are exceeded, collapse the import graph to the directory level; all truncations are reported and never silently dropped. No network calls during scanning (rendering HTML only pulls Mermaid from the CDN when opened in a browser). Output ordering is stable, avoiding changes to the diagram between runs.
  • Tests cover the deterministic core: import parsing (JS/TS and Python), module collapsing, cycle detection, rule globs, baseline diffing, Mermaid rendering, and the check end-to-end path. Run against src/ via tsx, with no build step and no test framework dependencies.

Usage

Requires Node.js 18+. The server communicates over stdio, and AI clients start it this way. It can also be used directly in the terminal: with no arguments it is an MCP server, and with subcommands it is an ordinary CLI for humans and CI. Zip-friendly: when pointed at an extracted "Download ZIP" folder (containing a repo-main/ wrapper), it detects the wrapper and maps the real repository root, noting this in the output and never doing so silently.

With Claude Code: after installation, ask "Use repo-cartographer to map ./my-project and draw me an architecture diagram." With Claude Desktop: add it to claude_desktop_config.json. With the OpenAI Agents SDK: the same server, a different model, which is exactly what demonstrates the value of MCP.

check usage: reads a rules file and flags forbidden cross-boundary imports and dependency cycles. After recording a baseline for an existing codebase, subsequent runs detect automatically and pass unless a PR introduces new violations.

Architecture governance in CI (GitHub Action): a composite action (action.yml) runs check on every PR, fails the build on error-level violations, and posts a sticky comment. See docs/github-action.md for the full design and phases.

When to use it

  • Quickly understand an unfamiliar codebase and generate architecture diagrams for PRs, documentation, or onboarding guidance.
  • Enforce architecture rules in CI to prevent cross-boundary imports and dependency cycles.
  • With an LLM client that supports MCP, let the model draw diagrams based on real repository facts rather than hallucinations.

Limitations

  • Languages supported in v1: JavaScript/TypeScript and Python.
  • No network calls during scanning, but rendering HTML requires pulling Mermaid from the CDN the first time it is opened.
  • Other features, fees, pricing, platforms, results, or usage steps, if not provided in the materials, are not yet provided.

Author: Gopi K Aitham (builditwithgk), available for freelance and contract work related to AI, agents, and MCP tools.