A static analysis and visualization tool designed to map the architecture, dependency graph, and tool-routing logic of enterprise-grade AI Agents.
Modern AI CLI agents are complex distributed systems involving Model Context Protocol (MCP) servers, polymorphic tool execution, and stateful terminal rendering.
This project explores how these systems are architected at scale. By writing a custom Abstract Syntax Tree (AST) parser in Python, I extracted the behavioral metadata from a publicly exposed source map of a major AI CLI. That data is then piped into a high-performance React dashboard, transforming hundreds of isolated files into an interactive Directed Acyclic Graph (DAG).
- 🧠 AST Metadata Extraction — The Python backend uses deep Regex parsing to extract class names, inheritance trees (
extends BaseTool), and public API exports, moving beyond simple file-system mapping to true Object-Oriented analysis. - ⚡ Dynamic DAG Layouts — Implements the
dagrelayout engine to calculate hierarchical x/y coordinates mathematically, preventing the classic "hairball" problem common in massive graph visualizations. - 🎛️ Domain Toggling — Rendering 600+ nodes simultaneously blocks the browser's main thread. This app features a Domain Filter that isolates subsystems (e.g., Core Engine vs. API Layer), recalculating the layout in milliseconds.
- 🔍 Interactive Focus Mode — Clicking any node instantly dims the noise and traces both incoming dependents and outgoing dependencies, color-coding the data flow.
- The Backend (
build_graph.py) — Scans the target directory, categorizes files into 10 architectural domains (Tools, MCP, Bootloader, Engine, etc.), and extracts relationships to generate a strictgraph.jsonartifact. - The Frontend (
React + Vite) — Ingests the JSON artifact. UsesReact Flowto manage the canvas, nodes, and edges, andDagre.jsto strictly enforce a Left-to-Right dependency cascade.
git clone https://github.com/Rutwik-M/cl-visualizer.git
cd agent-architecture-visualizerThe repository includes a pre-compiled graph.json in the public directory for immediate viewing.
npm install
npm run devOpen http://localhost:5173 in your browser.
If you want to generate a new graph against a different TypeScript codebase, place the target code in a local directory, update the SOURCE_DIRECTORY path at the bottom of build_graph.py, and run:
python3 build_graph.pyBuilding this visualization revealed several high-level system design patterns used in modern AI agents:
- The "God Class" Routing Pattern — Almost all CLI capabilities inherit from a centralized
Tool.tsinterface, proving a highly decoupled, polymorphic command structure rather than hard-coded switch statements. - Terminal as a Web App — The architecture treats the terminal prompt like a full-blown React web application, utilizing React Ink for complex state management and interactive dialog lifecycles.
- MCP Abstraction — Plugin ecosystems are not proprietary; they are directly wired into the open-source Model Context Protocol (MCP) Stdio and Remote server adapters.
-
This repository contains no proprietary source code. The
graph.jsondata is a mathematically abstracted structural representation derived from a publicly available source map, used strictly for educational system-design analysis and visualization research. -
This repository does not claim ownership of the original Claude Code source material.
-
This repository is not affiliated with, endorsed by, or maintained by Anthropic.
Rutwik Muley