# Code-Review-Graph Export Formats: GraphML, Neo4j, and Obsidian Support

> Explore code-review-graph export formats: GraphML, Neo4j, and Obsidian. Visualize and analyze codebases effectively for network analysis, databases, and PKM.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: api-reference
- Published: 2026-08-09

---

**The code-review-graph library supports three primary export formats—GraphML, Neo4j Cypher, and Obsidian Vault—allowing you to serialize code-base graphs for network analysis, graph databases, or personal knowledge management.**

The `code-review-graph` tool models an entire code repository as a directed multigraph using the `GraphStore` class. To facilitate interoperability with external tools, the library provides dedicated exporters that serialize this graph structure into industry-standard formats. Each exporter follows a consistent pipeline defined in the source code, ensuring that node attributes, edge relationships, and community metadata are preserved across all outputs.

## How the Export Pipeline Works

All exporters share a unified retrieval and serialization pipeline. First, the `export_graph_data()` function in [`visualization.py`](https://github.com/tirth8205/code-review-graph/blob/main/visualization.py) (line 102) extracts the in-memory payload from a `GraphStore` instance, returning serializable collections of nodes and edges. Second, each format-specific exporter in [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py) iterates over these collections to generate the target output.

The `GraphStore` class defined in [`graph.py`](https://github.com/tirth8205/code-review-graph/blob/main/graph.py) serves as the central data model, exposing the `store.graph` property containing nodes and edges, along with utility methods like `_sanitize_name`. All export functions expect this object as their primary input.

## Supported Export Formats

The library implements three distinct export strategies in [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py), each optimized for specific downstream use cases.

### GraphML for Network Analysis

The `export_graphml(store, output_path)` function (line 58) generates an XML document compliant with the GraphML schema. It maps node attributes—including `kind`, `file`, `language`, and `community`—to `<data>` elements within each `<node>` tag. Edges receive a `kind` attribute distinguishing relationship types. This format is ideal for importing into tools like Gephi or yEd for visual network analysis.

### Neo4j Cypher for Graph Databases

For integration with Neo4j, the `export_neo4j_cypher(store, output_path)` function (line 124) produces executable Cypher statements. It emits `CREATE` clauses for nodes with appropriate labels and properties, followed by `MATCH` and `CREATE` patterns for relationships. The helper functions `_cypher_escape` and `_cypher_props` (lines 73-88) handle string escaping and property mapping to prevent injection issues and ensure valid Cypher syntax.

### Obsidian Vault for Knowledge Management

The `export_obsidian_vault(store, output_dir)` function (line 95) transforms the graph into a navigable Obsidian vault structure. It generates one Markdown file per node with YAML front-matter containing metadata, embeds wikilinks to neighboring nodes, and creates community overview pages plus a master index. The `_obsidian_slug` helper (lines 146-151) ensures filenames are filesystem-safe while maintaining readability.

## Programmatic Usage (Python API)

You can invoke exporters directly after loading a project. The `load_project()` function returns a `GraphStore` instance compatible with all export functions.

```python
from pathlib import Path
from code_review_graph.main import load_project
from code_review_graph.exports import (
    export_graphml,
    export_neo4j_cypher,
    export_obsidian_vault,
)

# Load repository into GraphStore

store = load_project(Path("/path/to/source/code"))

# Export to GraphML

export_graphml(store, Path("output/graph.graphml"))

# Export to Neo4j Cypher script

export_neo4j_cypher(store, Path("output/import.cypher"))

# Export to Obsidian vault directory

export_obsidian_vault(store, Path("output/obsidian_vault"))

```

## Command-Line Interface

The CLI in [`cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/cli.py) (lines 1658-1685) exposes the same functionality via the `--export` flag. Pass the format identifier and specify the output path.

```bash

# Generate GraphML file

code-review-graph --project /path/to/code --export graphml --out graph.graphml

# Generate Neo4j Cypher script

code-review-graph --project /path/to/code --export neo4j --out import.cypher

# Generate Obsidian vault directory

code-review-graph --project /path/to/code --export obsidian --out ./obsidian_vault

```

## Summary

- **Unified Pipeline**: All exporters rely on `export_graph_data()` from [`visualization.py`](https://github.com/tirth8205/code-review-graph/blob/main/visualization.py) and operate on the `GraphStore` object defined in [`graph.py`](https://github.com/tirth8205/code-review-graph/blob/main/graph.py).
- **GraphML**: XML-based format for network visualization tools, produced by `export_graphml()` in [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py).
- **Neo4j Cypher**: Database import scripts with safe string handling via `_cypher_escape()`, generated by `export_neo4j_cypher()`.
- **Obsidian Vault**: Markdown-based knowledge base with wikilinks and YAML front-matter, created by `export_obsidian_vault()`.
- **Dual Interface**: Available both as Python functions and CLI commands via [`cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/cli.py).

## Frequently Asked Questions

### Does code-review-graph support JSON or SVG export?

Yes, the [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py) module also contains exporters for JSON and SVG formats, though the primary specialized formats are GraphML, Neo4j Cypher, and Obsidian Vault. The JSON exporter provides a raw serializable dump of the graph structure, while SVG generates a static vector visualization.

### Can I customize the node attributes included in the GraphML output?

The GraphML exporter in [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py) captures standard attributes such as `kind`, `file`, `language`, and `community` by default. To include custom attributes, you would need to modify the graph construction logic in [`graph.py`](https://github.com/tirth8205/code-review-graph/blob/main/graph.py) where nodes are created, as the exporter iterates over existing node properties.

### Is the Neo4j Cypher output compatible with all Neo4j versions?

The generated Cypher uses standard `CREATE` and `MATCH` syntax supported by Neo4j 4.x and 5.x. The `_cypher_props()` and `_cypher_escape()` helpers ensure proper handling of special characters and data types, making the output broadly compatible with modern Neo4j installations.

### How does the Obsidian exporter handle large codebases?

The `export_obsidian_vault()` function uses the `_obsidian_slug()` helper (lines 146-151) to generate safe filenames and creates directory structures based on detected communities. While there is no explicit pagination, the file-per-node approach scales to thousands of files, limited primarily by your filesystem's file count limits and Obsidian's indexing performance.