ExcaliBrain
repository·master·Indexed 21 days ago
https://github.com/zsviczian/excalibrainAn Obsidian plugin that creates an interactive, structured mind-map of a vault by interpreting links, Dataview fields, and metadata. It uses a spatial logic to map relationships—such as Parents, Children, Friends, and Siblings—to specific cardinal directions. ExcaliBrain requires the Dataview and Excalidraw plugins to function and supports both inferred relationships from standard links and explicit relationships defined via a customizable ontology of metadata fields.
What's inside excalibrain
- ExcaliBrain is an interactive, structured mind-map for Obsidian vaults. It generates a visual map of your notes by interpreting folders, files, links, Dataview fields, tags, and YAML front matter. It is inspired by TheBrain and Breadcrumbs.
Manage Ghost Nodes (Unresolved Links)
masterGhost nodes represent links to files that do not yet exist. They allow you to visualize your intended knowledge structure before you create the actual files.
Key Characteristics
- Identification: They appear as "Virtual" nodes in the graph.
- Styling: By default, they are styled with a semi-transparent red background and a hatched (
hachure) fill. - Lifecycle: A ghost node is automatically replaced by a real file when that file is created. If the last reference to a ghost node is deleted, the node is removed from the index.
Configuration
- Visibility: You can toggle the visibility of these nodes in the settings via
settings.showVirtualNodes.
Understand the ExcaliBrain Relationship System
masterExcaliBrain classifies relationships between notes using a combination of Defined and Inferred states.
- DEFINED: A relationship explicitly created via an ontology field (e.g.,
parent:: [[Note]]). - INFERRED: A relationship derived from standard Obsidian links without explicit fields.
Relationship Types
- Parent/Child: Hierarchical relationships.
- Left/Right Friend: Lateral or opposing connections.
- Previous/Next Friend: Sequential connections.
Relationship Logic Rules
- Precedence:
DEFINEDrelationships always take precedence overINFERREDones. If a relationship is already defined, it cannot be downgraded to inferred. - Direction Merging: If a relationship is established in both directions (e.g.,
TOandFROM), it merges into aBOTHdirection. - Friendship Inference: If both a parent and child relationship are inferred between two notes, they are treated as lateral
Left Friends.
- DEFINED: A relationship explicitly created via an ontology field (e.g.,
Performance and optimization strategies in ExcaliBrain
masterTo maintain performance within Obsidian, ExcaliBrain employs several optimization techniques:
- Lazy evaluation: Dataview (DV) fields are only parsed when a page is actually viewed (tracked via the
dvIndexReadyflag). - Neighbor filtering: Filters are applied during the retrieval phase rather than at the storage phase to keep the index lightweight.
- Link deduplication: Uses map-based storage to prevent duplicate links.
- Case-sensitivity handling: Uses lowercase map lookups to ensure cross-platform consistency.
- Debounced rendering: Rapid successive changes are coalesced into a single render cycle to prevent UI lag.
- Lazy evaluation: Dataview (DV) fields are only parsed when a page is actually viewed (tracked via the
Understand HTTP Link Parsing
masterExcaliBrain indexes all HTTP(S) links within your vault to create a hierarchical view of web references.
How it works
- Extraction: The
URLParserscans markdown files using regex to find links like[label](https://example.com)or direct URLs. - Node Creation:
- Each unique URL becomes a
Pagenode. - Each unique URL origin (protocol + domain) becomes an origin node.
- URLs are linked as children of their respective origins, enabling hierarchical browsing of web references.
- Each unique URL becomes a
- Syncing: The parser automatically updates the index when files are created, modified, or deleted via vault event listeners.
- Extraction: The
How ExcaliBrain reconciles relationship types
masterExcaliBrain unifies different types of connections into a single
Relationstructure. This allows you to query and filter the graph using a consistent interface regardless of how the connection was formed. The plugin reconciles the following:- File hierarchy: Based on folder structures.
- Tag hierarchy: Based on the tag-tree.
- Explicit ontology: Defined via Dataview fields.
- Inferred links: Standard Obsidian links.
- HTTP links: Parsed via
URLParserand treated as inferred links.
ExcaliBrain Architecture Overview
masterExcaliBrain is built as a visualization layer on top of Obsidian's metadata cache and the Dataview plugin. The architecture is divided into three tiers:
- Index Tier (
Pagesclass): Maintains a centralized graph ofPageobjects representing all indexable content. - Relationship Tier (
Pageclass): Manages neighbor relationships and applies transformation logic to determine roles (parent, child, friend, etc.). - Visualization Tier (
Scene,Node,Linkclasses): Renders the graph using the Excalidraw API with customizable styling.
Core Dependencies:
- Obsidian API: File system, metadata cache, and workspace management.
- DataView Plugin: Parses YAML/inline frontmatter for explicit relationship definitions.
- Excalidraw Plugin: The rendering engine for shape management and API integration.
- Index Tier (
Use Tag-Based Styling for Nodes
masterNodes can be styled based on their tags. The plugin identifies a
primaryTag(defined bysettings.primaryTagField, defaulting to "Note type") to determine the base style.- Primary Tag: Determines the main style from
settings.tagNodeStyles. - Additional Tags: If
settings.displayAllStylePrefixesis enabled, prefixes from other tags are appended to the primary tag's prefix.
This allows you to visually distinguish different types of notes (e.g., Projects vs. Tasks) using specific colors or icons automatically.
- Primary Tag: Determines the main style from
How ExcaliBrain relationship types work
masterExcaliBrain distinguishes 5 types of relationships between notes. These are derived using specific logic:
Relationship Types
- Children
- Parents
- Friends
- Other Friends (lateral relationships on the right side)
- Siblings
Derivation Logic
- Explicitly defined: Relationships specified via Dataview fields (e.g.,
Author:: [[Isaac Asimov]]). - Inferred (Links):
- Forward-link: Inferred as a child.
- Backlink: Inferred as a parent.
- Mutual links: If files link to each other, they are friends.
- Children of parents: These are considered siblings.
Understand the Index Creation and Maintenance Process
masterThe
createIndex()method builds the graph in three distinct phases:- Phase 1: Structural Foundation: Waits for Dataview and URLParser, then adds host origins, the file system structure (folders and markdown files), and the tag hierarchy.
- Phase 2: Relationship Population: Adds unresolved links (ghost nodes), resolved links (standard wiki/markdown links), and HTTP links via
addPageURLs(). - Phase 3: Metadata Enrichment: Loads starred/bookmarked files as home entry points and caches lowercase paths for case-sensitivity handling.
Index Maintenance: The index is reactive and updates via:
- Vault Events:
create,modify,delete, andrenameevents trigger updates or re-renders. - Dataview Index Changes: The plugin polls
DVAPI.index.importer.reloadQueueto detect metadata changes. - Manual Updates: Calling
Scene.reRender(updateIndex: true)forces a complete rebuild.
Understand the ExcaliBrain Graph Display Logic
masterExcaliBrain uses a centralized spatial logic to represent a 'Thought' (the currently focused note) in a structured map. Relationships are mapped to specific cardinal directions to provide spatial orientation:
- Parents (North): Broader categories or origins of the central idea.
- Children (South): Sub-topics, examples, or instances derived from the center.
- Friends (West/Left): Lateral connections representing similar or supporting ideas.
- Next/Competing (East/Right): Sequential steps or ideas that challenge/supercharge the concept.
- Siblings (Periphery): Other children of the current node's parents.
Transform Markdown Notes into a Graph
masterExcaliBrain converts an Obsidian vault into a graph using three data sources:
- Inferred Relationships: Automatically derived from standard Obsidian links.
- Forward link: Inferred as a child.
- Backlink: Inferred as a parent.
- Mutual links: Inferred as friends.
- Explicit Relationships (Ontology): Defined via Dataview fields (e.g.,
author::,inspired_by::,supports::). This allows you to create a formal 'link ontology' where specific metadata fields dictate exactly where a node appears on the graph. - Virtual Nodes: 'Ghost' nodes representing unresolved links (links to files that do not yet exist), allowing you to visualize the future structure of your vault.
- Inferred Relationships: Automatically derived from standard Obsidian links.