Skip to main content

Build a code graph with Graphify

Graphify turns a Git repository into a code graph inside a Knowledge. Files and significant symbols (functions, classes, and so on) become resources, the links between them become relations, and the Knowledge chat answers questions about the code by querying the graph. This guide takes you from a clone URL to a Knowledge you can browse and query.

In Rational AI, Graphify is a processing rule named Graphify repository. You select it when you attach a Git repository source to a Knowledge.

Before you begin​

  • The Graphify Query extension installed. It adds the Graphify repository processing rule and the tool the chat uses. See Manage extensions.
  • The Knowledge module in your license, with Create on the Sources row of your role and Update on the Knowledge row. See Manage roles and users.
  • An HTTPS clone URL for the repository, for example https://github.com/id-Software/DOOM.git.
  • For a private repository, a Git credentials connector for the repository host, created in Settings → Connectors. Public repositories need no connector.

Create a Git repository source​

  1. Go to Settings → Sources and select Add.
  2. In Type, under Git repository, select Public repository, or the Git credentials connector for a private repository.
  3. Enter the Repository URL.
  4. Optionally, enter a Branch, tag, or commit. Leave it empty to use the repository's default branch. Turn on Include Git submodules if the repository uses them.
The Add new source dialog with the Git repository type selected and a repository URL filled in

Attach the source with the Graphify rule​

  1. Create a Knowledge or open an existing one, open its settings, and attach the Git repository source on the Sources tab.
  2. Select Graphify repository as the source's Processing rule (in its Data processing settings), or as the Knowledge's Default processing rule.
  3. In the source's row, select Process now. If the source was never synchronized, this synchronizes it first.

A Graphify Knowledge holds exactly one Git repository. If you attach a second source that uses the rule, or a source that isn't a Git repository, saving fails with Graphify repository requires exactly one Git source per knowledge. To analyze several repositories, create one Knowledge for each.

The Knowledge Sources tab with a Git source attached and Graphify repository selected as its processing rule

Check what processing created​

When processing finishes, the Knowledge holds these resources:

CategoryWhat it holdsRelations
OverviewOne overview of the codebase.None
WorkspaceOne resource per top-level area of the repository.None
The file's workspaceOne resource per analyzed file.references to the files it uses
CommunityA cluster of files that belong together.contains the files in the cluster
SymbolA significant function, class, or other symbol.defined_in the file that declares it

Graphify doesn't chunk or embed the code, so document search finds nothing in this Knowledge. Answers come from the graph instead.

Explore the graph​

Processing adds a view named Graphify to the Knowledge. Open the Knowledge and switch to that view to explore files, symbols, communities, and the links between them. The resources also work like any other Knowledge content: filter them by category in the standard views and follow their relations from the resource details. See Set up the views of a Knowledge.

Ask questions about the code​

Graphify sets up the Knowledge's touchpoint to answer from the graph: it gives the touchpoint the query_graph tool and a matching prompt, and removes the generic RAG tools. Chat with the Knowledge as usual.

For a Knowledge built from the public DOOM repository, try:

Where is the main game loop implemented?

The answer points to D_DoomLoop() in linuxdoom-1.10/d_main.c and the functions it calls.

When the repository changes, select Process now again to rebuild the graph.

Next steps​