# Where Is the Knowledge Graph Stored in Understand Anything and How to Share It with Git LFS

> Learn where Understand Anything stores its knowledge graph and how to share it efficiently using Git LFS. Manage large JSON files with ease.

- Repository: [Egonex/Understand-Anything](https://github.com/Egonex-AI/Understand-Anything)
- Tags: how-to-guide
- Published: 2026-06-28

---

**The knowledge graph in Understand Anything is stored as a JSON file at [`.understand-anything/knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/knowledge-graph.json) in your project root, and you can share it using Git LFS by running `git lfs track ".understand-anything/*.json"` to handle large files efficiently.**

Understand Anything generates a structured knowledge graph to represent your codebase analysis. This graph is persisted locally as a JSON document and can be version-controlled to share insights across your team. According to the Egonex-AI/Understand-Anything source code, the system uses a dedicated persistence module to manage graph storage and provides built-in support for Git LFS to handle large graph files.

## Knowledge Graph Storage Location

The knowledge graph is written to a **hidden project-specific folder** named `.understand-anything/` located at your project root. Inside this directory, the core graph data resides in [`knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/knowledge-graph.json), with additional auxiliary JSON files stored alongside it.

In [`understand-anything-plugin/packages/core/src/persistence/index.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/core/src/persistence/index.ts), the persistence layer defines the exact storage path and handles directory creation automatically. The code ensures the hidden folder exists before writing, sanitizing file paths to prevent traversal issues.

## Persistence Implementation: saveGraph and loadGraph

The persistence module exposes two primary functions for graph management: **`saveGraph`** and **`loadGraph`**. These handle the serialization and deserialization of the graph data structure.

**The `saveGraph` function** performs three critical operations:
- Sanitizes the target file path to prevent directory traversal
- Creates the `.understand-anything/` directory if it does not exist
- Writes pretty-printed JSON to [`knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/knowledge-graph.json)

**The `loadGraph` function** reads the stored JSON and optionally validates it against the schema upon retrieval.

```typescript
import { saveGraph } from "@understand-anything/core/persistence";
import { analyzeProject } from "@understand-anything/core/analysis";

const graph = await analyzeProject(projectRoot);
saveGraph(projectRoot, graph);   // writes .understand-anything/knowledge-graph.json

```

```typescript
import { loadGraph } from "@understand-anything/core/persistence";

const storedGraph = loadGraph(projectRoot, { validate: true });
if (storedGraph) {
  // feed it to the UI or reuse for incremental analysis
}

```

## Sharing Knowledge Graphs with Git LFS

Because the knowledge graph is a plain JSON document, it can be version-controlled like any source file. However, production graphs often exceed 10 MB, making Git LFS the recommended approach for team collaboration.

According to the README.md (lines 92-98) in the Egonex-AI/Understand-Anything repository, the recommended workflow involves committing the entire `.understand-anything/` directory while excluding temporary artefacts.

**Setup Git LFS for the knowledge graph:**

```bash
git lfs install
git lfs track ".understand-anything/*.json"
git add .gitattributes .understand-anything/
git commit -m "Add knowledge graph with LFS tracking"

```

This configuration ensures that heavy [`knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/knowledge-graph.json) files are stored in LFS rather than the standard Git object store, keeping repository size manageable while allowing teammates to retrieve ready-to-use graphs without re-running analysis.

**Files to exclude from version control:**
- `.understand-anything/intermediate/` (temporary processing files)
- [`.understand-anything/diff-overlay.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/diff-overlay.json) (transient diff data)

## Dashboard Integration

The dashboard server exposes the knowledge graph to the UI through the JSON file. In [`understand-anything-plugin/packages/dashboard/vite.config.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/dashboard/vite.config.ts) (lines 130-252), the development server configures routes to serve the graph at [`/knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main//knowledge-graph.json), allowing the visualization layer to consume the stored data directly.

## Summary

- **Storage location**: The knowledge graph is stored at [`.understand-anything/knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/knowledge-graph.json) in a hidden directory at your project root.
- **Core functions**: `saveGraph` and `loadGraph` in [`understand-anything-plugin/packages/core/src/persistence/index.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/core/src/persistence/index.ts) handle persistence with automatic directory creation and optional schema validation.
- **Git LFS workflow**: Track `.understand-anything/*.json` patterns using `git lfs track` to manage large graph files efficiently.
- **Exclusions**: Commit the graph JSON but exclude intermediate folders and diff overlays to keep repositories clean.

## Frequently Asked Questions

### Where exactly is the knowledge graph file stored?

The knowledge graph is stored at [`.understand-anything/knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/knowledge-graph.json) relative to your project root. The persistence module in [`understand-anything-plugin/packages/core/src/persistence/index.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/core/src/persistence/index.ts) creates the hidden `.understand-anything/` directory automatically when `saveGraph` is first called, ensuring the path exists before writing the pretty-printed JSON data.

### How do I enable Git LFS for the knowledge graph?

Run `git lfs install` to initialize LFS, then execute `git lfs track ".understand-anything/*.json"` to track all JSON files in the directory. This stores large graph files in LFS rather than the standard Git object store, as recommended in the README.md for graphs exceeding 10 MB.

### Can I load a knowledge graph without re-analyzing the project?

Yes. Use the `loadGraph(projectRoot, { validate: true })` function from `@understand-anything/core/persistence` to retrieve a previously saved graph. This returns the deserialized graph object from [`.understand-anything/knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/.understand-anything/knowledge-graph.json), allowing you to feed it directly to the dashboard or reuse it for incremental analysis without reprocessing the entire codebase.

### What files should I exclude from Git in the .understand-anything directory?

Exclude the `.understand-anything/intermediate/` directory and [`diff-overlay.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/diff-overlay.json) files, as these contain temporary processing artefacts and transient diff data. Commit only the main [`knowledge-graph.json`](https://github.com/Egonex-AI/Understand-Anything/blob/main/knowledge-graph.json) and other persistent auxiliary files, using Git LFS for files larger than 10 MB.