Skip to content

About

Visualize a codebase's function call graph as draggable Blueprint-style cards. Python, Rust, TypeScript, and JavaScript supported.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Function Viewer

Function Viewer logo

Overview

Function Viewer visualizes how the functions of a codebase call each other, styled like an Unreal Engine Blueprint graph. Every function is a draggable card showing its signature, docstring, and full syntax highlighted source, connected by glowing wires that trace each real call in the code.

The goal is to make the flow of a codebase visible instead of jumping between files and grepping for callers. Core capabilities:

  • Load any file or folder from disk and see every function and call resolved automatically, in any supported language, no per-language toggle needed.
  • Toggle functions active or inactive to grow or shrink the graph around what matters right now.
  • Follow a function's flow upward (its callers) or downward (what it calls) with one click.
  • Auto arrange the graph two ways: by call order (flow mode) or grouped by file (folder mode, draggable as a group).
  • Search and a VS Code style file explorer for quick navigation, with a small language icon next to each file.
  • A Dark and a Light theme. The topbar toggle cycles System, Light and Dark; System follows the OS and is the default.

Supported languages

Language Extensions
Python .py
Rust .rs
TypeScript .ts, .tsx, .mts, .cts
JavaScript .js, .jsx, .mjs, .cjs
C .c, .h (unless the folder also holds C++ files)
C++ .cc, .cpp, .cxx, .hpp, .hh, .hxx, plus .h when the folder also holds C++ files
Java .java

More languages can be added without touching the frontend - see Backend below.

Quick start

Backend (Python 3.10+):

pip install -r backend/requirements.txt
python -m uvicorn backend.main:app --port 8000

Frontend:

cd frontend
npm install
npm run dev

Open http://localhost:5173 and load a folder or file from the sidebar. Try sample_project (Python), sample_rust_project (Rust), sample_typescript_project (TypeScript and JavaScript), sample_c_project (C) or sample_cpp_project (C++) for a quick demo.

Codebase

backend/            FastAPI + a per-language plugin architecture, static analysis
frontend/src/        React 19 + React Flow + Zustand, the UI
sample_project/      Python demo fixture used for manual testing
sample_rust_project/ Rust demo fixture used for manual testing
sample_typescript_project/ TypeScript + JavaScript demo fixture used for manual testing
sample_c_project/    C demo fixture used for manual testing
sample_cpp_project/  C++ demo fixture used for manual testing

Backend

  • analyzer.py: the dispatcher. Groups the files it's given by extension, hands each slice to its language plugin, and merges the results into one graph. An extension normally belongs to one plugin, but a plugin may claim one conditionally per load (conditional_extensions and claims() in languages/base.py); that is how .h goes to C or C++. Function and file ids are namespaced by path, so merging across languages can't collide.
  • languages/: one module per language, each implementing the same LanguagePlugin contract (languages/base.py) - parse every file, extract each function's signature/docstring/source lines, and resolve which loaded functions it calls (direct calls, module.func(), self.method(), constructors/associated functions). Only calls between functions that were actually loaded get resolved. Adding a language means adding one new module here and registering it in languages/__init__.py; nothing else changes.
    • python.py: parses with the stdlib ast.
    • rust.py: parses with tree-sitter + tree-sitter-rust (functions, impl methods, use-based and bare-path module resolution). Calls made inside a macro invocation (println!, format!, ...) aren't visible to it - macro arguments are an opaque token stream, not parsed expressions.
    • typescript.py: one plugin for TypeScript and JavaScript, parsed with tree-sitter + tree-sitter-typescript (the typescript grammar for .ts, .tsx for everything else). It stamps each file with its own language, so a .ts file and a .js file get their own badge but can call each other. Reads ESM and basic CommonJS imports, resolves relative specifiers and (by unique path suffix) aliases, and ignores .d.ts and minified files. There's no separate "JS mode": a missing annotation is just a missing annotation. Its docstring lists exactly what it resolves and what it can't (JSX elements, inheritance, dynamic calls, ...).
    • c.py (with cfamily.py, tree-sitter helpers shared by the C and C++ plugins): parses with tree-sitter + tree-sitter-c and owns .c, and .h unless the C++ plugin claims it. Only definitions are Functions; a prototype in a header never is, but its comment documents a definition that has none. Calls are resolved by name in C's own visibility order: the same file, then files reached through quoted #include "..." (and the .c file implementing an included header), then the one non-static definition anywhere in the picked folder. A static function is visible only in its own file, and two or more candidates mean no wire rather than a guess. Nothing is preprocessed or compiled, so functions defined by macros aren't Functions, calls hidden in macro bodies are invisible, every #ifdef branch is parsed, and function-pointer calls (cb(x), s->handler(x)) aren't linked, including a call through a parameter or local variable named like a loaded function. A file tree-sitter can't fully parse is flagged but keeps the functions it recovered.
    • cpp.py: parses with tree-sitter + tree-sitter-cpp, owns .cc, .cpp, .cxx, .hpp, .hh and .hxx, and claims .h when the picked folder holds any of those (a C-only folder's headers stay C). C and C++ are separate plugins, so no wire joins a C file to a C++ one. Functions are definitions with a body: free functions, methods defined in or out of their class, constructors, destructors and operators; lambdas aren't Functions, and a template is one Function. qualname is the scoped name (ns::Class::method); overloads defined in one file get their parameter types appended (add(int), at(int) const), a name defined once keeps its plain name. Calls resolve by name through C++'s scopes (the enclosing class and its loaded bases, enclosing namespaces, using declarations, then C's include-based visibility), and when a step finds several candidates the call links only if the argument count leaves exactly one. A member call resolves by the receiver's declared type (a parameter, local variable or data member; smart pointers and aliases unwrapped), falling back to the one loaded method of that name when the type isn't visible (auto, a template parameter). Nothing is preprocessed or compiled: no template instantiation, no argument-dependent lookup, no overload resolution by argument types; operator expressions and calls through function pointers or std::function aren't linked, and virtual dispatch isn't followed, so a call through a Base * links to Base::run, never to every override. Macros hide functions and calls as in C.
  • main.py: the FastAPI app. GET /api/browse powers the server-side folder picker, POST /api/analyze runs the analyzer and returns the graph as JSON. Also serves the built frontend in production.

Frontend

  • store.ts: the single Zustand store, holds the loaded graph, which functions are active, the layout mode, and every UI action.
  • flow.ts: pure functions for visibility rules (active functions plus their direct neighbors shown as ghosts), reachability for the flow buttons, and picking main as the entry point on load.
  • layout.ts: the two auto arrange algorithms, both built on a shared depth first search model. Flow mode lays out every function left to right by call depth, in call order. Folder mode groups functions by file first, then ranks the file groups left to right with dagre.
  • components/GraphCanvas.tsx: the React Flow canvas, incremental card placement, both layout modes, folder drag to move a group, wire highlighting, and the topbar controls.
  • components/FunctionNode.tsx: the blueprint style function card, with syntax highlighting and per line call handles.
  • components/FolderFrame.tsx: the folder style group frame used in folder mode.
  • components/Sidebar.tsx, FileTree.tsx, SearchBar.tsx, PathBrowser.tsx: import controls, a nested directory tree, search, and the server-side folder browser.
  • components/LanguageIcon.tsx: the small per-file language badge shown in the Explorer.
  • languages.ts: the frontend's mirror of the backend's language registry - id, label, extensions, icon color per language, plus two optional settings (prism, a highlighting grammar not named like the id; unannotatedReturn, what a card shows when a return type is missing). Adding a language to the backend also means adding one entry here.
  • api.ts, types.ts, colors.ts: fetch wrapper, wire format types, and per file color hashing.
  • theme.ts, components/ThemeToggle.tsx: the theme preference (System, Light or Dark), the System theme tracking, and the topbar toggle. The resolved theme is set as data-theme on <html>, and every color in index.css is a token that the Light theme overrides.

The frontend only talks to the backend over HTTP, with no browser-only file APIs, so it can later be wrapped in an Electron or Tauri shell without changes.

CI/CD

Every PR into main runs two required checks (.github/workflows/pr-checks.yml): a frontend build and a backend build-and-run (health check against /api/health).

On every push to main, two deployments happen automatically:

  • Backend: a single Docker image (Dockerfile) that builds the frontend and bundles it with the backend, which serves it at /. render.yaml describes the Render web service; once connected to this repo, Render rebuilds and redeploys on every push. Live at https://function-viewer.onrender.com.
  • Frontend: .github/workflows/deploy-pages.yml builds frontend/ with VITE_API_URL pointed at the Render backend above and publishes it to GitHub Pages. Live at https://mcr-project.github.io/function-viewer/.

The two are independent: the Render deploy is self-contained (backend serving its own built frontend), while the Pages site is a separate static build of the same frontend wired to the same Render API.

About

Visualize a codebase's function call graph as draggable Blueprint-style cards. Python, Rust, TypeScript, and JavaScript supported.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages