Where Understand Anything Saves Its Knowledge Graph: File Path & Access Guide

Understand Anything persists the assembled knowledge graph to a JSON file at <project-root>/.understand-anything/knowledge-graph.json, managed by the core persistence layer and served via the dashboard HTTP endpoint.

The Egonex-AI/Understand-Anything repository analyzes codebases to build relationship graphs. When processing completes, the resulting knowledge graph must be stored in a consistent location for agents, skills, and the visualization layer to access. This guide documents the exact file path and the mechanisms that read from and write to this canonical storage location.

Default Knowledge Graph Storage Location

The system writes all graph data to a single canonical location. Inside your project root, Understand Anything creates a hidden directory named .understand-anything and stores the serialized graph as knowledge-graph.json.

This path serves as the single source of truth across the entire toolchain. Whether the graph is generated by the main analysis engine, loaded by the visualization dashboard, or created by auxiliary scripts, every component targets <project-root>/.understand-anything/knowledge-graph.json.

Core Persistence Implementation

The persistence logic resides in packages/core/src/persistence/index.ts. This module handles directory creation, path sanitization, and JSON serialization for the knowledge graph location.

Saving the Graph with saveGraph

The saveGraph function ensures the target directory exists before writing. According to the source code in packages/core/src/persistence/index.ts (lines 69-80), the implementation calls ensureDir to create .understand-anything if missing, sanitizes file paths, and writes the serialized graph to knowledge-graph.json.

Loading the Graph with loadGraph

The loadGraph function reads from the same canonical path. Located in the same file (lines 85-104), it opens <project-root>/.understand-anything/knowledge-graph.json and optionally validates the schema before returning the graph object.

If the file does not exist, the function returns null, allowing the calling code to handle initialization or prompt the user to run the /understand command first.

Dashboard HTTP Access

The web-based dashboard serves the graph over HTTP without duplicating the file. In packages/dashboard/vite.config.ts (lines 130-152), a custom middleware intercepts requests to /knowledge-graph.json and streams the contents from the .understand-anything directory on disk.

This approach ensures the dashboard always displays the latest persisted state while maintaining a clean separation between the storage layer and the presentation layer.

Programmatic Access Examples

Load the Graph in Node.js

Use the core persistence API to read the graph programmatically:

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

const projectRoot = "/path/to/your/project";
const graph = loadGraph(projectRoot, { validate: true });

if (graph) {
  console.log(`Graph contains ${graph.nodes.length} nodes`);
} else {
  console.error("No knowledge-graph.json found – run /understand first.");
}

This method reads directly from .understand-anything/knowledge-graph.json as implemented in the persistence layer.

Save a Modified Graph

To persist changes to the knowledge graph:

import { saveGraph } from "@understand-anything/core/persistence";

const modifiedGraph = { /* your KnowledgeGraph object */ };
saveGraph(projectRoot, modifiedGraph);
// File written to .understand-anything/knowledge-graph.json

The saveGraph function handles directory creation and JSON serialization atomically.

Fetch from the Dashboard (Browser)

When the dashboard is running, access the graph via HTTP:

fetch("/knowledge-graph.json")
  .then(r => r.json())
  .then(graph => console.log(`Loaded ${graph.nodes.length} nodes`));

The Vite dev server routes this request to the physical file location, ensuring consistency between the API and the file system.

Summary

  • The knowledge graph is stored at <project-root>/.understand-anything/knowledge-graph.json
  • The saveGraph and loadGraph functions in packages/core/src/persistence/index.ts manage all read/write operations
  • The dashboard serves the file via HTTP middleware defined in packages/dashboard/vite.config.ts
  • Auxiliary scripts like scripts/generate-large-graph.mjs (lines 14-18) also write to this canonical location

Frequently Asked Questions

What is the exact file path for the Understand Anything knowledge graph?

The system writes the graph to a hidden directory at your project root: .understand-anything/knowledge-graph.json. This relative path is consistent across all components, from the core persistence layer to the dashboard server.

How does the dashboard access the knowledge graph without a separate API server?

The dashboard uses a Vite middleware defined in packages/dashboard/vite.config.ts (lines 130-152) to intercept HTTP requests to /knowledge-graph.json and stream the file contents directly from the .understand-anything directory on disk.

Can I manually generate or modify the knowledge-graph.json file?

Yes. The scripts/generate-large-graph.mjs script demonstrates manual generation, writing test data to the same location. However, you should ensure the JSON structure conforms to the expected schema, as the loadGraph function can optionally validate the file against type definitions.

What happens if the .understand-anything directory doesn't exist?

The saveGraph function automatically creates the directory using ensureDir before writing the file. If the directory is missing when loadGraph is called, the function returns null rather than throwing an error, indicating that no graph has been persisted yet.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →