Table of Contents

Relations & Dependencies

Relations are the core concept that makes CodeDB more than a simple editor. They let you define typed connections between files, creating a knowledge graph of your codebase.

What Are Relations?

A relation connects a source file to a target file with a type. For example:

Adding Relations

There are several ways to add a relation:

From the Relations Panel

  1. Open a file in the editor
  2. Open the bottom panel (⌘J) and click the Relations tab
  3. The panel shows two sections: Dependencies (outgoing) and Links & Tags (incoming)
  4. Use the controls to add a new relation

From the Context Menu

  1. Right-click a file in the sidebar
  2. Select Add Relation
  3. Choose the target file and relation type

From the Command Palette

  1. Press ⌘R to quickly add a relation from the current file

Relation Types

You can use any relation type string. Common types include:

Viewing Relations

The Relations panel at the bottom of the editor shows all connections for the active file:

Each relation shows the connected file name, relation type, and can be clicked to navigate to that file.

Relation Metadata

Relations can store optional metadata as key-value pairs. This is useful for adding context like version constraints, notes, or categories to a relationship.

Database Schema

Relations are stored in the relations table:

CREATE TABLE relations (
  id INTEGER PRIMARY KEY,
  source_id INTEGER REFERENCES files(id),
  target_id INTEGER REFERENCES files(id),
  relation_type TEXT NOT NULL,
  metadata TEXT
);

You can query relations directly in the Query Console.