Skip to content

Commit 63d72be

Browse files
committed
docs: add 10 Mermaid diagrams across site and project docs
Site docs (6): - ACL resolution chain flowchart (access-control.md) - Password login sequence diagram (authentication.md) - Auth middleware priority flowchart (authentication.md) - Cross-graph proxy node diagram (cross-graph-links.md) - Task status state diagram (tasks.md) - Sequential indexing phases (embeddings.md) Project docs (4): - Architecture overview — replaced ASCII with Mermaid (architecture.md) - Hybrid search pipeline flowchart (search.md) - Three-queue indexer diagram (indexer.md) - Bidirectional watcher sync diagram (watcher.md)
1 parent c5fa0a6 commit 63d72be

9 files changed

Lines changed: 184 additions & 68 deletions

File tree

docs/architecture.md

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,60 @@
22

33
## High-level diagram
44

5-
```
6-
┌──────────────────────────────────────────────────────────────────────┐
7-
│ CLI │
8-
│ src/cli/index.ts (Commander) │
9-
│ │
10-
│ index ──── scan + embed + save + exit │
11-
│ serve ──── HTTP server + MCP + REST API + UI + WebSocket │
12-
│ users ──── user management (add users to config) │
13-
└──────────────────────────┬───────────────────────────────────────────┘
14-
15-
┌──────────────┴──────────────┐
16-
▼ ▼
17-
┌─────────────┐ ┌──────────────────┐
18-
│ YAML Config │ │ ProjectManager │
19-
│ (Zod valid) │ │ (multi-project) │
20-
└──────┬──────┘ └────────┬─────────┘
21-
│ │
22-
▼ ▼
23-
┌──────────────────────────────────────────┐
24-
│ ProjectIndexer │
25-
│ 3 serial queues: docs / code / files │
26-
│ chokidar watcher for live updates │
27-
└──────────────────┬───────────────────────┘
28-
29-
30-
┌──────────────────────────────────────────┐
31-
│ Embedding (transformers.js) │
32-
│ embed() / embedBatch() / loadModel() │
33-
│ named registry + model deduplication │
34-
└──────────────────┬───────────────────────┘
35-
36-
37-
┌──────────────────────────────────────────┐
38-
│ Graphs (Graphology) │
39-
│ │
40-
│ DocGraph ────── markdown chunks │
41-
│ CodeGraph ───── AST symbols │
42-
│ KnowledgeGraph user notes + facts │
43-
│ FileIndexGraph all project files │
44-
│ TaskGraph ───── tasks + kanban │
45-
│ SkillGraph ──── reusable recipes │
46-
└──────────────────┬───────────────────────┘
47-
48-
┌──────────────────┴───────────────────────┐
49-
│ Graph Managers (unified API) │
50-
│ │
51-
│ embed + CRUD + dirty + events │
52-
│ + cross-graph cleanup │
53-
└──────────────────┬───────────────────────┘
54-
55-
┌──────────────┼──────────────┐
56-
▼ ▼ ▼
57-
┌────────┐ ┌──────────┐ ┌──────────┐
58-
│ MCP │ │ REST API │ │ UI │
59-
│ Tools │ │ Express │ │ React │
60-
│ (70) │ │ + WS │ │ + Vite │
61-
└────────┘ └──────────┘ └──────────┘
5+
```mermaid
6+
graph TD
7+
CLI["CLI (commander)"]
8+
Config["YAML Config"]
9+
PM["ProjectManager"]
10+
11+
CLI --> Config
12+
CLI --> PM
13+
14+
subgraph Indexer["ProjectIndexer"]
15+
DQ["docs queue"]
16+
CQ["code queue"]
17+
FQ["files queue"]
18+
end
19+
20+
PM --> Indexer
21+
22+
subgraph Embed["Embedding Layer"]
23+
ONNX["ONNX Runtime"]
24+
Models["bge-m3 / jina-code"]
25+
end
26+
27+
Indexer --> Embed
28+
29+
subgraph Graphs
30+
DocG["DocGraph"]
31+
CodeG["CodeGraph"]
32+
KG["KnowledgeGraph"]
33+
TG["TaskGraph"]
34+
SG["SkillGraph"]
35+
FIG["FileIndexGraph"]
36+
end
37+
38+
Embed --> Graphs
39+
40+
subgraph Managers["Graph Managers"]
41+
DM["DocGraphManager"]
42+
CM["CodeGraphManager"]
43+
KM["KnowledgeGraphManager"]
44+
TM["TaskGraphManager"]
45+
SM["SkillGraphManager"]
46+
FM["FileIndexGraphManager"]
47+
end
48+
49+
Graphs --> Managers
50+
51+
subgraph API["API Layer"]
52+
MCP["MCP Tools (70)"]
53+
REST["REST Routes"]
54+
WS["WebSocket"]
55+
UI["Web UI"]
56+
end
57+
58+
Managers --> API
6259
```
6360

6461
## Layers

docs/indexer.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ The indexer (`src/cli/indexer.ts`) walks the project directory and dispatches fi
44

55
## Architecture
66

7-
```
8-
File detected (scan or watch event)
9-
↓ micromatch pattern matching
10-
11-
┌────────────────┬────────────────┬────────────────┐
12-
│ docsQueue │ codeQueue │ fileQueue │
13-
│ │ │ │
14-
│ parseFile() │ parseCodeFile()│ fs.stat() │
15-
│ embedBatch() │ embedBatch() │ embed() │
16-
│ updateFile() │ updateCodeFile │ updateFileEntry │
17-
└────────────────┴────────────────┴────────────────┘
7+
```mermaid
8+
flowchart TD
9+
FILE[File detected] --> MATCH{Pattern matching}
10+
MATCH -->|docs patterns| DQ[Docs Queue]
11+
MATCH -->|code patterns| CQ[Code Queue]
12+
MATCH -->|all files| FQ[File Index Queue]
13+
14+
DQ --> DP[parseFile + embedBatch]
15+
CQ --> CP[parseCodeFile + embedBatch]
16+
FQ --> FP[fs.stat + embed]
17+
18+
DP --> DG[Update DocGraph]
19+
CP --> CG[Update CodeGraph]
20+
FP --> FG[Update FileIndexGraph]
1821
```
1922

2023
## Three-phase sequential indexing

docs/search.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ All graph searches use the same hybrid algorithm combining BM25 keyword search a
66

77
## Hybrid search algorithm
88

9+
```mermaid
10+
flowchart TD
11+
Q[Search query] --> E[Compute query embedding]
12+
E --> P{Score all nodes}
13+
P --> BM25[BM25 keyword score]
14+
P --> VEC[Vector cosine similarity]
15+
BM25 --> RRF[Reciprocal Rank Fusion]
16+
VEC --> RRF
17+
RRF --> SEED[Select top seeds]
18+
SEED --> BFS[BFS graph expansion]
19+
BFS --> MERGE[Merge & deduplicate]
20+
MERGE --> FILTER[Filter by minScore]
21+
FILTER --> RESULT[Return top maxResults]
22+
```
23+
924
### Step 1: Score all nodes
1025

1126
Two scoring methods run in parallel:

docs/watcher.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@ Updated description from IDE...
8989

9090
The watcher detects the change, parses the file, updates the TaskGraph, and the change appears in the web UI via WebSocket push.
9191

92+
## Bidirectional sync overview
93+
94+
```mermaid
95+
flowchart LR
96+
subgraph ProjectWatcher["Project Watcher"]
97+
PW[chokidar watches projectDir]
98+
PW --> PD[Dispatch to docs/code/file queues]
99+
end
100+
101+
subgraph MirrorWatcher["Mirror Watcher"]
102+
MW[chokidar watches .notes/.tasks/.skills]
103+
MW --> MC{Our write?}
104+
MC -->|Yes, skip| SKIP[MirrorWriteTracker match]
105+
MC -->|No, external| IMP[Import to graph]
106+
end
107+
108+
Graph <-->|mirror write| ProjectWatcher
109+
Graph <-->|import| MirrorWatcher
110+
```
111+
92112
## Real-time flow
93113

94114
```

site/docs/concepts/cross-graph-links.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ notes_create_link({
2727

2828
This creates a proxy node `@code::src/lib/auth.ts::loginUser` in the Knowledge graph, with an edge from your note to that proxy.
2929

30+
```mermaid
31+
graph LR
32+
subgraph KnowledgeGraph
33+
Note["note: auth-notes"]
34+
Proxy["proxy: @code::loginUser"]
35+
end
36+
subgraph CodeGraph
37+
Symbol["symbol: loginUser()"]
38+
end
39+
Note -->|references| Proxy
40+
Proxy -.->|resolves to| Symbol
41+
```
42+
3043
## Proxy node format
3144

3245
Proxy IDs follow the pattern `@{graph}::{nodeId}`:

site/docs/concepts/embeddings.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ Additionally, ONNX Runtime session options are tuned to reduce memory overhead d
127127

128128
During initial indexing, Graph Memory processes graphs in a fixed order: **docs → files → code**. Each phase completes before the next begins. Because models are loaded lazily, this means only one embedding model is resident in memory at a time during indexing.
129129

130+
```mermaid
131+
graph LR
132+
subgraph Phase1["Phase 1: Docs"]
133+
D1[Scan docs] --> D2[Embed with bge-m3]
134+
D2 --> D3[Drain queue]
135+
end
136+
subgraph Phase2["Phase 2: Files"]
137+
F1[Scan files] --> F2[Embed with bge-m3]
138+
F2 --> F3[Drain queue]
139+
end
140+
subgraph Phase3["Phase 3: Code"]
141+
C1[Scan code] --> C2[Embed with jina-code]
142+
C2 --> C3[Drain queue]
143+
end
144+
Phase1 --> Phase2 --> Phase3
145+
```
146+
130147
For multi-project setups where each project has its own model configuration, this reduces peak memory by up to **~3 GB** compared to loading all models simultaneously. Projects are indexed sequentially as well, so the memory footprint stays flat regardless of how many projects are configured.
131148

132149
:::tip

site/docs/concepts/tasks.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ backlog → todo → in_progress → review → done
4545
→ cancelled
4646
```
4747

48+
```mermaid
49+
stateDiagram-v2
50+
[*] --> backlog: create (default)
51+
backlog --> todo: prioritize
52+
todo --> in_progress: start work
53+
in_progress --> review: submit
54+
review --> done: approve
55+
review --> in_progress: request changes
56+
backlog --> cancelled: won't do
57+
todo --> cancelled: skip
58+
in_progress --> cancelled: abandon
59+
done --> [*]
60+
cancelled --> [*]
61+
```
62+
4863
| Status | Meaning |
4964
|--------|---------|
5065
| `backlog` | Identified but not prioritized yet |

site/docs/security/access-control.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ When a user accesses a graph, their effective permission is resolved through a 5
3232
5. server.defaultAccess ← fallback
3333
```
3434

35+
```mermaid
36+
flowchart TD
37+
A[Request access to graph] --> B{graph.access[userId]?}
38+
B -->|found| R1[Return permission]
39+
B -->|not found| C{project.access[userId]?}
40+
C -->|found| R2[Return permission]
41+
C -->|not found| D{workspace.access[userId]?}
42+
D -->|found| R3[Return permission]
43+
D -->|not found| E{server.access[userId]?}
44+
E -->|found| R4[Return permission]
45+
E -->|not found| F[Return server.defaultAccess]
46+
```
47+
3548
This means you can set a broad default and override it at any level.
3649

3750
## Default behavior

site/docs/security/authentication.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ When you open the UI with authentication enabled, you see a login page.
5858
3. On success, the server sets two **httpOnly cookies** containing JWT tokens
5959
4. The UI loads and you have full access according to your permissions
6060
61+
```mermaid
62+
sequenceDiagram
63+
participant U as User
64+
participant UI as Web UI
65+
participant S as Server
66+
U->>UI: Enter email + password
67+
UI->>S: POST /api/auth/login
68+
S->>S: Resolve user, verify scrypt hash
69+
S->>S: Sign JWT (access 15m + refresh 7d)
70+
S-->>UI: Set httpOnly cookies
71+
UI-->>U: App loads (AuthGate passes)
72+
```
73+
6174
### JWT tokens
6275
6376
Two tokens are issued as secure cookies:
@@ -239,6 +252,16 @@ When a request arrives, the server checks credentials in this order:
239252
2. **Bearer token** -- check the `Authorization: Bearer` header; accepts both API keys (`mgm-...`) and OAuth access tokens (JWT type `oauth_access`)
240253
3. **Anonymous** -- if neither is present, the request uses `server.defaultAccess` permissions
241254

255+
```mermaid
256+
flowchart TD
257+
R[Incoming request] --> J{JWT cookie present?}
258+
J -->|valid| ID1[Use JWT identity]
259+
J -->|missing/invalid| B{Bearer token?}
260+
B -->|API key| ID2[Use API key identity]
261+
B -->|OAuth token| ID3[Use OAuth identity]
262+
B -->|none| ANON[Anonymous — use defaultAccess]
263+
```
264+
242265
The first successful match determines the user identity for the request.
243266

244267
Note: OAuth refresh tokens (type `oauth_refresh`) are only accepted at `POST /api/oauth/token`. They cannot be used as Bearer tokens for API or MCP requests.

0 commit comments

Comments
 (0)