-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchitecture-diagram.html
More file actions
391 lines (337 loc) · 17.4 KB
/
architecture-diagram.html
File metadata and controls
391 lines (337 loc) · 17.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Claude Watch – Architecture Diagram</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: #111; color: #ddd; display: flex; flex-direction: column; min-height: 100vh; }
/* Controls */
.controls { background: #1a1a1a; border-bottom: 1px solid #333; padding: 14px 20px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.controls-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: #666; margin-right: 6px; }
.flow-btn { padding: 6px 12px; font-size: 11px; border: 1px solid #F59E0B; border-radius: 6px; background: transparent; color: #F59E0B; cursor: pointer; }
.flow-btn:hover { background: #F59E0B22; }
.flow-btn.active { background: #F59E0B; color: #111; }
.sep { width: 1px; height: 20px; background: #333; margin: 0 4px; }
.legend { display: flex; gap: 12px; margin-left: auto; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: #888; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
/* Canvas */
.diagram-area { flex: 1; display: flex; align-items: center; justify-content: center; background: #0d0d0d; padding: 20px; }
.diagram-svg { max-width: 960px; width: 100%; height: auto; }
/* SVG styles */
.node-box { fill: #1a1a2e; stroke: #444; stroke-width: 1.5; rx: 8; }
.node-box.external { fill: #1a2e1a; stroke: #4CAF50; }
.node-box.client { fill: #1a1a2e; stroke: #0099FF; }
.node-box.server { fill: #2e2a1a; stroke: #F59E0B; }
.node-label { fill: #eee; font-size: 13px; font-weight: 600; text-anchor: middle; dominant-baseline: central; font-family: system-ui, sans-serif; }
.node-sub { fill: #888; font-size: 9px; text-anchor: middle; dominant-baseline: central; font-family: system-ui, sans-serif; }
.node-icon { font-size: 18px; text-anchor: middle; dominant-baseline: central; }
.edge { fill: none; stroke-width: 1.5; stroke-dasharray: 6 4; opacity: 0.25; }
.edge.http { stroke: #42A5F5; }
.edge.ws { stroke: #66BB6A; }
.edge.ext { stroke: #AB47BC; }
.edge.pipe { stroke: #FF7043; }
.edge.active { opacity: 0.7; stroke-dasharray: none; }
/* Packets */
.packet { r: 5; opacity: 0; }
.packet.http { fill: #42A5F5; }
.packet.ws { fill: #66BB6A; }
.packet.ext { fill: #AB47BC; }
.packet.pipe { fill: #FF7043; }
.packet.active { opacity: 1; }
/* Protocol labels */
.proto-label { fill: #666; font-size: 8px; text-anchor: middle; font-family: 'SF Mono', 'Fira Code', monospace; }
</style>
</head>
<body>
<div class="controls">
<span class="controls-label">Flow</span>
<button class="flow-btn active" onclick="setFlow('idle')">Idle</button>
<button class="flow-btn" onclick="setFlow('voice')">Voice Query</button>
<button class="flow-btn" onclick="setFlow('text')">Text Message</button>
<button class="flow-btn" onclick="setFlow('permission')">Permission</button>
<button class="flow-btn" onclick="setFlow('all')">All Flows</button>
<span class="sep"></span>
<div class="legend">
<div class="legend-item"><div class="legend-dot" style="background:#42A5F5"></div>HTTP</div>
<div class="legend-item"><div class="legend-dot" style="background:#66BB6A"></div>WebSocket</div>
<div class="legend-item"><div class="legend-dot" style="background:#AB47BC"></div>External API</div>
<div class="legend-item"><div class="legend-dot" style="background:#FF7043"></div>stdin/stdout</div>
</div>
</div>
<div class="diagram-area">
<svg class="diagram-svg" viewBox="0 0 920 520" xmlns="http://www.w3.org/2000/svg">
<!-- ====== NODES ====== -->
<!-- Galaxy Watch -->
<rect class="node-box client" x="20" y="60" width="130" height="70"/>
<text class="node-icon" x="85" y="82">⏱</text>
<text class="node-label" x="85" y="102">Galaxy Watch</text>
<text class="node-sub" x="85" y="118">Wear OS</text>
<!-- Companion Phone -->
<rect class="node-box client" x="20" y="200" width="130" height="70"/>
<text class="node-icon" x="85" y="222">📱</text>
<text class="node-label" x="85" y="242">Phone App</text>
<text class="node-sub" x="85" y="258">Android</text>
<!-- Dashboard -->
<rect class="node-box client" x="20" y="340" width="130" height="70"/>
<text class="node-icon" x="85" y="362">💻</text>
<text class="node-label" x="85" y="382">Dashboard</text>
<text class="node-sub" x="85" y="398">Vue.js</text>
<!-- HTTP Server -->
<rect class="node-box server" x="260" y="100" width="150" height="80"/>
<text class="node-label" x="335" y="132">HTTP Server</text>
<text class="node-sub" x="335" y="152">port 5566</text>
<text class="node-sub" x="335" y="166">server.py</text>
<!-- WebSocket Server -->
<rect class="node-box server" x="260" y="260" width="150" height="80"/>
<text class="node-label" x="335" y="292">WebSocket</text>
<text class="node-sub" x="335" y="312">port 5567</text>
<text class="node-sub" x="335" y="326">real-time</text>
<!-- Deepgram -->
<rect class="node-box external" x="510" y="20" width="140" height="70"/>
<text class="node-icon" x="580" y="42">🎤</text>
<text class="node-label" x="580" y="62">Deepgram</text>
<text class="node-sub" x="580" y="78">STT + TTS</text>
<!-- Claude Wrapper -->
<rect class="node-box server" x="510" y="160" width="140" height="80"/>
<text class="node-label" x="580" y="190">Claude</text>
<text class="node-label" x="580" y="206">Wrapper</text>
<text class="node-sub" x="580" y="226">persistent process</text>
<!-- Permission Hook -->
<rect class="node-box server" x="510" y="310" width="140" height="70"/>
<text class="node-label" x="580" y="338">Permission</text>
<text class="node-label" x="580" y="354">Hook</text>
<text class="node-sub" x="580" y="370">tool approval</text>
<!-- Claude Code CLI -->
<rect class="node-box external" x="740" y="140" width="150" height="80"/>
<text class="node-icon" x="815" y="162">🤖</text>
<text class="node-label" x="815" y="182">Claude Code</text>
<text class="node-sub" x="815" y="198">CLI process</text>
<text class="node-sub" x="815" y="212">stream-json</text>
<!-- tmux -->
<rect class="node-box" x="740" y="290" width="150" height="60" style="stroke:#888"/>
<text class="node-label" x="815" y="314">tmux</text>
<text class="node-sub" x="815" y="332">claude-watch</text>
<!-- ====== EDGES ====== -->
<!-- Watch → HTTP Server (audio POST /transcribe) -->
<path id="e-watch-server" class="edge http" d="M150,95 L260,130"/>
<text class="proto-label" x="200" y="102">POST /transcribe</text>
<!-- Phone → HTTP Server (text POST /api/message) -->
<path id="e-phone-server" class="edge http" d="M150,225 L260,155"/>
<text class="proto-label" x="195" y="183">POST /api/message</text>
<!-- Watch ↔ WebSocket -->
<path id="e-watch-ws" class="edge ws" d="M150,115 Q200,200 260,280"/>
<text class="proto-label" x="175" y="198" transform="rotate(-5,175,198)">ws://</text>
<!-- Phone ↔ WebSocket -->
<path id="e-phone-ws" class="edge ws" d="M150,255 L260,290"/>
<text class="proto-label" x="200" y="265">ws://</text>
<!-- Dashboard ↔ WebSocket -->
<path id="e-dash-ws" class="edge ws" d="M150,365 L260,310"/>
<text class="proto-label" x="195" y="345">ws://</text>
<!-- HTTP Server → Deepgram (audio for STT) -->
<path id="e-server-deepgram" class="edge ext" d="M410,120 L510,65"/>
<text class="proto-label" x="460" y="80">HTTPS</text>
<!-- Deepgram → HTTP Server (transcript back) -->
<path id="e-deepgram-server" class="edge ext" d="M510,75 L410,130"/>
<!-- HTTP Server → Claude Wrapper (send prompt) -->
<path id="e-server-claude" class="edge pipe" d="M410,160 L510,190"/>
<text class="proto-label" x="460" y="168">prompt</text>
<!-- Claude Wrapper → HTTP Server (response) -->
<path id="e-claude-server" class="edge pipe" d="M510,180 L410,145"/>
<text class="proto-label" x="460" y="155">response</text>
<!-- HTTP Server ↔ WebSocket (internal broadcast) -->
<path id="e-server-ws" class="edge pipe" d="M335,180 L335,260"/>
<text class="proto-label" x="355" y="222" transform="rotate(90,355,222)">broadcast</text>
<!-- Claude Wrapper ↔ Claude Code CLI (stdin/stdout) -->
<path id="e-claude-cli" class="edge pipe" d="M650,200 L740,180"/>
<text class="proto-label" x="695" y="183">stdin/stdout</text>
<!-- Claude Code → Permission Hook -->
<path id="e-cli-hook" class="edge pipe" d="M780,220 Q700,270 650,320"/>
<text class="proto-label" x="720" y="268">hook call</text>
<!-- Permission Hook → HTTP Server (request approval) -->
<path id="e-hook-server" class="edge http" d="M510,345 L410,165"/>
<text class="proto-label" x="448" y="262">POST /permission</text>
<!-- HTTP Server → Permission Hook (decision) -->
<path id="e-server-hook" class="edge http" d="M400,170 L520,340"/>
<text class="proto-label" x="472" y="280">GET /status</text>
<!-- Claude Wrapper → tmux -->
<path id="e-claude-tmux" class="edge pipe" d="M650,225 Q700,270 740,310"/>
<text class="proto-label" x="710" y="262">tail log</text>
<!-- Deepgram TTS back (server gets audio) -->
<path id="e-deepgram-tts" class="edge ext" d="M580,90 L580,160"/>
<text class="proto-label" x="600" y="128" transform="rotate(90,600,128)">TTS mp3</text>
<!-- ====== PACKETS (animated dots) ====== -->
<circle id="p-watch-server" class="packet http"/>
<circle id="p-phone-server" class="packet http"/>
<circle id="p-server-deepgram" class="packet ext"/>
<circle id="p-deepgram-server" class="packet ext"/>
<circle id="p-server-claude" class="packet pipe"/>
<circle id="p-claude-server" class="packet pipe"/>
<circle id="p-claude-cli" class="packet pipe"/>
<circle id="p-cli-hook" class="packet pipe"/>
<circle id="p-hook-server" class="packet http"/>
<circle id="p-server-hook" class="packet http"/>
<circle id="p-watch-ws" class="packet ws"/>
<circle id="p-phone-ws" class="packet ws"/>
<circle id="p-dash-ws" class="packet ws"/>
<circle id="p-server-ws" class="packet pipe"/>
<circle id="p-deepgram-tts" class="packet ext"/>
<circle id="p-claude-tmux" class="packet pipe"/>
</svg>
</div>
<script>
(function() {
let currentFlow = 'idle';
let animFrame = null;
let startTime = 0;
// Define which edges and packets are active per flow
const flows = {
idle: { edges: [], packets: [] },
voice: {
edges: ['e-watch-server','e-server-deepgram','e-deepgram-server','e-server-claude','e-claude-cli',
'e-claude-server','e-server-ws','e-watch-ws','e-phone-ws','e-dash-ws','e-deepgram-tts','e-claude-tmux'],
packets: [
{ id:'p-watch-server', path:'e-watch-server', delay:0, dur:1.2 },
{ id:'p-server-deepgram', path:'e-server-deepgram', delay:1.2, dur:1.0 },
{ id:'p-deepgram-server', path:'e-deepgram-server', delay:2.4, dur:1.0 },
{ id:'p-server-claude', path:'e-server-claude', delay:3.6, dur:0.8 },
{ id:'p-claude-cli', path:'e-claude-cli', delay:4.4, dur:0.8 },
{ id:'p-claude-server', path:'e-claude-server', delay:6.0, dur:0.8 },
{ id:'p-claude-tmux', path:'e-claude-tmux', delay:5.5, dur:0.6 },
{ id:'p-server-ws', path:'e-server-ws', delay:7.0, dur:0.6 },
{ id:'p-watch-ws', path:'e-watch-ws', delay:7.6, dur:1.0 },
{ id:'p-phone-ws', path:'e-phone-ws', delay:7.6, dur:0.8 },
{ id:'p-dash-ws', path:'e-dash-ws', delay:7.6, dur:0.8 },
{ id:'p-deepgram-tts', path:'e-deepgram-tts', delay:6.8, dur:0.8 },
]
},
text: {
edges: ['e-phone-server','e-server-claude','e-claude-cli','e-claude-server',
'e-server-ws','e-watch-ws','e-phone-ws','e-dash-ws','e-claude-tmux'],
packets: [
{ id:'p-phone-server', path:'e-phone-server', delay:0, dur:1.0 },
{ id:'p-server-claude', path:'e-server-claude', delay:1.2, dur:0.8 },
{ id:'p-claude-cli', path:'e-claude-cli', delay:2.0, dur:0.8 },
{ id:'p-claude-server', path:'e-claude-server', delay:3.5, dur:0.8 },
{ id:'p-claude-tmux', path:'e-claude-tmux', delay:3.0, dur:0.6 },
{ id:'p-server-ws', path:'e-server-ws', delay:4.5, dur:0.6 },
{ id:'p-watch-ws', path:'e-watch-ws', delay:5.2, dur:1.0 },
{ id:'p-phone-ws', path:'e-phone-ws', delay:5.2, dur:0.8 },
{ id:'p-dash-ws', path:'e-dash-ws', delay:5.2, dur:0.8 },
]
},
permission: {
edges: ['e-phone-server','e-server-claude','e-claude-cli','e-cli-hook',
'e-hook-server','e-server-ws','e-phone-ws','e-watch-ws','e-dash-ws',
'e-server-hook','e-claude-server','e-claude-tmux'],
packets: [
{ id:'p-phone-server', path:'e-phone-server', delay:0, dur:1.0 },
{ id:'p-server-claude', path:'e-server-claude', delay:1.2, dur:0.8 },
{ id:'p-claude-cli', path:'e-claude-cli', delay:2.0, dur:0.8 },
{ id:'p-cli-hook', path:'e-cli-hook', delay:3.0, dur:1.0 },
{ id:'p-hook-server', path:'e-hook-server', delay:4.2, dur:1.2 },
{ id:'p-server-ws', path:'e-server-ws', delay:5.4, dur:0.6 },
{ id:'p-phone-ws', path:'e-phone-ws', delay:6.0, dur:0.8 },
{ id:'p-watch-ws', path:'e-watch-ws', delay:6.0, dur:1.0 },
{ id:'p-dash-ws', path:'e-dash-ws', delay:6.0, dur:0.8 },
{ id:'p-server-hook', path:'e-server-hook', delay:7.5, dur:1.2 },
{ id:'p-claude-server', path:'e-claude-server', delay:9.0, dur:0.8 },
{ id:'p-claude-tmux', path:'e-claude-tmux', delay:8.5, dur:0.6 },
]
},
all: {
edges: ['e-watch-server','e-phone-server','e-server-deepgram','e-deepgram-server',
'e-server-claude','e-claude-cli','e-claude-server','e-cli-hook',
'e-hook-server','e-server-hook','e-server-ws','e-watch-ws','e-phone-ws',
'e-dash-ws','e-deepgram-tts','e-claude-tmux'],
packets: [
{ id:'p-watch-server', path:'e-watch-server', delay:0, dur:1.2 },
{ id:'p-phone-server', path:'e-phone-server', delay:0.5, dur:1.0 },
{ id:'p-server-deepgram', path:'e-server-deepgram', delay:1.5, dur:1.0 },
{ id:'p-deepgram-server', path:'e-deepgram-server', delay:2.8, dur:1.0 },
{ id:'p-server-claude', path:'e-server-claude', delay:4.0, dur:0.8 },
{ id:'p-claude-cli', path:'e-claude-cli', delay:4.8, dur:0.8 },
{ id:'p-cli-hook', path:'e-cli-hook', delay:5.8, dur:1.0 },
{ id:'p-hook-server', path:'e-hook-server', delay:7.0, dur:1.2 },
{ id:'p-server-ws', path:'e-server-ws', delay:8.4, dur:0.6 },
{ id:'p-phone-ws', path:'e-phone-ws', delay:9.0, dur:0.8 },
{ id:'p-watch-ws', path:'e-watch-ws', delay:9.0, dur:1.0 },
{ id:'p-dash-ws', path:'e-dash-ws', delay:9.0, dur:0.8 },
{ id:'p-server-hook', path:'e-server-hook', delay:9.5, dur:1.2 },
{ id:'p-claude-server', path:'e-claude-server', delay:11.0, dur:0.8 },
{ id:'p-deepgram-tts', path:'e-deepgram-tts', delay:11.8, dur:0.8 },
{ id:'p-claude-tmux', path:'e-claude-tmux', delay:10.5, dur:0.6 },
]
}
};
function getPathPoints(pathEl) {
// For <path> elements, sample points along the path
const len = pathEl.getTotalLength();
return { el: pathEl, len: len };
}
function lerp(a, b, t) { return a + (b - a) * t; }
function posOnPath(pathInfo, t) {
t = Math.max(0, Math.min(1, t));
const pt = pathInfo.el.getPointAtLength(t * pathInfo.len);
return { x: pt.x, y: pt.y };
}
function animate(timestamp) {
if (!startTime) startTime = timestamp;
const elapsed = (timestamp - startTime) / 1000; // seconds
const flow = flows[currentFlow];
if (!flow || !flow.packets.length) return;
// Calculate total cycle duration
const maxEnd = Math.max(...flow.packets.map(p => p.delay + p.dur));
const cycleDur = maxEnd + 1.5; // pause between loops
const t = elapsed % cycleDur;
flow.packets.forEach(pDef => {
const circle = document.getElementById(pDef.id);
const pathEl = document.getElementById(pDef.path);
if (!circle || !pathEl) return;
const localT = (t - pDef.delay) / pDef.dur;
if (localT < 0 || localT > 1) {
circle.setAttribute('opacity', '0');
return;
}
const pathInfo = getPathPoints(pathEl);
const pos = posOnPath(pathInfo, localT);
circle.setAttribute('cx', pos.x);
circle.setAttribute('cy', pos.y);
circle.setAttribute('opacity', '1');
circle.setAttribute('r', 5);
});
animFrame = requestAnimationFrame(animate);
}
window.setFlow = function(name) {
currentFlow = name;
startTime = 0;
// Update buttons
document.querySelectorAll('.flow-btn').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.flow-btn').forEach(b => {
if (b.textContent.toLowerCase().replace(/\s+/g,'') === name.replace(/\s+/g,'')) b.classList.add('active');
});
// Reset all edges and packets
document.querySelectorAll('.edge').forEach(e => e.classList.remove('active'));
document.querySelectorAll('.packet').forEach(p => p.setAttribute('opacity', '0'));
// Activate edges for this flow
const flow = flows[name];
if (flow) {
flow.edges.forEach(id => {
const el = document.getElementById(id);
if (el) el.classList.add('active');
});
}
// Start/stop animation
if (animFrame) cancelAnimationFrame(animFrame);
if (name !== 'idle' && flow && flow.packets.length) {
animFrame = requestAnimationFrame(animate);
}
};
// Init
setFlow('idle');
})();
</script>
</body>
</html>