# code-review-graph Export Formats: GraphML, Neo4j, Obsidian, and More

> Export code-review-graph to GraphML Neo4j Obsidian JSON and SVG. Visualize code reviews with desktop tools graph databases and knowledge bases.

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

---

**code-review-graph supports five distinct export formats including GraphML for desktop visualization tools, Neo4j Cypher for graph databases, and Obsidian vaults for knowledge bases, alongside JSON and SVG outputs.**

The code-review-graph project by tirth8205 analyzes code review data to generate relationship graphs. Once your graph is constructed, the exports module in [`code_review_graph/exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/exports.py) provides multiple serialization strategies, allowing you to move data into specialized tools for further analysis or visualization.

## Supported Export Formats

The tool can serialize graphs into five interchangeable formats, each implemented as a dedicated function in the exports module.

### JSON

The **JSON** export produces a UTF-8 encoded file containing the complete graph payload—nodes, edges, and community metadata. This format is ideal for programmatic consumption or archival storage. The implementation resides in `export_json` at [`code_review_graph/exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/exports.py) lines 23-52.

### GraphML

**GraphML** is an XML-based format supported by desktop visualization tools such as Gephi, yEd, and Cytoscape. Exporting to this format allows you to apply force-directed layouts and advanced filtering outside the CLI environment. Use the `export_graphml` function found in [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py).

### Neo4j Cypher

The **Neo4j Cypher** export generates a text file containing `CREATE` statements compatible with Neo4j Browser or `cypher-shell`. You can paste these statements directly into a Neo4j instance to populate a native graph database.

### Obsidian Vault

The **Obsidian vault** export creates a directory of Markdown files with YAML front-matter and wikilinks, ready for import into Obsidian. This format includes community overview pages, making it suitable for personal knowledge management and documentation workflows. The `export_obsidian_vault` function handles this conversion in [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py).

### SVG

**SVG** exports produce static vector images of the graph layout. This requires the optional `matplotlib` dependency and is handled by `export_svg` in [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py).

## How the Export Pipeline Works

All exports follow a three-stage pipeline defined across [`visualization.py`](https://github.com/tirth8205/code-review-graph/blob/main/visualization.py) and [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py).

1. **Data Gathering**: The `export_graph_data` function in [`code_review_graph/visualization.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/visualization.py) (lines 172-19) queries the `GraphStore` and builds a canonical dictionary containing nodes, edges, and community metadata.

2. **Serialization**: Each format-specific function—such as `export_graphml` or `export_neo4j_cypher`—transforms the dictionary into its target representation (XML strings, Cypher commands, Markdown pages, etc.).

3. **Atomic Write**: Exporters write to a temporary file before atomically replacing the target path. This pattern, visible in `export_json` at lines 30-47 of [`exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/exports.py), ensures file integrity even if the process terminates unexpectedly.

## Exporting via the Python API

You can invoke exports programmatically after constructing a `GraphStore` instance.

```python
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.exports import (
    export_json,
    export_graphml,
    export_neo4j_cypher,
    export_obsidian_vault,
    export_svg,
)

store = GraphStore(Path("/tmp/mygraph.db"))

# JSON

export_json(store, Path("out/graph.json"))

# GraphML

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

# Neo4j Cypher

export_neo4j_cypher(store, Path("out/graph.cypher"))

# Obsidian vault (directory)

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

# SVG (requires matplotlib)

export_svg(store, Path("out/graph.svg"))

```

## Exporting via the Command Line

The `visualize` command in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py) exposes all formats via the `--format` flag. Outputs are written to `<repo_root>/.code-review-graph/data/`.

```bash

# Export as GraphML for Gephi

code-review-graph visualize --format graphml

# Export as Neo4j Cypher statements

code-review-graph visualize --format cypher

# Export as an Obsidian vault

code-review-graph visualize --format obsidian

# Export as SVG image

code-review-graph visualize --format svg

```

The CLI dispatcher maps each format string to its corresponding export function: `export_json`, `export_graphml`, `export_neo4j_cypher`, `export_obsidian_vault`, or `export_svg`.

## Key Implementation Files

| File | Role |
|------|------|
| [`code_review_graph/exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/exports.py) | Implements all export functions and atomic write logic. |
| [`code_review_graph/visualization.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/visualization.py) | Contains `export_graph_data`, the shared data preparation routine. |
| [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py) | Parses `--format` arguments and dispatches to the appropriate exporter. |

## Summary

- **code-review-graph** offers five export formats: JSON, GraphML, Neo4j Cypher, Obsidian vault, and SVG.
- All exports use a three-step pipeline: data gathering via `export_graph_data`, format-specific serialization, and atomic file writing.
- Use the Python API for custom workflows or the CLI `visualize --format` command for quick exports.
- GraphML targets desktop visualization tools, while Cypher enables Neo4j database imports and Obsidian vaults support knowledge management.

## Frequently Asked Questions

### Which export format should I use for Gephi or Cytoscape?

Use the **GraphML** format. The `export_graphml` function in [`code_review_graph/exports.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/exports.py) generates XML compatible with these desktop applications, preserving node and edge attributes for interactive exploration.

### Can I import graph data directly into a Neo4j database?

Yes. Select the **Cypher** export format using `--format cypher` or the `export_neo4j_cypher` Python function. The resulting `.cypher` file contains `CREATE` statements that you can execute in Neo4j Browser or pipe directly into `cypher-shell` to populate your graph database.

### What does the Obsidian vault export include?

The **Obsidian vault** export generates a directory of Markdown files with YAML front-matter describing each node, plus wikilinks representing edges. Community detection results are summarized in overview pages, allowing you to navigate code review relationships as a linked knowledge base inside Obsidian.

### Is matplotlib required for all exports?

No. The **SVG** format is the only export that requires the optional `matplotlib` dependency. JSON, GraphML, Cypher, and Obsidian exports function with only the base package installed.