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
| Field | Type | Description |
|---|---|---|
$id | string | Unique identifier |
name | string | Project name (2–100 chars) |
description | string | Optional description (max 500 chars) |
teamId | string | Owning team ID |
visibility | enum | public or private |
status | enum | ACTIVE or ARCHIVED |
aiTier | enum | Optional small or medium model override (all paid plans) |
members | array | Project-level member access |
Context (V1)
| Field | Type | Description |
|---|---|---|
$id | string | Unique identifier |
name | string | Context name (max 100 chars) |
description | string | Optional (max 500 chars) |
content | string | Markdown content (max 50K chars) |
schemaKey | string | Hierarchical path (e.g., root/api/auth) |
tier | number | 1 (always loaded), 2 (on-demand), 3 (archived) |
state | enum | draft, approved, deprecated |
contextType | enum | system, reference, memory |
parentContextId | string | For hierarchy |
Memory Item (V2)
| Field | Type | Description |
|---|---|---|
itemId | string | Unique identifier |
projectId | string | Parent project |
teamId | string | Parent team |
type | enum | Decision, Convention, BugFix, Todo, ArchitectureNote, ImplementationFact, CodeMapNode |
title | string | Item title |
facts | string | Multi-line extracted facts |
rationale | string | Why it matters |
impact | string | What changed |
files | string[] | Related file paths |
schemaKey | string | Brain hierarchy key |
commitRange | string | Git SHA range |
confidence | number | 0.0–1.0 |
status | enum | active, stale, review, superseded, archived |
evidenceRefs | string[] | Links to evidence blobs |
mergedFrom | string[] | Dedup tracking |
dedupHint | string | e.g., decision:auth:jwt |
tags | string[] | Categorization tags |
importance | number | 1–5 scale |
sessionId | string | Source session |
Session
| Field | Type | Description |
|---|---|---|
sessionId | string | Unique identifier |
projectId | string | Parent project |
teamId | string | Parent team |
startedAt | string | ISO timestamp |
endedAt | string | ISO timestamp (null if active) |
headCommitSha | string | Last known git HEAD |
status | enum | active, closed, compacted |
source | enum | mcp-server, cli-auto, cli-scan, vscode, cursor, windsurf, antigravity |
messageCount | number | Events in session |
filesModified | string[] | Files touched |
Raw Event
| Field | Type | Description |
|---|---|---|
$id | string | Unique identifier |
projectId | string | Parent project |
sessionId | string | Parent session |
eventHash | string | SHA-256 for idempotence |
type | enum | mcp_save, vscode_capture, auto_save, scan |
payload | object | Event-specific data |
processed | boolean | Whether enrichment has processed this event |
blobIds | string[] | Uploaded evidence blob IDs |
API Key
| Field | Type | Description |
|---|---|---|
$id | string | Unique identifier |
teamId | string | Parent team |
name | string | Key name |
keyHash | string | SHA-256 hash of the raw key |
keyPrefix | string | First 8 chars for display |
lastUsedAt | string | Last usage timestamp |
Collections (Appwrite)
Core
projects— Project documentsproject_members— Project-level access controlcontexts— V1 context documentscontext_versions— Version historycontext_entries— Journal entries (append-only)context_links— Links between contextsapi_keys— API keys (SHA-256 hashed)activity_log— Activity audit trail
V2 Memory
raw_events— Raw ingestion eventsv2_sessions— Session trackingmemory_items— Enriched memory itemsmemory_embeddings— Semantic search embeddingsproblems— Detected problemsindex_jobs— Background jobs (enrichment, hygiene)
Billing
subscriptions— Stripe subscriptionsusage_rollups— Pre-aggregated usage statscredit_balances— Credit balances per teamcredit_transactions— Credit transaction audit trail