Find your way in.
CodeGraph is a Java command-line tool that builds a Neo4j graph from source code. Start with one service, then ingest another to connect supported HTTP calls across repositories.
Quickstart
You’ll need a CodeGraph source checkout, Java 21 or newer, Maven 3.9 or newer, and a running Neo4j 5.x database.
1. Build the CLI
Run Maven from the root of your CodeGraph checkout. It creates a self-contained executable at target/codegraph.jar.
mvn package2. Ingest a Java source root
Use the directory where Java packages begin, usually src/main/java. Replace the example path, service name, and password with your local values.
java -jar target/codegraph.jar /path/to/catalog/src/main/java --service catalog --password <neo4j-password>The default connection is neo4j://127.0.0.1:7687, with user neo4j. Use --uri and --user to change it. The --password argument is required.
--service identifies the service. If you omit it, CodeGraph tries spring.application.name from supported base configuration. Keep service names unique and stable: Java node IDs include the service so identical class and method names in different repositories stay separate. Add -v for extraction and linking diagnostics.
Upgrading an existing graph? Older Java node IDs did not include the service. CodeGraph now stops before writing to a graph containing those IDs. Re-ingest every service into a fresh Neo4j database or a new instance selected with --uri.
Connect two repositories
Ingest both source roots into the same Neo4j database. Either ingestion order works. Each run performs a linking pass over the stored HTTP facts.
java -jar target/codegraph.jar /path/to/checkout/src/main/java --service checkout --password <neo4j-password>
java -jar target/codegraph.jar /path/to/scheduler/src/main/java --service scheduler --password <neo4j-password>The current matcher compares the target service, HTTP verb, and path. Outbound service identity comes from the first path segment: /scheduler/… maps to scheduler. The host is excluded from matching.
Spring routes include the context path in base application.properties. Play-style callers can read base HOCON from conf/application.conf beside the app source root. Automatic profiles and environment fallback are not loaded.
Explore in Neo4j Browser
Run these Cypher queries in your Neo4j Browser after ingestion. The example method name must exist in the source you parsed.
Follow a method’s calls
MATCH path = (method:Method {name: 'getProduct'})
-[:CALLS*1..5]->(:Method)
RETURN path
LIMIT 50;Find connected HTTP callers and handlers
MATCH path = (caller:Method)-[:SENDS_TO]->(route:Channel)
-[:HANDLED_BY]->(handler:Method)
RETURN path
LIMIT 25;From source to graph
- Parse. JavaParser reads source files and a symbol solver resolves type and method identities.
- Build. Classes, methods, fields, and supported relationships become graph records. Spring and OkHttp readers add HTTP channels.
- Persist. Neo4j merges nodes and relationships by stable identifiers.
- Link. The HTTP matcher connects callers to uniquely matching declared routes. Unmatched channels remain without handlers.
Graph edges describe relationships identified in source. They do not establish runtime execution order, latency, or whether a particular request was sent.
Supported today
| Area | Current coverage |
|---|---|
| Structure | Top-level classes, interfaces, records, enums; methods and fields. Inheritance edges for classes and interfaces. |
| Method calls | Statically resolved method calls whose endpoints exist in the parsed graph. |
| HTTP handlers | Supported Spring annotation mappings, class prefixes, and the base context path. |
| HTTP callers | Continuous OkHttp request-builder chains with supported literal, configuration, constant, and stable-local URL expressions. |
| Uncertainty | Unknown whole path segments can become symbolic holes. Ambiguous matches remain unlinked. |
Keep these boundaries in mind
- Nested types, constructor calls, runtime reflection, and interface-to-implementation dispatch are not fully modeled.
- Kafka, gRPC, Play inbound routes, other HTTP clients, and gateway rewrites are outside the current HTTP scope.
- Fully dynamic URLs, split request builders, and unsupported expressions may be skipped. Verbose logs provide diagnostic reasons.
- Re-ingestion is idempotent, but there is no stale-source cleanup or rematching of already-linked calls after route changes. Use a fresh database when validating changed routing definitions.
- Source text, source locations, and an AI context retrieval API are not currently stored or exposed by this implementation.
About the interactive demo
The homepage uses fictional, bundled examples of CodeGraph’s supported relationships. You can inspect nodes and follow the sample paths entirely in your browser. It does not connect to your repositories or a live Neo4j instance.
Back to the graph