-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeSpace.html
More file actions
1682 lines (1488 loc) · 87 KB
/
Copy pathCodeSpace.html
File metadata and controls
1682 lines (1488 loc) · 87 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>codeSpace — Engineering Documentation</title>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Fraunces:ital,wght@0,300;0,600;0,700;0,900;1,300&family=DM+Sans:wght@300;400;500&display=swap" rel="stylesheet">
<style>
:root {
--ink: #0E0F14;
--paper: #F5F2EB;
--paper2: #EDE9DF;
--paper3: #E4DFD3;
--rule: #D4CEBC;
--muted: #6B6455;
--accent: #C84B1F;
--accent2: #1A6B4A;
--accent3: #1B4587;
--gold: #B8860B;
--code-bg: #1A1C24;
--code-text: #E2DCCC;
--flag-c: #5BA4CF;
--val-c: #F4A261;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: var(--paper);
color: var(--ink);
font-family: 'DM Sans', sans-serif;
font-size: 14.5px;
line-height: 1.7;
-webkit-font-smoothing: antialiased;
}
.layout { display: flex; min-height: 100vh; }
/* ─── Sidebar ─────────────────────────────────────── */
nav {
width: 260px;
flex-shrink: 0;
background: var(--ink);
position: sticky;
top: 0;
height: 100vh;
overflow-y: auto;
padding: 32px 0 40px;
}
.nav-brand { padding: 0 24px 28px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 24px; }
.nav-brand .logo {
font-family: 'Fraunces', serif;
font-size: 18px;
font-weight: 700;
color: white;
margin-bottom: 4px;
}
.nav-brand .logo span { color: var(--accent); }
.nav-brand .sub {
font-family: 'IBM Plex Mono', monospace;
font-size: 10px;
color: rgba(255,255,255,0.35);
letter-spacing: 0.06em;
}
.nav-group-label {
font-family: 'IBM Plex Mono', monospace;
font-size: 9px;
color: rgba(255,255,255,0.25);
letter-spacing: 0.12em;
text-transform: uppercase;
padding: 16px 24px 8px;
}
nav a {
display: flex;
align-items: center;
gap: 12px;
padding: 9px 24px;
text-decoration: none;
color: rgba(255,255,255,0.5);
font-family: 'DM Sans', sans-serif;
font-size: 12.5px;
border-left: 2px solid transparent;
transition: all 0.15s ease;
}
nav a:hover { color: white; background: rgba(255,255,255,0.04); }
nav a.active { color: white; border-left-color: var(--accent); background: rgba(200,75,31,0.08); }
nav a:hover .nav-num, nav a.active .nav-num { background: var(--accent); color: white; }
.nav-num {
display: inline-flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
background: rgba(255,255,255,0.08);
border-radius: 4px;
font-family: 'IBM Plex Mono', monospace;
font-size: 9px;
transition: all 0.15s ease;
}
/* ─── Main ────────────────────────────────────────── */
main {
flex: 1;
max-width: calc(99% - 256px);
padding: 56px 56px 80px;
}
/* ─── Hero ────────────────────────────────────────── */
.hero { margin-bottom: 64px; padding-bottom: 40px; border-bottom: 1px solid var(--rule); }
.hero-eyebrow {
font-family: 'IBM Plex Mono', monospace;
font-size: 11px;
color: var(--accent);
text-transform: uppercase;
letter-spacing: 0.12em;
margin-bottom: 16px;
}
.hero h1 {
font-family: 'Fraunces', serif;
font-size: clamp(36px, 5vw, 58px);
font-weight: 900;
line-height: 1.05;
letter-spacing: -0.02em;
color: var(--ink);
margin-bottom: 20px;
}
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 900; }
.hero-desc {
font-size: 16px;
color: var(--muted);
max-width: 620px;
line-height: 1.65;
margin-bottom: 24px;
}
.hero-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-tag {
font-family: 'IBM Plex Mono', monospace;
font-size: 11px;
color: var(--muted);
border: 1px solid var(--rule);
padding: 4px 10px;
border-radius: 999px;
}
/* ─── Section ─────────────────────────────────────── */
.section {
margin-bottom: 72px;
animation: fadeUp 0.4s ease both;
}
@keyframes fadeUp {
from { opacity: 0; transform: translateY(16px); }
to { opacity: 1; transform: translateY(0); }
}
.section-header {
display: flex;
align-items: flex-start;
gap: 20px;
margin-bottom: 28px;
}
.section-num-big {
font-family: 'Fraunces', serif;
font-size: 48px;
font-weight: 900;
color: var(--rule);
user-select: none;
line-height: 1;
}
.section-title-block { flex: 1; }
.section-title {
font-family: 'Fraunces', serif;
font-size: 26px;
font-weight: 700;
color: var(--ink);
line-height: 1.2;
margin-bottom: 4px;
}
.section-subtitle {
font-size: 13px;
color: var(--muted);
}
h3 {
font-family: 'Fraunces', serif;
font-size: 18px;
font-weight: 600;
color: var(--ink);
margin: 28px 0 12px;
}
h4 {
font-family: 'IBM Plex Mono', monospace;
font-size: 12px;
font-weight: 400;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.08em;
margin: 20px 0 10px;
}
p { color: #2A2720; margin-bottom: 12px; }
strong { font-weight: 500; color: var(--ink); }
code {
font-family: 'IBM Plex Mono', monospace;
font-size: 12px;
color: var(--accent);
background: var(--paper3);
border: 1px solid var(--rule);
padding: 1px 5px;
border-radius: 4px;
}
ul, ol { margin: 0 0 12px 22px; }
li { color: #2A2720; margin-bottom: 6px; }
/* ─── Components ──────────────────────────────────── */
.concept {
background: var(--paper2);
border-left: 3px solid var(--accent3);
border-radius: 0 8px 8px 0;
padding: 16px 20px;
margin: 16px 0;
}
.concept-label {
font-family: 'IBM Plex Mono', monospace;
font-size: 9px;
color: var(--accent3);
text-transform: uppercase;
letter-spacing: 0.12em;
margin-bottom: 6px;
}
.concept p { font-size: 14px; line-height: 1.65; color: var(--ink); margin: 0; }
.note {
background: #FEF9EC;
border: 1px solid #EDD97A;
border-radius: 6px;
padding: 12px 16px;
margin: 16px 0;
display: flex;
gap: 12px;
align-items: flex-start;
}
.note .note-icon { font-size: 16px; flex-shrink: 0; }
.note p { color: #5C4A00; font-size: 13px; margin: 0; line-height: 1.6; }
.note strong { color: #3D3000; }
.warn {
background: #FEF2F2;
border: 1px solid #FCA5A5;
border-radius: 6px;
padding: 12px 16px;
margin: 16px 0;
display: flex;
gap: 12px;
align-items: flex-start;
}
.warn .note-icon { font-size: 16px; flex-shrink: 0; }
.warn p { color: #7F1D1D; font-size: 13px; margin: 0; line-height: 1.6; }
.warn strong { color: #5C0F0F; }
.step-label {
display: inline-block;
background: var(--accent);
color: white;
font-family: 'IBM Plex Mono', monospace;
font-size: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.06em;
padding: 3px 10px;
border-radius: 4px;
margin: 16px 0 8px;
}
.step-label.green { background: var(--accent2); }
.step-label.blue { background: var(--accent3); }
.step-label.gold { background: var(--gold); }
/* ─── Code block ──────────────────────────────────── */
.code-wrap {
background: var(--code-bg);
border-radius: 8px;
margin: 16px 0;
overflow: hidden;
}
.code-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 14px;
background: rgba(255,255,255,0.04);
border-bottom: 1px solid rgba(255,255,255,0.06);
}
.code-label {
font-family: 'IBM Plex Mono', monospace;
font-size: 10px;
color: rgba(255,255,255,0.5);
text-transform: uppercase;
letter-spacing: 0.08em;
}
.copy-btn {
font-family: 'IBM Plex Mono', monospace;
font-size: 10px;
color: rgba(255,255,255,0.5);
background: transparent;
border: 1px solid rgba(255,255,255,0.15);
padding: 3px 8px;
border-radius: 4px;
cursor: pointer;
text-transform: uppercase;
letter-spacing: 0.08em;
transition: all 0.15s ease;
}
.copy-btn:hover { color: white; border-color: rgba(255,255,255,0.4); }
pre {
font-family: 'IBM Plex Mono', monospace;
font-size: 12.5px;
color: var(--code-text);
padding: 16px;
overflow-x: auto;
line-height: 1.6;
white-space: pre;
}
.c-cmd { color: #87CEEB; font-weight: 600; }
.c-flag { color: var(--flag-c); }
.c-val { color: var(--val-c); }
.c-str { color: #98C379; }
.c-comment { color: rgba(255,255,255,0.28); font-style: italic; }
.c-key { color: #C678DD; }
.c-pipe { color: #E5C07B; }
/* ─── Tables ──────────────────────────────────────── */
.flag-table, .compare {
width: 100%;
border-collapse: collapse;
margin: 16px 0;
border: 1px solid var(--rule);
border-radius: 6px;
overflow: hidden;
}
.flag-table th {
font-family: 'IBM Plex Mono', monospace;
font-size: 10px;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.08em;
background: var(--paper3);
text-align: left;
padding: 10px 14px;
font-weight: 500;
}
.flag-table td { padding: 10px 14px; border-top: 1px solid var(--rule); vertical-align: top; }
.flag-table tbody tr:hover { background: var(--paper2); }
.f-name { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600; color: var(--flag-c); }
.f-val { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--val-c); }
.f-desc { font-size: 13px; color: var(--ink); }
.f-why { font-size: 12px; color: var(--muted); }
.compare th {
background: var(--ink);
color: white;
font-size: 13px;
font-weight: 600;
padding: 12px 14px;
text-align: left;
}
.compare th:first-child { border-top-left-radius: 6px; }
.compare th:last-child { border-top-right-radius: 6px; }
.compare td { padding: 12px 14px; border-top: 1px solid var(--rule); font-size: 13px; }
.compare .row-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.compare .local-val { color: var(--muted); }
.compare .eks-val { color: var(--accent2); font-weight: 500; }
/* ─── Flow diagram ────────────────────────────────── */
.flow { margin: 16px 0; }
.flow-step { display: flex; gap: 16px; min-height: 56px; }
.flow-line { display: flex; flex-direction: column; align-items: center; padding-top: 6px; }
.flow-dot {
width: 10px; height: 10px; border-radius: 50%;
background: var(--accent); flex-shrink: 0;
}
.flow-connector { width: 2px; flex: 1; background: var(--rule); margin-top: 4px; }
.flow-content { padding-bottom: 16px; flex: 1; }
.flow-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.flow-detail { font-size: 12.5px; color: var(--muted); }
/* ─── Scale diagram ───────────────────────────────── */
.scale-diagram {
background: var(--paper2);
border: 1px solid var(--rule);
border-radius: 10px;
padding: 20px;
font-family: 'IBM Plex Mono', monospace;
font-size: 12px;
line-height: 2;
color: var(--muted);
margin: 16px 0;
}
.scale-diagram .hi { color: var(--ink); font-weight: bold; }
.scale-diagram .green { color: var(--accent2); }
.scale-diagram .red { color: var(--accent); }
/* ─── Divider ─────────────────────────────────────── */
.divider {
border: none;
border-top: 1px solid var(--rule);
margin: 40px 0;
}
/* ─── Footer ──────────────────────────────────────── */
footer {
display: flex;
justify-content: space-between;
font-family: 'IBM Plex Mono', monospace;
font-size: 11px;
color: var(--muted);
border-top: 2px solid var(--rule);
padding-top: 24px;
margin-top: 60px;
}
/* ─── Mobile ──────────────────────────────────────── */
@media (max-width: 768px) {
nav { display: none; }
main { padding: 32px 24px 60px; max-width: 100%; }
.hero h1 { font-size: 32px; }
footer { flex-direction: column; gap: 8px; }
}
</style>
</head>
<body>
<div class="layout">
<!-- ═══════════ SIDEBAR ═══════════ -->
<nav>
<div class="nav-brand">
<div class="logo">Code<span>Space</span></div>
<div class="sub">Engineering Documentation</div>
</div>
<div class="nav-group-label">Introduction</div>
<a href="#summary"><span class="nav-num">1</span>Executive summary</a>
<a href="#architecture"><span class="nav-num">2</span>Architecture</a>
<div class="nav-group-label">Services</div>
<a href="#services"><span class="nav-num">3</span>Microservices</a>
<a href="#lifecycle"><span class="nav-num">4</span>Sandbox lifecycle</a>
<a href="#ai"><span class="nav-num">5</span>AI editing layer</a>
<div class="nav-group-label">Reference</div>
<a href="#data"><span class="nav-num">6</span>Data & schemas</a>
<a href="#cluster"><span class="nav-num">7</span>Cluster design</a>
<a href="#setup"><span class="nav-num">8</span>Local setup</a>
<a href="#env"><span class="nav-num">9</span>Environment vars</a>
<a href="#api"><span class="nav-num">10</span>API reference</a>
<div class="nav-group-label">Operations</div>
<a href="#cicd"><span class="nav-num">11</span>CI/CD pipeline</a>
<a href="#security"><span class="nav-num">12</span>Security</a>
<a href="#observability"><span class="nav-num">13</span>Observability</a>
<div class="nav-group-label">Project</div>
<a href="#roadmap"><span class="nav-num">14</span>Roadmap & limits</a>
<a href="#contributing"><span class="nav-num">15</span>Contributing</a>
<a href="#license"><span class="nav-num">16</span>License</a>
</nav>
<!-- ═══════════ MAIN ═══════════ -->
<main>
<!-- ─── HERO ─── -->
<section class="hero">
<div class="hero-eyebrow">Engineering · v0.1</div>
<h1>An <em>AI-powered</em> cloud<br>sandbox IDE</h1>
<p class="hero-desc">
codeSpace provisions isolated React + Vite sandboxes inside Kubernetes on demand. Each sandbox ships with a live preview, an integrated terminal, and a Mistral-powered AI agent that reads and writes files directly in the running pod — hot-reloading instantly through Vite's HMR.
</p>
<div class="hero-tags">
<span class="hero-tag">Node.js 20</span>
<span class="hero-tag">React 19</span>
<span class="hero-tag">Kubernetes 1.28+</span>
<span class="hero-tag">MongoDB Atlas</span>
<span class="hero-tag">Redis</span>
<span class="hero-tag">RabbitMQ</span>
<span class="hero-tag">MistralAI</span>
<span class="hero-tag">LangGraph</span>
</div>
</section>
<!-- ─── 01 SUMMARY ─── -->
<section class="section" id="summary">
<div class="section-header">
<div class="section-num-big">01</div>
<div class="section-title-block">
<div class="section-title">Executive summary</div>
<div class="section-subtitle">What it is, who it's for, and what makes it different</div>
</div>
</div>
<p>
codeSpace is a browser-based cloud IDE that spins up isolated, per-user React + Vite environments on demand inside a Kubernetes cluster. Each sandbox runs as a dedicated pod pre-loaded with a starter template. Users interact with a VS Code-style UI that includes a live preview pane, a file explorer, an integrated terminal, and an AI chat panel powered by Mistral Large via LangChain/LangGraph.
</p>
<p>
The AI agent reads, creates, and updates files directly inside the running pod in real time, triggering Vite's HMR so changes appear instantly in the preview without a full reload.
</p>
<div class="concept">
<div class="concept-label">Core value proposition</div>
<p>Spin up a production-quality React sandbox in one click, describe what you want to build in plain English, and watch the AI write and hot-reload the code while you observe it live in the same browser tab.</p>
</div>
<h3>Target users</h3>
<ul>
<li><strong>Frontend developers</strong> who want a zero-setup coding environment</li>
<li><strong>Students & learners</strong> exploring React without local toolchain pain</li>
<li><strong>Educators</strong> running classes where each student needs a working sandbox in seconds</li>
</ul>
</section>
<!-- ─── 02 ARCHITECTURE ─── -->
<section class="section" id="architecture">
<div class="section-header">
<div class="section-num-big">02</div>
<div class="section-title-block">
<div class="section-title">High-level architecture</div>
<div class="section-subtitle">How the browser, the cluster, and the managed services fit together</div>
</div>
</div>
<h3>System map</h3>
<div class="scale-diagram">
<span class="hi">Browser (React + Vite frontend)</span><br>
↓ HTTP / WebSocket / SSE<br>
<span class="hi">nginx Ingress Controller</span><br>
↓<br>
<span class="green">Core services</span> auth · sandbox · ai · router · notification<br>
↓ Kubernetes API<br>
<span class="green">Per-sandbox pods</span> template + agent (shared /workspace volume)<br>
↓<br>
<span class="hi">External managed services</span><br>
MongoDB Atlas · Redis · RabbitMQ · MistralAI · Gmail SMTP
</div>
<h3>Five core services</h3>
<table class="flag-table">
<thead><tr><th>Service</th><th>Image</th><th>Responsibility</th></tr></thead>
<tbody>
<tr><td><span class="f-name">auth-service</span></td><td><span class="f-val">auth</span></td><td class="f-desc">Google OAuth 2.0 login, JWT issuance, user record persistence, login event dispatch via RabbitMQ.</td></tr>
<tr><td><span class="f-name">sandbox-service</span></td><td><span class="f-val">sandbox</span></td><td class="f-desc">Provisions new sandbox pods + per-sandbox services. Listens for Redis key expiry to clean up dead sandboxes.</td></tr>
<tr><td><span class="f-name">ai-service</span></td><td><span class="f-val">ai-orchestration</span></td><td class="f-desc">Hosts the LangGraph ReAct agent. Streams responses via SSE. Proxies file tool calls to per-sandbox agent sidecars.</td></tr>
<tr><td><span class="f-name">router-service</span></td><td><span class="f-val">router</span></td><td class="f-desc">Subdomain reverse proxy. Routes <code>{id}.preview.localhost</code> and <code>{id}.agent.localhost</code> to the right per-sandbox service. Refreshes Redis TTL on every request.</td></tr>
<tr><td><span class="f-name">notification-service</span></td><td><span class="f-val">notification</span></td><td class="f-desc">Consumes <code>auth_notification_queue</code> and sends login alert emails via Gmail OAuth2.</td></tr>
</tbody>
</table>
<h3>Per-sandbox pod (created on demand)</h3>
<p>Every active session has its own pod with two containers sharing an <code>emptyDir</code> volume mounted at <code>/workspace</code>:</p>
<ul>
<li><strong>template container</strong> — runs <code>npm run dev</code>, exposes Vite on port 5173</li>
<li><strong>agent container</strong> — file API + PTY over Socket.IO on port 3000</li>
</ul>
<p>An init container seeds the shared volume from the template image's <code>/workspace</code>. Both runtime containers see the same file tree, so writes from the agent are picked up by Vite's watcher.</p>
</section>
<!-- ─── 03 SERVICES ─── -->
<section class="section" id="services">
<div class="section-header">
<div class="section-num-big">03</div>
<div class="section-title-block">
<div class="section-title">Microservices breakdown</div>
<div class="section-subtitle">Each service explained — directory, port, deps, API surface</div>
</div>
</div>
<!-- 3.1 Auth -->
<div class="step-label">Auth Service</div>
<table class="flag-table">
<tbody>
<tr><td><span class="f-name">Directory</span></td><td class="f-desc"><code>auth/</code></td></tr>
<tr><td><span class="f-name">Framework</span></td><td class="f-desc">Express 5 on Node 20 (ES modules)</td></tr>
<tr><td><span class="f-name">Port</span></td><td class="f-desc">3000 (exposed at <code>:80</code> via ClusterIP)</td></tr>
<tr><td><span class="f-name">Replicas</span></td><td class="f-desc">1</td></tr>
<tr><td><span class="f-name">Dependencies</span></td><td class="f-desc">MongoDB Atlas, RabbitMQ, Google OAuth, JWT</td></tr>
</tbody>
</table>
<table class="flag-table">
<thead><tr><th>Method</th><th>Path</th><th>What it does</th></tr></thead>
<tbody>
<tr><td><span class="f-name">GET</span></td><td><span class="f-val">/api/auth/google</span></td><td class="f-desc">Initiates the Google OAuth redirect flow.</td></tr>
<tr><td><span class="f-name">GET</span></td><td><span class="f-val">/api/auth/google/callback</span></td><td class="f-desc">OAuth callback. Upserts the user, signs a 1-hour JWT, returns it as an <code>httpOnly</code> cookie.</td></tr>
<tr><td><span class="f-name">GET</span></td><td><span class="f-val">/_status/healthz</span></td><td class="f-desc">Liveness probe.</td></tr>
<tr><td><span class="f-name">GET</span></td><td><span class="f-val">/_status/readyz</span></td><td class="f-desc">Readiness probe.</td></tr>
</tbody>
</table>
<p>Key packages: <code>passport</code>, <code>passport-google-oauth20</code>, <code>jsonwebtoken</code>, <code>mongoose</code>, <code>amqplib</code>, <code>cookie-parser</code>.</p>
<hr class="divider">
<!-- 3.2 AI -->
<div class="step-label">AI Orchestration Service</div>
<table class="flag-table">
<tbody>
<tr><td><span class="f-name">Directory</span></td><td class="f-desc"><code>ai-orchestration/</code></td></tr>
<tr><td><span class="f-name">Framework</span></td><td class="f-desc">Express 5 + LangChain + LangGraph</td></tr>
<tr><td><span class="f-name">Port</span></td><td class="f-desc">3000</td></tr>
<tr><td><span class="f-name">Replicas</span></td><td class="f-desc">2 (CPU-bound, scales under streaming load)</td></tr>
<tr><td><span class="f-name">Model</span></td><td class="f-desc"><code>mistral-large-latest</code> via MistralAI API</td></tr>
</tbody>
</table>
<table class="flag-table">
<thead><tr><th>Method</th><th>Path</th><th>What it does</th></tr></thead>
<tbody>
<tr><td><span class="f-name">POST</span></td><td><span class="f-val">/api/ai/invoke</span></td><td class="f-desc">Streams agent activity + final response over SSE. Body: <code>{ message, projectId }</code>.</td></tr>
<tr><td><span class="f-name">GET</span></td><td><span class="f-val">/api/status/healthz</span></td><td class="f-desc">Liveness probe.</td></tr>
</tbody>
</table>
<hr class="divider">
<!-- 3.3 Notification -->
<div class="step-label">Notification Service</div>
<table class="flag-table">
<tbody>
<tr><td><span class="f-name">Directory</span></td><td class="f-desc"><code>notification/</code></td></tr>
<tr><td><span class="f-name">Framework</span></td><td class="f-desc">Express 5 + amqplib + nodemailer</td></tr>
<tr><td><span class="f-name">Port</span></td><td class="f-desc">4000</td></tr>
<tr><td><span class="f-name">Queue</span></td><td class="f-desc"><code>auth_notification_queue</code> (durable, persistent delivery)</td></tr>
</tbody>
</table>
<p>Consumes login events off RabbitMQ and sends an alert email via Gmail OAuth2. HTTP endpoints exist only for health probes.</p>
<hr class="divider">
<!-- 3.4 Sandbox Server -->
<div class="step-label">Sandbox Server</div>
<table class="flag-table">
<tbody>
<tr><td><span class="f-name">Directory</span></td><td class="f-desc"><code>sandbox/server/</code></td></tr>
<tr><td><span class="f-name">Service account</span></td><td class="f-desc"><code>resource-manager</code> (has pods + services RBAC)</td></tr>
<tr><td><span class="f-name">K8s client</span></td><td class="f-desc"><code>@kubernetes/client-node</code></td></tr>
<tr><td><span class="f-name">Redis</span></td><td class="f-desc">Stores <code>sandbox:{id}</code> with 120s TTL; subscribes to <code>__keyevent@0__:expired</code> for cleanup.</td></tr>
</tbody>
</table>
<table class="flag-table">
<thead><tr><th>Method</th><th>Path</th><th>What it does</th></tr></thead>
<tbody>
<tr><td><span class="f-name">POST</span></td><td><span class="f-val">/api/sandbox/start</span></td><td class="f-desc">Creates pod + service + Redis key. Returns <code>{ sandboxId, previewUrl }</code>.</td></tr>
<tr><td><span class="f-name">GET</span></td><td><span class="f-val">/api/sandbox/health</span></td><td class="f-desc">Health check.</td></tr>
</tbody>
</table>
<hr class="divider">
<!-- 3.5 Router -->
<div class="step-label">Sandbox Router</div>
<table class="flag-table">
<tbody>
<tr><td><span class="f-name">Directory</span></td><td class="f-desc"><code>sandbox/router/</code></td></tr>
<tr><td><span class="f-name">Proxy libs</span></td><td class="f-desc"><code>http-proxy-middleware</code> v4 (HTTP) + <code>httpxy</code> (WS upgrades)</td></tr>
<tr><td><span class="f-name">TTL refresh</span></td><td class="f-desc">Every proxied request calls <code>EXPIRE sandbox:{id} 120</code></td></tr>
</tbody>
</table>
<table class="flag-table">
<thead><tr><th>Host</th><th>Routes to</th><th>Port</th></tr></thead>
<tbody>
<tr><td><span class="f-name">{id}.preview.localhost</span></td><td><span class="f-val">sandbox-service-{id}</span></td><td class="f-desc">80 → 5173 (Vite)</td></tr>
<tr><td><span class="f-name">{id}.agent.localhost</span></td><td><span class="f-val">sandbox-service-{id}</span></td><td class="f-desc">3000 → 3000 (Agent)</td></tr>
</tbody>
</table>
<div class="concept">
<div class="concept-label">Why a separate router</div>
<p>nginx ingress can't read the dynamic subdomain ID and route to a per-sandbox ClusterIP service without one rule per sandbox. The Router parses <code>req.headers.host</code> at request time and proxies to the right backend — a single ingress entry handles all sandboxes.</p>
</div>
<hr class="divider">
<!-- 3.6 Agent -->
<div class="step-label">Sandbox Agent (Sidecar)</div>
<table class="flag-table">
<tbody>
<tr><td><span class="f-name">Directory</span></td><td class="f-desc"><code>sandbox/agent/</code></td></tr>
<tr><td><span class="f-name">Base image</span></td><td class="f-desc"><code>node:20-bullseye</code> (Debian — required for <code>node-pty</code> native compile)</td></tr>
<tr><td><span class="f-name">Working dir</span></td><td class="f-desc"><code>/workspace</code> (shared <code>emptyDir</code> volume)</td></tr>
</tbody>
</table>
<table class="flag-table">
<thead><tr><th>Method</th><th>Path</th><th>What it does</th></tr></thead>
<tbody>
<tr><td><span class="f-name">GET</span></td><td><span class="f-val">/list-files</span></td><td class="f-desc">Recursively lists files in <code>/workspace</code> (excludes <code>node_modules</code>, <code>.git</code>, <code>dist</code>).</td></tr>
<tr><td><span class="f-name">GET</span></td><td><span class="f-val">/read-files?files=a,b</span></td><td class="f-desc">Returns contents for the requested files.</td></tr>
<tr><td><span class="f-name">PATCH</span></td><td><span class="f-val">/update-files</span></td><td class="f-desc">Writes / overwrites file contents. Creates parent dirs.</td></tr>
<tr><td><span class="f-name">POST</span></td><td><span class="f-val">/create-files</span></td><td class="f-desc">Creates new files.</td></tr>
</tbody>
</table>
<p>Socket.IO events on the same port: <code>terminal-output</code> (server → client, PTY data) and <code>terminal-input</code> (client → server, keystrokes).</p>
<hr class="divider">
<!-- 3.7 Template -->
<div class="step-label">Sandbox Template</div>
<p>Pre-built React + Vite project. Used as both the init container (seeds <code>/seed</code>) and the main runtime container (runs <code>npm run dev</code> on <code>/workspace</code>). Image: <code>node:20-alpine</code>.</p>
<hr class="divider">
<!-- 3.8 Frontend -->
<div class="step-label">Frontend (Client IDE)</div>
<p>Browser-based IDE. React 19 + Vite 8 + Tailwind v4. Components:</p>
<table class="flag-table">
<thead><tr><th>Component</th><th>Purpose</th></tr></thead>
<tbody>
<tr><td><span class="f-name">SplashScreen</span></td><td class="f-desc">Landing page. Calls <code>POST /api/sandbox/start</code>.</td></tr>
<tr><td><span class="f-name">TopBar</span></td><td class="f-desc">Preview / Files tab switcher, sandbox ID, status indicator.</td></tr>
<tr><td><span class="f-name">FileExplorer</span></td><td class="f-desc">Tree-view sidebar. Refreshes on AI edits.</td></tr>
<tr><td><span class="f-name">FileViewer</span></td><td class="f-desc">Read-only code viewer.</td></tr>
<tr><td><span class="f-name">PreviewFrame</span></td><td class="f-desc">iframe pointing to <code>{id}.preview.localhost</code> with refresh + new-tab toolbar.</td></tr>
<tr><td><span class="f-name">Terminal</span></td><td class="f-desc">xterm.js terminal over Socket.IO.</td></tr>
<tr><td><span class="f-name">AiChat</span></td><td class="f-desc">Chat panel. Consumes SSE from <code>/api/ai/invoke</code>. Renders activity log under AI bubbles.</td></tr>
</tbody>
</table>
</section>
<!-- ─── 04 LIFECYCLE ─── -->
<section class="section" id="lifecycle">
<div class="section-header">
<div class="section-num-big">04</div>
<div class="section-title-block">
<div class="section-title">Sandbox lifecycle</div>
<div class="section-subtitle">From "Create Sandbox" click to TTL-driven cleanup</div>
</div>
</div>
<h3>Provisioning flow</h3>
<div class="flow">
<div class="flow-step">
<div class="flow-line"><div class="flow-dot"></div><div class="flow-connector"></div></div>
<div class="flow-content">
<div class="flow-title">User clicks "Create Sandbox" on SplashScreen</div>
<div class="flow-detail">Frontend issues POST /api/sandbox/start</div>
</div>
</div>
<div class="flow-step">
<div class="flow-line"><div class="flow-dot"></div><div class="flow-connector"></div></div>
<div class="flow-content">
<div class="flow-title">Ingress routes to sandbox-service (ClusterIP)</div>
<div class="flow-detail">/api/sandbox prefix matches the sandbox deployment</div>
</div>
</div>
<div class="flow-step">
<div class="flow-line"><div class="flow-dot"></div><div class="flow-connector"></div></div>
<div class="flow-content">
<div class="flow-title">Sandbox server generates UUIDv7 → sandboxId</div>
<div class="flow-detail">Used as pod name suffix, service selector, and Redis key</div>
</div>
</div>
<div class="flow-step">
<div class="flow-line"><div class="flow-dot"></div><div class="flow-connector"></div></div>
<div class="flow-content">
<div class="flow-title">Pod + service + Redis key created in parallel</div>
<div class="flow-detail">createNamespacedPod, createNamespacedService, SET sandbox:{id} EX 120</div>
</div>
</div>
<div class="flow-step">
<div class="flow-line"><div class="flow-dot" style="background:var(--accent2)"></div></div>
<div class="flow-content">
<div class="flow-title">Response returned to client</div>
<div class="flow-detail">{ sandboxId, previewUrl: "http://{id}.preview.localhost" }</div>
</div>
</div>
</div>
<h3>Pod specification</h3>
<div class="step-label blue">Init container</div>
<p>Image <code>template</code>. Runs <code>sh -c 'cp -r /workspace/. /seed/'</code> — copies the pre-built React/Vite template from the image into the shared <code>emptyDir</code> volume.</p>
<div class="step-label">Container 1 — sandbox-container</div>
<p>Image <code>template</code>. Starts Vite dev server. Port 5173. CPU 250m/500m, memory 500Mi/1Gi.</p>
<div class="step-label">Container 2 — agent-container</div>
<p>Image <code>agent</code>. File API + PTY. Port 3000. CPU 250m/500m, memory 500Mi/1Gi.</p>
<div class="concept">
<div class="concept-label">Why shared emptyDir</div>
<p>Both containers mount <code>workspace-volume</code> at <code>/workspace</code>. The init container seeds it once. After that, every file the agent writes is immediately visible to Vite's file watcher — which is exactly what enables instant HMR after AI edits.</p>
</div>
<h3>Per-sandbox K8s service</h3>
<div class="code-wrap">
<div class="code-header"><span class="code-label">sandbox-service-{id}.yaml (generated)</span></div>
<pre><span class="c-key">ports</span>:
- <span class="c-key">name</span>: <span class="c-val">http</span> <span class="c-key">port</span>: <span class="c-val">80</span> <span class="c-key">targetPort</span>: <span class="c-val">5173</span> <span class="c-comment"># Vite preview</span>
- <span class="c-key">name</span>: <span class="c-val">agent-http</span> <span class="c-key">port</span>: <span class="c-val">3000</span> <span class="c-key">targetPort</span>: <span class="c-val">3000</span> <span class="c-comment"># Agent API</span>
<span class="c-key">selector</span>:
<span class="c-key">sandboxId</span>: <span class="c-val">{sandboxId}</span> <span class="c-comment"># unique — prevents cross-sandbox routing</span>
<span class="c-key">type</span>: <span class="c-val">ClusterIP</span></pre>
</div>
<div class="note">
<div class="note-icon">💡</div>
<p>The selector uses <code>sandboxId</code>, <strong>not</strong> a shared label like <code>app: sandbox</code>. This guarantees each per-sandbox service routes only to its paired pod — no cross-tenant traffic possible.</p>
</div>
<h3>TTL & cleanup policy</h3>
<ul>
<li>On creation, <code>sandbox:{id}</code> is stored in Redis with a <strong>120-second TTL</strong>.</li>
<li>Every HTTP / WebSocket request through the Router calls <code>EXPIRE sandbox:{id} 120</code> — TTL is effectively activity-based.</li>
<li>An ioredis subscriber in the sandbox server listens on <code>__keyevent@0__:expired</code>. On expiry it calls <code>deleteNamespacedPod</code> + <code>deleteNamespacedService</code> with <code>gracePeriodSeconds: 0</code>.</li>
<li>No persistent storage — the <code>emptyDir</code> volume dies with the pod.</li>
</ul>
<h3>Subdomain routing</h3>
<p>The nginx ingress maps both wildcard hosts to the router:</p>
<div class="code-wrap">
<div class="code-header"><span class="code-label">ingress (wildcard rules)</span></div>
<pre>*.preview.localhost → router-service :80
*.agent.localhost → router-service :80</pre>
</div>
<p>The Router reads <code>req.headers.host</code>, splits on <code>.</code> to extract <code>sandboxId</code> and <code>type</code> (<code>preview</code> vs <code>agent</code>), and proxies to the matching <code>sandbox-service-{sandboxId}</code> ClusterIP.</p>
</section>
<!-- ─── 05 AI ─── -->
<section class="section" id="ai">
<div class="section-header">
<div class="section-num-big">05</div>
<div class="section-title-block">
<div class="section-title">AI code editing layer</div>
<div class="section-subtitle">How user intent becomes file writes inside a running pod</div>
</div>
</div>
<h3>Agent architecture</h3>
<p>The AI layer uses LangChain + LangGraph to build a stateful ReAct agent:</p>
<div class="code-wrap">
<div class="code-header"><span class="code-label">agent.js (simplified)</span></div>
<pre><span class="c-key">LangGraph</span>.<span class="c-cmd">createAgent</span>({
<span class="c-key">model</span>: <span class="c-cmd">ChatMistralAI</span>(<span class="c-str">"mistral-large-latest"</span>),
<span class="c-key">tools</span>: [list_files, read_files, update_files],
<span class="c-key">systemPrompt</span>: <span class="c-str">"codeSpace — expert AI frontend engineer..."</span>,
<span class="c-key">recursionLimit</span>: <span class="c-val">100</span>
})</pre>
</div>
<p>Standard tool-calling loop: the agent receives a user message, decides which tools to call, executes them, receives results, and repeats until it has enough information to produce a final response.</p>
<h3>Streaming response (SSE)</h3>
<p>The <code>POST /api/ai/invoke</code> endpoint sets <code>Content-Type: text/event-stream</code> and flushes text over the open connection:</p>
<table class="flag-table">
<thead><tr><th>Output type</th><th>Source</th><th>Rendered as</th></tr></thead>
<tbody>
<tr><td><span class="f-name">Activity lines</span></td><td><span class="f-val">writer callback</span></td><td class="f-desc">Tool progress: <code>"Listing files..."</code>, <code>"Reading files..."</code>, <code>"Updating files..."</code></td></tr>
<tr><td><span class="f-name">Final response</span></td><td><span class="f-val">last ai message</span></td><td class="f-desc">The last <code>ai</code>-role message with no <code>tool_calls</code> — written, then <code>res.end()</code> closes the stream.</td></tr>
</tbody>
</table>
<p>The frontend's <code>AiChat</code> reads the stream with the Fetch API's <code>ReadableStream</code>, classifies each line, and renders an expandable activity log under the AI bubble.</p>
<h3>Tools the agent has</h3>
<table class="flag-table">
<thead><tr><th>Tool</th><th>HTTP call</th><th>Returns</th></tr></thead>
<tbody>
<tr><td><span class="f-name">list_files</span></td><td><span class="f-val">GET .../list-files</span></td><td class="f-desc">Flat array of all file paths in <code>/workspace</code>.</td></tr>
<tr><td><span class="f-name">read_files</span></td><td><span class="f-val">GET .../read-files?files=…</span></td><td class="f-desc">Map of <code>{ path: content }</code> for requested files.</td></tr>
<tr><td><span class="f-name">update_files</span></td><td><span class="f-val">PATCH .../update-files</span></td><td class="f-desc">Writes full file contents. Creates parent directories.</td></tr>
</tbody>
</table>
<p>All tools receive <code>config.context.projectId</code> and <code>config.context.writer</code> via LangGraph's runnable config. The agent reaches the sandbox agent sidecar over Kubernetes internal DNS: <code>http://sandbox-service-{sandboxId}:3000</code> resolves to the per-sandbox ClusterIP.</p>
<h3>Agent workflow (from system prompt)</h3>
<ol>
<li><strong>Understand</strong> — parse user intent, identify implicit requirements.</li>
<li><strong>Plan</strong> — outline component tree, styling approach, sections.</li>
<li><strong>Explore</strong> — <code>list_files</code> → <code>read_files</code> on entry points and target files.</li>
<li><strong>Build</strong> — <code>update_files</code> in batched calls: configs first, shared components next, pages last.</li>
<li><strong>Polish</strong> — verify responsiveness, imports, accessibility.</li>
<li><strong>Report</strong> — summarize changes (written to stream, not to files).</li>
</ol>
<h3>Hot reload integration</h3>
<p>File writes from <code>update_files</code> land on the shared <code>emptyDir</code> volume. Vite's file watcher (configured with <code>usePolling: true</code>, <code>interval: 300ms</code>) detects the change and sends an HMR update over the WebSocket at <code>ws://{id}.preview.localhost</code>. The PreviewFrame iframe receives the update and patches the DOM without a full reload.</p>
<h3>Model parameters</h3>
<table class="flag-table">
<thead><tr><th>Parameter</th><th>Value</th></tr></thead>
<tbody>
<tr><td><span class="f-name">Provider</span></td><td class="f-desc">MistralAI</td></tr>
<tr><td><span class="f-name">Model ID</span></td><td><span class="f-val">mistral-large-latest</span></td></tr>
<tr><td><span class="f-name">Temperature</span></td><td><span class="f-val">0.7</span></td></tr>
<tr><td><span class="f-name">Max recursion</span></td><td class="f-desc">100 LangGraph steps</td></tr>
</tbody>
</table>
<h3>Context window management</h3>
<p>The agent uses the full LangGraph message history within a single invocation. There is currently <strong>no cross-session memory</strong> — each <code>POST /api/ai/invoke</code> starts a fresh agent run with only the current user message. The agent always calls <code>list_files</code> first to orient itself, then <code>read_files</code> on relevant files before making edits.</p>
<h3>Error handling</h3>
<ul>
<li>If the agent throws during streaming, the catch block checks <code>res.headersSent</code>. If headers were already sent, it calls <code>res.end()</code> gracefully; otherwise it returns <code>500 { error: "Failed to invoke agent" }</code>.</li>
<li>Individual tool errors (file not found, etc.) return error strings in the tool result object rather than throwing — the agent can reason about the failure and retry or skip.</li>
<li>File writes include <code>mkdir -p</code> semantics (<code>recursive: true</code>) so the agent can create files in new directories without a separate step.</li>
</ul>
</section>
<!-- ─── 06 DATA ─── -->
<section class="section" id="data">
<div class="section-header">
<div class="section-num-big">06</div>
<div class="section-title-block">
<div class="section-title">Data models & schemas</div>
<div class="section-subtitle">What lives in MongoDB, what lives in Redis, what flows through RabbitMQ</div>
</div>
</div>
<h3>User (MongoDB — auth database)</h3>
<p>Collection: <code>users</code></p>
<table class="flag-table">
<thead><tr><th>Field</th><th>Type</th><th>Notes</th></tr></thead>
<tbody>
<tr><td><span class="f-name">_id</span></td><td><span class="f-val">ObjectId</span></td><td class="f-desc">PK, auto-assigned.</td></tr>
<tr><td><span class="f-name">googleId</span></td><td><span class="f-val">String</span></td><td class="f-desc">Required, unique. From Google OAuth <code>profile.id</code>.</td></tr>
<tr><td><span class="f-name">email</span></td><td><span class="f-val">String</span></td><td class="f-desc">Required, unique. Primary email from Google profile.</td></tr>
<tr><td><span class="f-name">name</span></td><td><span class="f-val">String</span></td><td class="f-desc">Required. Display name from Google profile.</td></tr>
<tr><td><span class="f-name">avatar</span></td><td><span class="f-val">String</span></td><td class="f-desc">Profile photo URL.</td></tr>
<tr><td><span class="f-name">createdAt</span></td><td><span class="f-val">Date</span></td><td class="f-desc">Auto-generated by <code>timestamps: true</code>.</td></tr>
<tr><td><span class="f-name">updatedAt</span></td><td><span class="f-val">Date</span></td><td class="f-desc">Auto-updated.</td></tr>
</tbody>
</table>
<p>Indexes: <code>googleId</code> (unique), <code>email</code> (unique).</p>
<h3>Sandbox state (Redis)</h3>
<p>Sandbox lifecycle is tracked in Redis only — no persistent record in MongoDB.</p>
<table class="flag-table">
<thead><tr><th>Aspect</th><th>Value</th></tr></thead>
<tbody>
<tr><td><span class="f-name">Key format</span></td><td><span class="f-val">sandbox:{sandboxId}</span></td></tr>
<tr><td><span class="f-name">Value</span></td><td class="f-desc">JSON string: <code>{ "status": "active" }</code></td></tr>
<tr><td><span class="f-name">TTL</span></td><td class="f-desc">120 seconds, refreshed on every proxied request</td></tr>
<tr><td><span class="f-name">Expiry handler</span></td><td class="f-desc">Sandbox server subscribes to <code>__keyevent@0__:expired</code>; deletes the K8s pod + service.</td></tr>
</tbody>
</table>
<h3>AI edit history</h3>
<div class="note">
<div class="note-icon">💡</div>
<p><strong>Not yet implemented.</strong> A suggested schema (collection <code>ai_edits</code>): <code>sandboxId</code>, <code>userId</code>, <code>userMessage</code>, <code>filesModified[]</code>, <code>agentSteps</code>, <code>createdAt</code>. Wire this up if you need undo / edit history.</p>
</div>
<h3>Message queue payload</h3>
<p>Queue: <code>auth_notification_queue</code> (RabbitMQ, durable, persistent delivery)</p>
<table class="flag-table">
<thead><tr><th>Field</th><th>Type</th><th>Notes</th></tr></thead>
<tbody>
<tr><td><span class="f-name">userId</span></td><td><span class="f-val">ObjectId (string)</span></td><td class="f-desc">Auth service user <code>_id</code>.</td></tr>
<tr><td><span class="f-name">action</span></td><td><span class="f-val">String</span></td><td class="f-desc">Currently always <code>"google_login"</code>.</td></tr>
<tr><td><span class="f-name">timestamp</span></td><td><span class="f-val">Date</span></td><td class="f-desc">ISO timestamp of the login event.</td></tr>
<tr><td><span class="f-name">email</span></td><td><span class="f-val">String</span></td><td class="f-desc">User's email address.</td></tr>
</tbody>
</table>
</section>
<!-- ─── 07 CLUSTER ─── -->
<section class="section" id="cluster">
<div class="section-header">
<div class="section-num-big">07</div>
<div class="section-title-block">
<div class="section-title">Kubernetes cluster design</div>
<div class="section-subtitle">Namespaces, resources, RBAC, secrets, networking</div>
</div>
</div>
<h3>Namespace strategy</h3>
<table class="flag-table">
<thead><tr><th>Namespace</th><th>Contents</th></tr></thead>
<tbody>
<tr><td><span class="f-name">default</span></td><td class="f-desc">All application workloads + all dynamic sandbox pods/services.</td></tr>
<tr><td><span class="f-name">ingress-nginx</span></td><td class="f-desc">nginx Ingress Controller (installed separately).</td></tr>
<tr><td><span class="f-name">kube-system</span></td><td class="f-desc">Cluster system components.</td></tr>
</tbody>
</table>