Codebase Knowledge Graph

.NET code analysis using Neo4j Database

  • Codebase Knowledge Graph: a graph concept agnostic to a programming language.
  • Strazh: tool to build a Codebase Knowledge Graph from a C# codebase.

How it works


  • class LoggerProviderAdapter (dark green node)
  • interface ILoggerAdapter (light green node)
  • the file, where this class is declared (yellow node)
  • methods (blue nodes)

Why is it useful?

  • Fast access to various codebase insights with rich visualization (Neo4j Browser, Bloom, and other Neo4j tools)
  • Ability to catch design violations and mistakes
  • Ability to find different coverages and various statistical information
  • Help you to estimate changes, features, and refactoring

Graph generation

static string GetFullName(string firstName, string lastName)
=> firstName + lastName;
Example of Syntax Tree (LINQPad)
  • Subject “class LoggerProviderAdapter” (Node :Class)
  • Predicate “have” (Relationship :HAVE)
  • Object “method Debug” (Node :Method)
Examples of Triples: Class declared in a File. Class have a Method. Method invoke some another Method.

Codebase Knowledge Graph

Codebase Knowledge Graph layers
Codebase Knowledge Graph schema
UnitTests project depends on Project (red nodes) with expanded Packages (orange nodes) used by UnitTests
Project Dependencies
Yellow nodes are Folders and grey nodes are Files. Red node is Project.
Invocation chain of method in Strazh project started from method “BuildKnowledgeGraph”

Strazh in Action

strazh [options]
-c, --credentials (REQUIRED)
required information in format `dbname:user:password` to connect to Neo4j Database
-t, --tier
optional flag as `project` or `code` or 'all' (default `all`) selected tier to scan in a codebase
-d, --delete
optional flag as `true` or `false` or no flag (default `true`) to delete data in graph before execution
-s, --solution (REQUIRED)
optional absolute path to only one `.sln` file (can't be used together with -p / --projects)
-p, --projects (REQUIRED)
optional list of absolute path to one or many `.csproj` files (can't be used together with -s / --solution)
show version information
-?, -h, --help
show help and usage information
  • Project Dependencies
  • Folder Structure
  • Types
  • Methods


  • You need a running instance of Neo4j Database and grant to Strazh a role with write permissions. Run services one after another.
  • Easiest setup is to use a default database “neo4j” with a default admin role “neo4j.” As you can see, provided “neo4j:neo4j:strazh” credentials match prepared NEO4J_AUTH: neo4j/strazh settings in Neo4j.
  • Also it’s always good to have Neo4j with APOC and GDS plugins inside to power up your queries.
Strazh output

Looking for Contributors

Contributors are welcome!

Personal Thank you




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vlad Batushkov

Engineering Manager @ Agoda. Neo4j Featured Community Member. Certified Neo4j Professional. Articles brewed on web, hops and indie rock’n’roll.