The code graph

A map of the code, built by its compilers

For every commit Branchscope builds a graph of the code: functions, types, endpoints, tables, screens and message channels, and the calls and data access between them. Reviews, views and diagrams all come from it, and none of it is written by an AI model.

fixtures/invoices › Graph › Architecture
  • new
  • edited
  • removed
  • renamed or moved
  • unchanged
  • not allowed by a rule
  • needs review
  • unresolved
  • ⬡ endpoint · ⛁ table · ▭ screen · ▢ code
Architecture 3 projects, 2 endpoints, 1 table, 1 screen
Billing.Api maps to (5 links) table invoicesmaps to (5 links)Billing.Api reads (1 link) table invoicesreads (1 link)Billing.Api serves (1 link) GET /invoices/{id}serves (1 link)Billing.Api.Tests depends on (4 links) Billing.Apidepends on (4 links)web calls (2 links) GET /invoices/{id}calls (2 links)web serves (1 link) GET /api/healthserves (1 link)web serves (1 link) /invoices/[id]serves (1 link)web calls (1 link) URL built at runtimecalls (1 link)table invoices · tabletable invoicesBilling.Api · projectBilling.ApiC#Billing.Api.Tests · project · testBilling.Api.TestsC#GET /invoices/{id} · endpointGET /invoices/{id}GET /api/health · endpointGET /api/healthweb · projectwebTypeScript/invoices/[id] · screen/invoices/[id]URL built at runtime · unresolvedURL built at runtime
As text

Elements

  • table invoices (table)
  • Billing.Api (project): C#
  • Billing.Api.Tests (project, test): C#
  • GET /invoices/{id} (endpoint)
  • GET /api/health (endpoint)
  • web (project): TypeScript
  • /invoices/[id] (screen)
  • URL built at runtime (unresolved)

Connections

  • Billing.Api maps to (5 links) table invoices
  • Billing.Api reads (1 link) table invoices
  • Billing.Api serves (1 link) GET /invoices/{id}
  • Billing.Api.Tests depends on (4 links) Billing.Api
  • web calls (2 links) GET /invoices/{id} (unresolved)
  • web serves (1 link) GET /api/health
  • web serves (1 link) /invoices/[id]
  • web calls (1 link) URL built at runtime (unresolved)

The Architecture view of fixtures/invoices, the TypeScript and C# sample in Branchscope's repository, drawn from its golden graph by the Graph tab's own code.

Derived, not authored

Built by compilers, not guessed by a model

Each language's own tooling reads the code: scip-typescript, Roslyn, go/types, rust-analyzer, scip-python, javac and the Kotlin compiler, with adapters for the frameworks on top. Every node says which of them found it, and every edge whether the compiler knows it, it was matched by a pattern, or it can't be known before the code runs. The default branch and protected branches get a graph on every push; any other branch or commit on request.

alice/invoices › Graph
ExplorerArchitectureData flow

Get function public-api

dotnet:src/Billing.Api|Billing.Api.Controllers|InvoicesController#Get(System.Guid)

Language
csharp
Code
src/Billing.Api/Controllers/InvoicesController.cs:11
Found by
adapter-aspnetcore, roslyn-dotnet

Uses

  • handlesGET /invoices/{id}src/Billing.Api/Controllers/InvoicesController.cs:7
  • readsinvoicessrc/Billing.Api/Controllers/InvoicesController.cs:13
  • referencesInvoicesrc/Billing.Api/Controllers/InvoicesController.cs:11

Languages

TypeScript, C#, Go, Rust, Python, Java and Kotlin, joined at their endpoints

JavaScript and TypeScript with Next.js and fetch clients, C# with ASP.NET Core and EF Core, Go with net/http, chi, gin and gorm, Rust with axum, actix-web, warp, sqlx, diesel and sea-orm, Python with FastAPI, Flask, Django and SQLAlchemy, and Java and Kotlin with Spring, JAX-RS, Ktor, JPA, Spring Data and Exposed, plus the message brokers each one talks to. A call in one language and the handler in another meet at the same endpoint, by the service names in branchscope.json.

alice/invoices › Graph
ExplorerArchitectureData flow

GET /invoices/{id} endpoint

http:billing-api:GET /invoices/{}

Used by

  • handlesGetsrc/Billing.Api/Controllers/InvoicesController.cs:7
  • requestsfetchInvoice(heuristic)apps/web/src/lib/api/invoices.ts:6
  • requestsget(heuristic)apps/web/src/lib/api/client.ts:13

Views

Explorer, Architecture and Data flow

The Graph tab has three views of one commit. Explorer finds any node by name, ID or path, with what it uses and what uses it, linked to the line. Architecture shows projects, how they depend on each other, and the endpoints, tables and screens they touch. Data flow follows columns tagged as personal data to the code that reads and writes them, and the endpoints and screens that reach that code.

fixtures/invoices › Graph › Data flow
  • new
  • edited
  • removed
  • renamed or moved
  • unchanged
  • not allowed by a rule
  • needs review
  • unresolved
  • ⬡ endpoint · ⛁ table · ▭ screen · ▢ code
Personal data 1 pii column; touched by 3 code elements; reachable from 1 entry point
table invoicestable invoicesBilling.ApiBilling.ApiBilling.Api.ControllersBilling.…Billing.Api.DataBilling.Api.DataGet() reads customer_emailreadsInvoice maps to customer_emailmaps toCustomerEmail maps to customer_emailmaps toGET /invoices/{id} handled by Get()handled bycustomer_email · column · piicustomer_emailGet() · function · public-apiGet()Invoice · typeInvoiceCustomerEmail · field · piiCustomerEmailGET /invoices/{id} · endpointGET /invoices/{id}
As text

Elements

  • customer_email (column, pii) in table invoices
  • Get() (function, public-api) in Billing.Api › Billing.Api.Controllers
  • Invoice (type) in Billing.Api › Billing.Api.Data
  • CustomerEmail (field, pii) in Billing.Api › Billing.Api.Data
  • GET /invoices/{id} (endpoint)

Connections

  • Get() reads customer_email
  • Invoice maps to customer_email
  • CustomerEmail maps to customer_email
  • GET /invoices/{id} handled by Get()

The Data flow view of the same graph: a column marked as personal data, the code that reads, writes and maps it, and the endpoint that reaches it.

Determinism

The same commit, the same graph, byte for byte

A graph is canonical JSON: the same commit and toolchain always give identical bytes, so a graph can be cached, compared and cited. Every function, type and field carries a fingerprint of its code without its name, which is how moves and renames are told apart from new code. Download it from the Graph tab, with bscope graph download, or from GET /v1/repos/:owner/:repo/graphs/:commit.

~/invoices
$ bscope graph status
main at 9c1d22a0: 58 nodes, 47 edges.
$ bscope graph download -o invoices.graph.json
Wrote the graph of main at 9c1d22a0 to invoices.graph.json.

Graph builds

Each build in a sandbox of its own

A graph is built from its own clone of the commit, in a sandbox of its own, so a repository's setup commands never run beside Branchscope's services. Builds that fail for the infrastructure's reasons, not the repository's, are retried on their own, and the builds list shows each one with its log.

alice/invoices › Graph builds
  • main 9c1d22a04,212 nodes · 9,876 edgesdone
  • agent/export 7e4f0b12pnpm install --frozen-lockfilerunning
  • fix/totals 3d8e1f55queued

See your code as a graph

Push a repository, or import one from GitHub or GitLab, and open its Graph tab once the first build is done.