Skip to main content

Database Schema

Project Nexus uses Supabase (PostgreSQL) with the pgvector extension. Row Level Security (RLS) is enabled on every table.

The full initialisation script is at supabase_setup.sql in the project root. Incremental migrations are in supabase/migrations/.


Tables​

users​

Extends Supabase Auth users. Automatically created on signup via a trigger.

ColumnTypeDescription
iduuidPrimary key. References auth.users(id).
emailtextUser's email address.
tiertextSubscription tier: free, cloud, or pro. Default: free.

RLS: Users can only read and update their own row.


nodes​

The primary content table. Each row is a captured article or video.

ColumnTypeDescription
iduuidPrimary key.
user_iduuidOwner. References users(id).
urltextSource URL.
titletextPage title.
summarytextAI-generated summary.
raw_texttextThe original scraped text. Loaded lazily.
embeddingvector(1536)Text embedding for semantic search.
is_bookmarkedbooleanBookmark status. Partial index for fast filtering. Default: false.
created_attimestamptzCapture timestamp.

RLS: Users can read, insert, update, and delete only their own nodes.


entities​

AI-extracted concepts, people, and tools from captured nodes.

ColumnTypeDescription
iduuidPrimary key.
user_iduuidOwner.
node_iduuidParent node. Cascade deletes on node deletion.
nametextEntity name (e.g., "React", "Dan Abramov").
typetextEntity type: person, concept, or tool.

RLS: Users can manage only their own entities.


edges​

Relationships between nodes. Can be AI-generated (vector similarity) or manually created.

ColumnTypeDescription
iduuidPrimary key.
source_iduuidSource node. Cascade deletes on node deletion.
target_iduuidTarget node. Cascade deletes on node deletion.
user_iduuidOwner.
relation_typetextType of relationship (e.g., semantic_similarity, manual).
weightfloatEdge weight / similarity score. Default: 1.0.
is_manualbooleantrue for user-created edges. Default: false.
labeltextOptional display label for the edge.

Constraint: Unique index on (source_id, target_id, user_id) prevents duplicate edges. RLS: Users can manage only their own edges.


reviews​

Spaced repetition tracking for each node.

ColumnTypeDescription
iduuidPrimary key.
user_iduuidOwner.
node_iduuidThe node being reviewed.
next_review_datedateWhen this node is next due for review.
intervalintegerCurrent interval in days.
ease_factornumericSM-2 ease factor. Default: 2.5.

RLS: Users can manage only their own review records.


tags​

User-defined labels for categorizing nodes, with color support.

ColumnTypeDescription
iduuidPrimary key.
user_iduuidOwner.
nametextTag name. Unique constraint on (user_id, name).
colortextUI color for the tag.

RLS: Users can manage only their own tags.


node_tags​

Join table between nodes and tags.

ColumnTypeDescription
node_iduuidReferences nodes(id). Cascade deletes.
tag_iduuidReferences tags(id). Cascade deletes.

Primary Key: (node_id, tag_id) RLS: Managed through RLS linking nodes and tags.


highlights​

User text passages and annotations saved from node content.

ColumnTypeDescription
iduuidPrimary key.
node_iduuidParent node. Cascade deletes on node deletion.
user_iduuidOwner.
texttextThe highlighted text passage.
colortextColor-coding for the highlight.
notetextOptional user notes associated with the highlight.

RLS: Users can manage only their own highlights.


collections​

User-defined named groups for organising nodes.

ColumnTypeDescription
iduuidPrimary key.
user_iduuidOwner.
nametextCollection name.
colortextOptional display colour.
created_attimestamptzCreation timestamp.

RLS: Users can manage only their own collections.


node_collections​

Many-to-many join table between nodes and collections.

ColumnTypeDescription
node_iduuidReferences nodes(id). Cascade deletes.
collection_iduuidReferences collections(id). Cascade deletes.
created_attimestamptzWhen the node was added to the collection.

Primary Key: (node_id, collection_id) RLS: A user can manage a node_collection row if they own the referenced collection.


consolidations​

AI-generated knowledge insights synthesised from multiple nodes by the Memory Agent.

ColumnTypeDescription
iduuidPrimary key.
user_iduuidOwner.
source_node_idsuuid[]Array of node IDs that contributed to this insight.
summarytextProse summary of the consolidated knowledge.
insighttextThe AI's specific cross-cutting observation.
themestext[]Array of topic tags. Default: {}.
created_attimestamptzCreation timestamp.

Indexes: consolidations_user_id_idx, consolidations_created_at_idx RLS: Users can select, insert, and delete only their own consolidations.


Functions​

search_nodes_hybrid(query_text, query_embedding, match_count, user_id)​

Performs a hybrid search combining full-text search and vector similarity on the nodes table.

Defined in supabase/migrations/20240306232702_search_nodes_hybrid.sql.


Migrations​

Migration FileDescription
20240101000000_init.sqlInitial schema (nodes, entities, edges, reviews, users).
20240306232702_search_nodes_hybrid.sqlHybrid search function.
20260304164808_fix_auth_users.sqlAuth user schema fixes.
20260305000000_add_performance_indexes.sqlPerformance indexes on nodes and edges.
20260306000000_add_manual_edges.sqlis_manual and label columns on edges.
20260307000000_add_collections.sqlcollections and node_collections tables.
20260308000000_add_consolidations.sqlconsolidations table for Memory Agent.