Skip to content

Entity Relationship Diagram

mermaid
erDiagram
    TEAM ||--o{ PROJECT : owns
    TEAM ||--o{ TEAM_MEMBER : has
    USER ||--o{ TEAM_MEMBER : belongs_to
    PROJECT ||--o{ CONTEXT : contains
    PROJECT ||--o{ SESSION : tracks
    PROJECT ||--o{ API_KEY : has
    PROJECT ||--o{ RAW_EVENT : receives
    PROJECT ||--o{ MEMORY_ITEM : stores
    SESSION ||--o{ RAW_EVENT : groups
    SESSION ||--o{ INDEX_JOB : triggers
    CONTEXT ||--o{ CONTEXT_ENTRY : has
    CONTEXT ||--o{ CONTEXT_LINK : from
    CONTEXT ||--o{ CONTEXT_LINK : to
    MEMORY_ITEM ||--o{ MEMORY_EMBEDDING : has

Core Entities

Project

FieldTypeDescription
$idstringUnique identifier
namestringProject name (2–100 chars)
descriptionstringOptional description (max 500 chars)
teamIdstringOwning team ID
visibilityenumpublic or private
statusenumACTIVE or ARCHIVED
aiTierenumOptional small or medium model override (all paid plans)
membersarrayProject-level member access

Context (V1)

FieldTypeDescription
$idstringUnique identifier
namestringContext name (max 100 chars)
descriptionstringOptional (max 500 chars)
contentstringMarkdown content (max 50K chars)
schemaKeystringHierarchical path (e.g., root/api/auth)
tiernumber1 (always loaded), 2 (on-demand), 3 (archived)
stateenumdraft, approved, deprecated
contextTypeenumsystem, reference, memory
parentContextIdstringFor hierarchy

Memory Item (V2)

FieldTypeDescription
itemIdstringUnique identifier
projectIdstringParent project
teamIdstringParent team
typeenumDecision, Convention, BugFix, Todo, ArchitectureNote, ImplementationFact, CodeMapNode
titlestringItem title
factsstringMulti-line extracted facts
rationalestringWhy it matters
impactstringWhat changed
filesstring[]Related file paths
schemaKeystringBrain hierarchy key
commitRangestringGit SHA range
confidencenumber0.0–1.0
statusenumactive, stale, review, superseded, archived
evidenceRefsstring[]Links to evidence blobs
mergedFromstring[]Dedup tracking
dedupHintstringe.g., decision:auth:jwt
tagsstring[]Categorization tags
importancenumber1–5 scale
sessionIdstringSource session

Session

FieldTypeDescription
sessionIdstringUnique identifier
projectIdstringParent project
teamIdstringParent team
startedAtstringISO timestamp
endedAtstringISO timestamp (null if active)
headCommitShastringLast known git HEAD
statusenumactive, closed, compacted
sourceenummcp-server, cli-auto, cli-scan, vscode, cursor, windsurf, antigravity
messageCountnumberEvents in session
filesModifiedstring[]Files touched

Raw Event

FieldTypeDescription
$idstringUnique identifier
projectIdstringParent project
sessionIdstringParent session
eventHashstringSHA-256 for idempotence
typeenummcp_save, vscode_capture, auto_save, scan
payloadobjectEvent-specific data
processedbooleanWhether enrichment has processed this event
blobIdsstring[]Uploaded evidence blob IDs

API Key

FieldTypeDescription
$idstringUnique identifier
teamIdstringParent team
namestringKey name
keyHashstringSHA-256 hash of the raw key
keyPrefixstringFirst 8 chars for display
lastUsedAtstringLast usage timestamp

Collections (Appwrite)

Core

  • projects — Project documents
  • project_members — Project-level access control
  • contexts — V1 context documents
  • context_versions — Version history
  • context_entries — Journal entries (append-only)
  • context_links — Links between contexts
  • api_keys — API keys (SHA-256 hashed)
  • activity_log — Activity audit trail

V2 Memory

  • raw_events — Raw ingestion events
  • v2_sessions — Session tracking
  • memory_items — Enriched memory items
  • memory_embeddings — Semantic search embeddings
  • problems — Detected problems
  • index_jobs — Background jobs (enrichment, hygiene)

Billing

  • subscriptions — Stripe subscriptions
  • usage_rollups — Pre-aggregated usage stats
  • credit_balances — Credit balances per team
  • credit_transactions — Credit transaction audit trail