An interactive, AST-powered codebase dependency graph and architecture explorer for TypeScript, JavaScript, Python, and Dart / Flutter repositories, built with ts-morph, React Flow, and Dagre.
Statically parses local repositories into an Abstract Syntax Tree (AST), resolves internal module imports/exports, maps architectural layers via Kahn's Topological Sort, and animates code execution flow step-by-step.
Inside any local TypeScript, JavaScript, Python, or Flutter/Dart project on your machine, simply run:
npx repotraceRepoTrace will automatically:
- Detect your current codebase directory.
- Boot the dashboard on an isolated production port (default
4242). - Launch your default browser to
http://localhost:4242and render your codebase graph!
# Analyze a specific project path
npx repotrace ./my-project
# Run on a custom port
npx repotrace --port 5050
# Run in headless/server mode (skip auto-opening browser)
npx repotrace --no-open
# View all CLI options
npx repotrace --helpIf you want to contribute to or hack on RepoTrace:
# 1. Clone repository
git clone https://github.com/your-username/repotrace.git
cd repotrace
# 2. Install dependencies
npm install
# 3. Start development servers (Vite :5173 + Express :3001)
npm run devWatch RepoTrace explore codebases, trace architectural execution flow, and cluster directories in real time:
Dagre-powered hierarchical tier layout color-coded by module category with circuit blueprint corridor routing:
Inspect discovered symbols (components, hooks, functions, interfaces) with caller/dependency counts, or step through execution flow step-by-step using the bottom canvas player:
-
β‘ Circuit Blueprint Flow Engine: Clean orthogonal corridor routing (
smoothstep) eliminates spaghetti crisscrossing wires. Hovering any card dynamically illuminates incoming callers in cyan (#06b6d4) and outgoing dependencies in purple (#a855f7). -
π― Focus Neighborhood Mode: 1-click micro-blueprint isolation (
[ Callers ] βββΆ [ Active File ] βββΆ [ Dependencies ]) that automatically fits to the screen with zero manual panning or scrolling needed. -
π Folder View Layout & Directory Clustering: Seamlessly switch between dependency flow and glassmorphic directory boundary containers that group files inside their physical folders.
-
π Real-Time Folder & File Search: Search files and physical folders simultaneously, spotlighting matching folder containers with glowing borders and camera centering.
-
β‘ Multi-Language AST Engine (TypeScript, JavaScript, Python, Dart/Flutter): Statically inspects and maps
.ts,.tsx,.js,.jsx,.mjs,.cjs,.py, and.dartfiles. Resolves ES Modules, CommonJS (require()), Python imports, and Flutter package imports (package:<app>/...viapubspec.yaml). Honors path aliases (@/*,~/*) and automatically ignores build caches, virtual environments (.venv,venv), Flutter platform runners (android/,ios/), and vendor packages (node_modules,.dart_tool). -
π Discovered Symbols & Functions: Extracts internal declarations from every fileβReact Components, Custom Hooks, Helper Functions, TypeScript Interfaces, Type Aliases, and Classesβbadging public exports versus private declarations.
-
π Zero-Upload Directory Navigator & Direct Path Input: Select any repository on your computer without uploading or moving source files. Includes an in-app filesystem navigator with quick shortcuts, direct path input/paste, and automatic codebase detection (
package.json/tsconfig.json). -
π Automatic Dagre Layout: Computes optimal hierarchical coordinates supporting Top-to-Bottom (
TB) and Left-to-Right (LR) orientations with smooth bezier connections. -
π Bidirectional Topological Sort:
-
Execution Flow (Entrypoint β Leaves, default): Traces the runtime boot path starting at
index.tsxdown through containers, UI components, and leaf utilities. - Build Order (Leaves β Entrypoint): Traces the compilation sequence starting at foundational primitives with zero dependencies up toward the entrypoint.
-
Execution Flow (Entrypoint β Leaves, default): Traces the runtime boot path starting at
-
π‘οΈ Fault-Tolerant Cycle Breaking: Mathematically detects circular import loops (
$A \rightarrow B \rightarrow C \rightarrow A$ ) using Kahn's algorithm and DFS back-edge detection. Bypasses the deadlock to ensure 100% of your codebase remains sorted and visible, while highlighting cyclic nodes in pulsing crimson red. -
π¬ Interactive Canvas Flow Player: Floating player docked at the bottom of the canvas. Traverses the codebase step-by-step or with auto-play, smoothly illuminating each module in glowing amber as it resolves.
-
π― 1-Hop Neighborhood Isolation: Clicking any file isolates its direct incoming callers (cyan) and outgoing dependencies (purple), dimming unrelated files to reduce visual noise.
The system decouples the Backend AST Engine (Data Producer) from the Frontend Canvas (Data Consumer):
flowchart TD
subgraph Frontend ["Client (React 18 + Vite + React Flow + Dagre)"]
UI[User inputs path or picks folder]
TopBar[TopBar Toolbar]
Canvas[React Flow Graph Canvas]
Drawer[Topo Order Drawer]
Player[Canvas Flow Player]
DagreEngine[Dagre Layout Engine]
TopoEngine[Kahn Topo Sort & Cycle Breaker]
end
subgraph Backend ["Server (Node.js + Express + ts-morph)"]
API["Express API (:3001)"]
Explorer["Directory Explorer (/api/explore)"]
WinDialog["Windows Dialog (/api/browse-folder)"]
Analyzer["CodebaseAnalyzer (server/analyzer.ts)"]
TSMorph["ts-morph AST Engine"]
end
UI --> TopBar
TopBar -->|POST /api/analyze| API
TopBar -->|POST /api/browse-folder| WinDialog
TopBar -->|GET /api/explore| Explorer
API --> Analyzer
Analyzer --> TSMorph
TSMorph -->|AST Nodes & Symbols| Analyzer
Analyzer -->|JSON: nodes, edges, symbols| API
API -->|GraphPayload| Frontend
Frontend --> DagreEngine
Frontend --> TopoEngine
DagreEngine --> Canvas
TopoEngine --> Drawer
TopoEngine --> Player
Player -->|Sync active step| Canvas
repotrace/
βββ server/ # Backend AST & Discovery Engine
β βββ analyzer.ts # CodebaseAnalyzer: ts-morph AST parser & symbol extractor
β βββ index.ts # Express API server & routes (/api/analyze, /api/explore)
β βββ mockData.ts # Fallback graph data for resilience
β βββ test-analyzer.ts # CLI test runner for AST extraction
β βββ test-topo.ts # CLI test runner for Topo Sort & Cycle Breaking
β
βββ src/ # Frontend UI & Visualization Layer
β βββ components/ # UI Components
β β βββ CanvasFlowPlayer.tsx # Bottom floating stepper & playback controls
β β βββ CycleAlertModal.tsx # Circular dependency loop diagnosis dialog
β β βββ FileNode.tsx # Custom React Flow card (badges, states, counters)
β β βββ FolderBrowserModal.tsx # In-app visual directory picker & OS dialog trigger
β β βββ GraphCanvas.tsx # React Flow canvas wrapper with minimap & controls
β β βββ Sidebar.tsx # Selected node inspector (symbols, callers, deps)
β β βββ TopBar.tsx # Top toolbar with search, presets, layout & topo triggers
β β βββ TopoOrderDrawer.tsx # Slide-out topological architectural tier guide
β β
β βββ utils/ # Client Graph Utilities & Algorithms
β β βββ graphAnalysis.ts # Category heuristics & 1-hop neighborhood math
β β βββ layout.ts # Dagre layout coordinate math & edge styling
β β βββ topoSort.ts # Fault-tolerant Kahn's algorithm & cycle breaking
β β
β βββ types/ # Domain Type Definitions
β β βββ graph.ts # RawNode, RawEdge, GraphPayload, FileSymbol, FileNodeData
β β
β βββ App.tsx # Root application coordinator
β βββ main.tsx # React DOM entrypoint
β βββ index.css # Tailwind CSS utilities
β
βββ example-repo/ # Realistic 10-file React+TS sample chat app
βββ progress.md # Roadmap tracking and completed milestones
βββ walkthrough.md # In-depth technical architecture guide
βββ package.json # Scripts and dependencies
Statically parses example-repo and logs discovered symbols, outgoing dependencies, and incoming callers to the terminal:
npm run test:analyzerRuns Kahn's algorithm over example-repo (verifying 7 architectural tiers) and an intentionally cyclic test graph (
npm run test:topoWhile the current AST analyzer uses ts-morph for TypeScript & JavaScript (.ts, .tsx, .js, .jsx), the frontend graph consumer is language-agnostic.
To support other languages (Python, Go, Rust, Java), implement an adapter in server/ that emits the standardized { nodes, edges } JSON structure:
- Python: Use Python's built-in
astmodule or Tree-sitter. - Go: Use
go/parserandgo/ast. - Rust: Use
synorra_ap_syntax.
The entire frontend canvas, Dagre layout, Topological Sort drawer, and Stepper player will work immediately without any client-side changes.
Contributions make the open-source community an incredible place to learn, inspire, and create!
- Read our Contributing Guide to get started with local setup, branch conventions, and testing workflows.
- Check out open issues or submit ideas for new language adapters, symbol call-graphs, or canvas themes.
- Please review and adhere to our Code of Conduct.
This project is licensed under the MIT License.

