Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
3034 lines (2615 loc) · 131 KB
/
Copy pathapp.js
File metadata and controls
3034 lines (2615 loc) · 131 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
const WORKSPACE_PATH = '/Users/joelvarghese/.gemini/antigravity/scratch/ML-Nexus-Resource-Hub';
let filesTree = [];
let flattenedFiles = [];
let currentFilePath = '';
// ── Study with ChatGPT ──
// ChatGPT reads the lesson from its raw GitHub URL, so the prompt stays short enough for a ?q= link.
const RAW_BASE = 'https://raw.githubusercontent.com/joevar5/ML-Nexus-Resource-Hub/main/';
const TUTOR_RULES = 'Be interactive: go one step at a time, ask me something, and wait for my reply before moving on. Use simple English and practical examples. I am learning this for real-world use and interviews.';
const CHATGPT_MODES = {
teach: 'Teach me this lesson. First give a 3-line overview and the list of key concepts. Then explain them one at a time, and after each one ask me a short question to check I understood. If I get it wrong, explain it another way.',
quiz: 'Quiz me on this lesson. Ask 8 questions one at a time, mixing multiple-choice, short-answer and "what happens if..." scenarios, getting harder as we go. After each answer, tell me if I was right and why. At the end give me a score and the topics I should review.',
interview: 'Act as a senior interviewer for an AI/ML infrastructure role. Interview me on this lesson: one question at a time, with follow-up questions based on my answers like a real interviewer. After 5 questions, rate each answer and show what a strong answer would include.',
practice: 'Give me one hands-on exercise based on this lesson that I can do on my laptop (code, commands or a small design). State the goal and what "done" looks like, but not the solution. Give hints only when I ask. When I paste my attempt, review it like a code reviewer.',
revise: 'Help me revise this lesson fast. Give me a one-page cheat sheet, then 10 flashcards. Show the flashcards one at a time: the question first, and the answer only after I reply.',
'sel-explain': 'Explain the selected text below in simple English: what it means, how it works internally, and a common misconception. Then ask me one question to check I understood.',
'sel-example': 'Give me a concrete, real-world example of the selected text below (code or a production scenario), then ask me to predict what happens in a slightly changed version.',
'sel-quiz': 'Quiz me on the selected text below: 3 questions, one at a time. Wait for my answer and tell me if I was right and why.',
};
function openChatGPT(mode, selection = '') {
const title = flattenedFiles.find(f => f.path === currentFilePath)?.name || currentFilePath;
const url = RAW_BASE + currentFilePath.split('/').map(encodeURIComponent).join('/');
const topics = [...document.querySelectorAll('#markdown-content h2')]
.slice(0, 15).map(h => h.textContent.trim()).join(' · ');
let prompt = `${CHATGPT_MODES[mode]}\n\nLesson: "${title}"\nRead the full lesson here first: ${url}`;
if (topics) prompt += `\nSections: ${topics}`;
// shortcut: selection capped at 2000 chars to keep the link under browser URL limits
if (selection) prompt += `\n\nSelected text:\n"""\n${selection.slice(0, 2000)}\n"""`;
prompt += `\n\n${TUTOR_RULES}`;
window.open(`https://chatgpt.com/?q=${encodeURIComponent(prompt)}`, '_blank', 'noopener');
}
let activeCategory = null;
let stats = { lessons: '0', designs: '0', projects: '0' };
let completedFiles = new Set(JSON.parse(localStorage.getItem('completed_files') || '[]'));
function saveCompletedFiles() {
localStorage.setItem('completed_files', JSON.stringify(Array.from(completedFiles)));
}
function toggleFileCompletion(filePath) {
if (completedFiles.has(filePath)) {
completedFiles.delete(filePath);
} else {
completedFiles.add(filePath);
}
saveCompletedFiles();
updateCategoryProgress();
updateSidebarCompletionUI();
updateReaderDoneBtn();
}
function updateCategoryProgress() {
if (!activeCategory) return;
const categoryDir = categories.find(c => c.name === activeCategory)?.dir;
if (!categoryDir) return;
const totalFiles = flattenedFiles.filter(f => f.path.startsWith(categoryDir) && f.type === 'file');
const totalCount = totalFiles.length;
const completedCount = totalFiles.filter(f => completedFiles.has(f.path)).length;
const progressPercent = totalCount > 0 ? Math.round((completedCount / totalCount) * 100) : 0;
document.getElementById('category-progress-text').innerText = `${progressPercent}% (${completedCount}/${totalCount})`;
document.getElementById('category-progress-bar').style.width = `${progressPercent}%`;
}
function updateSidebarCompletionUI() {
document.querySelectorAll('.tree-file').forEach(el => {
const path = el.dataset.filepath;
if (!path) return;
const isCompleted = completedFiles.has(path);
const markDoneBtn = el.querySelector('.mark-done-btn');
const labelSpan = el.querySelector('.file-label');
if (markDoneBtn) {
markDoneBtn.innerText = isCompleted ? 'check_box' : 'check_box_outline_blank';
if (isCompleted) {
markDoneBtn.classList.remove('text-on-surface-variant/40');
markDoneBtn.classList.add('text-primary');
} else {
markDoneBtn.classList.add('text-on-surface-variant/40');
markDoneBtn.classList.remove('text-primary');
}
}
if (labelSpan) {
if (isCompleted) {
labelSpan.classList.add('line-through', 'opacity-60');
} else {
labelSpan.classList.remove('line-through', 'opacity-60');
}
}
});
document.querySelectorAll('.tree-folder').forEach(el => {
const folderpath = el.dataset.folderpath;
if (!folderpath) return;
const folderName = folderpath.split('/').pop();
if (!folderName.startsWith('mod-')) return;
const descendantFiles = flattenedFiles.filter(f => f.path.startsWith(folderpath + '/'));
const labelSpan = el.querySelector('.folder-label');
const bellIcon = el.querySelector('.revise-bell-icon');
if (descendantFiles.length > 0) {
const allCompleted = descendantFiles.every(f => completedFiles.has(f.path));
if (labelSpan) {
if (allCompleted) {
labelSpan.classList.add('line-through', 'opacity-60');
} else {
labelSpan.classList.remove('line-through', 'opacity-60');
}
}
if (bellIcon) {
if (allCompleted) {
bellIcon.classList.remove('hidden');
} else {
bellIcon.classList.add('hidden');
}
}
}
});
}
// ── Quick Revise: Leitner-system spaced repetition ──
// Each quizzed lesson sits in a box (1 = just failed/new, 5 = mastered). Passing a quiz
// moves it up a box (further out); failing resets it to box 1 (due again immediately).
const SRS_STORAGE_KEY = 'revise_srs_v1';
const SRS_BOX_INTERVAL_DAYS = [0, 1, 3, 7, 14]; // index 0 unused; box N -> index N
function loadSrsData() {
try {
return JSON.parse(localStorage.getItem(SRS_STORAGE_KEY) || '{}');
} catch (e) {
return {};
}
}
function saveSrsData(data) {
try {
localStorage.setItem(SRS_STORAGE_KEY, JSON.stringify(data));
} catch (e) {
console.error('Failed to save revision schedule', e);
}
}
// Called once a lesson's quiz is fully answered, to move it through the Leitner boxes.
function recordQuizResult(filePath, passed) {
const srsData = loadSrsData();
const prevBox = srsData[filePath]?.box || 0;
const nextBox = passed ? Math.min(prevBox + 1, 5) : 1;
const dueInDays = passed ? SRS_BOX_INTERVAL_DAYS[nextBox] : 0;
srsData[filePath] = {
box: nextBox,
dueAt: Date.now() + dueInDays * 24 * 60 * 60 * 1000,
reviewCount: (srsData[filePath]?.reviewCount || 0) + 1
};
saveSrsData(srsData);
}
// Returns { file, status } for a random Leitner-weighted lesson pick, or null if none exist.
function pickReviseCandidate() {
// Scope to whichever lesson category the user is currently browsing — revising
// ML & GenAI System Design shouldn't jump you into AI Infrastructure Engineer.
const activeCat = categories.find(c => c.name === activeCategory && !c.customView && !c.locked);
const categoryDir = activeCat ? activeCat.dir : null;
let lessonFiles = flattenedFiles.filter(f => f.type === 'file' && isLessonFile(f.path));
if (categoryDir) {
lessonFiles = lessonFiles.filter(f => f.path.startsWith(categoryDir + '/'));
}
if (lessonFiles.length === 0) return null;
const srsData = loadSrsData();
const now = Date.now();
const withStatus = lessonFiles
.filter(f => f.path !== currentFilePath || lessonFiles.length === 1)
.map(f => {
const record = srsData[f.path];
if (!record) return { file: f, box: 0, due: true, status: 'New lesson' };
const due = record.dueAt <= now;
const boxLabel = record.box >= 5 ? 'Mastered' : `Box ${record.box}`;
return {
file: f,
box: record.box,
due,
status: due ? `${boxLabel} · due for revision` : `${boxLabel} · reviewed early`
};
});
// Prefer lessons that are new or overdue; only fall back to "everything's fresh" if
// literally nothing is due, so the button never goes dead.
const duePool = withStatus.filter(c => c.due);
const pool = duePool.length > 0 ? duePool : withStatus;
// Weight toward weaker boxes (lower box = higher weight; new/never-quizzed = highest).
const weighted = [];
pool.forEach(c => {
const weight = c.box === 0 ? 6 : Math.max(1, 6 - c.box);
for (let i = 0; i < weight; i++) weighted.push(c);
});
return weighted[Math.floor(Math.random() * weighted.length)];
}
// Quick Revise only makes sense while actually reading a lesson/quiz — hide the FAB on
// Home, Coding, The Build Lab, and the Author page.
function setQuickReviseVisible(visible) {
const btn = document.getElementById('quick-revise-btn');
if (!btn) return;
btn.classList.toggle('hidden', !visible);
if (!visible) setStudyMenuOpen(false);
}
function setStudyMenuOpen(open) {
const menu = document.getElementById('study-menu');
const toggle = document.getElementById('study-fab-toggle');
if (!menu || !toggle) return;
menu.hidden = !open;
toggle.setAttribute('aria-expanded', String(open));
if (open) menu.querySelector('[role="menuitem"]').focus();
}
// True for actual lesson + quiz content only — excludes exercises/labs/resources/projects/
// assessments (code sandboxes like deployment.yaml) and anything outside the two lesson-driven
// categories.
function isLessonFile(path) {
if (!path.toLowerCase().endsWith('.md')) return false;
if (path.startsWith('AI Infrastructure Engineer/')) {
// Lecture notes are long-form reading, not a quick recap — only the quiz files
// (short, structured Q&A built for active recall) qualify here.
return path.includes('/lessons/') && path.includes('/quizzes/');
}
if (path.startsWith('ML and GenAI System Design/')) return true;
// GenAI Atlas lessons are numbered markdown files with quizzes inline (no separate
// quiz subfolder like AI Infra) — exclude README.md/track index pages, which aren't lessons.
if (path.startsWith('GenAI Atlas/')) {
const fileName = path.split('/').pop();
return fileName.toLowerCase() !== 'readme.md';
}
return false;
}
// Set right before navigating to a Quick Revise pick; loadFile() consumes them once the
// picked lesson has finished rendering, to kick off the driver.js recap tour.
let pendingReviseTour = false;
let pendingReviseStatus = '';
// Jump to a Leitner-weighted lesson pick (new/overdue lessons favored) so the user can
// re-read it and retake its quiz.
function quickRevise() {
const pick = pickReviseCandidate();
if (!pick) {
showToast('No lessons available to revise yet.', 'warning');
return;
}
pendingReviseTour = true;
pendingReviseStatus = pick.status;
window.location.hash = encodeURIComponent(pick.file.path);
}
// Guided driver.js recap tour: breadcrumb -> heading -> quiz (if the lesson has one).
function startReviseTour() {
if (!window.driver || !window.driver.js) return;
const matchedFile = flattenedFiles.find(f => f.path === currentFilePath);
const lessonName = matchedFile ? matchedFile.name : currentFilePath.split('/').pop();
const statusLine = pendingReviseStatus ? `<br><span class="revise-status-badge">${escapeHtml(pendingReviseStatus)}</span>` : '';
pendingReviseStatus = '';
// makeQuizInteractive() builds #quiz-scoreboard only when it detects quiz-shaped
// content in the markdown — plain lesson docs (e.g. ML & GenAI System Design case
// studies) never get one, so the recap step shouldn't reference a quiz that isn't there.
const hasQuiz = !!document.getElementById('quiz-scoreboard');
const steps = [
{
element: '#breadcrumbs',
popover: {
title: 'Quick Revise ⚡',
description: `You're revisiting <strong>${escapeHtml(lessonName)}</strong>. Let's jog your memory.${statusLine}`,
side: 'bottom',
align: 'start'
}
},
{
element: '#markdown-content',
popover: {
title: 'Skim the key ideas',
description: hasQuiz
? 'Quickly scan back over the core concepts before the quiz.'
: 'Quickly scan back over the core concepts to refresh your memory.',
side: 'top',
align: 'start'
}
}
];
if (hasQuiz) {
steps.push({
element: '#quiz-scoreboard',
popover: {
title: 'Test yourself',
description: 'Retake the quiz below to check what stuck.',
side: 'top',
align: 'start'
}
});
}
const { driver } = window.driver.js;
driver({
showProgress: true,
overlayOpacity: 0.6,
stagePadding: 6,
smoothScroll: true,
steps
}).drive();
}
function updateReaderDoneBtn() {
const btn = document.getElementById('mark-done-page-btn');
const icon = document.getElementById('mark-done-page-icon');
const text = document.getElementById('mark-done-page-text');
if (!btn || !icon || !text || !currentFilePath) return;
const isCompleted = completedFiles.has(currentFilePath);
if (isCompleted) {
icon.innerText = 'check_box';
text.innerText = 'Done';
btn.className = "flex items-center gap-2 px-6 py-3 bg-primary text-white font-bold rounded-lg transition-all font-label text-sm uppercase tracking-wide border border-primary";
} else {
icon.innerText = 'check_box_outline_blank';
text.innerText = 'Mark as Done';
btn.className = "flex items-center gap-2 px-6 py-3 bg-surface-container-high hover:bg-primary hover:text-white text-on-surface font-bold rounded-lg transition-all font-label text-sm uppercase tracking-wide border border-outline-variant";
}
}
// `customView`, when set, names a hand-built view (see showProjectsView etc.) that this
// category opens to instead of loading a markdown file — used for card/UI-driven sections
// that aren't backed by content files at all.
const categories = [
{ name: 'AI Infrastructure Engineer', dir: 'AI Infrastructure Engineer', icon: 'memory' },
{ name: 'ML & GenAI System Design', dir: 'ML and GenAI System Design', icon: 'schema' },
// Only the Agents track (30-Day Agentic AI Interview Prep Path) is published so far —
// visibleFolders restricts the sidebar tree to that one subfolder until the rest unlocks.
{ name: 'GenAI Atlas', dir: 'GenAI Atlas', icon: 'auto_awesome', visibleFolders: ['Agents'] },
{ name: 'Coding', dir: 'Coding', icon: 'code', customView: 'coding' },
{ name: 'The Build Lab', dir: 'ML and GenAI Projects', icon: 'terminal', customView: 'projects' },
{ name: 'Engineering Blog Dissections', dir: 'Engineering Blog Dissections', icon: 'description', locked: true }
];
// Card data for the hand-built Projects view (#projects). Edit this array to add/remove cards —
// no markdown files involved, so layout and behavior stay fully under UI control.
const mlProjects = [
{
title: 'MLForge',
image: 'assets/projects/mlforge.svg',
imageAlt: 'Pipeline from notebook to FastAPI, Kubernetes, training pipeline and monitoring',
description: 'Engineered a full MLOps lifecycle from notebook to production: a FastAPI model-serving API deployed on Kubernetes, a tracked and versioned training pipeline, and live monitoring — the same path real ML platform teams ship on.',
icon: 'rocket_launch',
status: 'Live',
tags: ['classical-ml'],
link: 'AI Infrastructure Engineer/Phase 1 - Core AI Infrastructure & Foundations/phase-1-learning-plan.md',
featured: true,
journey: [
{ icon: 'api', label: 'Model API' },
{ icon: 'hub', label: 'Kubernetes' },
{ icon: 'timeline', label: 'Pipeline' },
{ icon: 'monitoring', label: 'Monitoring' },
{ icon: 'military_tech', label: 'Capstone' }
]
},
{
title: 'Retrievo',
image: 'ML and GenAI System Design/GENAI SD/miscellaneous/rag_overall_system_design.png',
imageAlt: 'RAG system: document indexing, retrieval, then LLM generation',
description: 'Architected an enterprise-grade RAG system for searching internal knowledge bases at scale — AI-driven document parsing and chunking, vector search, CLIP-powered multimodal retrieval, optional RAFT fine-tuning, and a custom 4-part eval suite to keep answers grounded and cited.',
icon: 'find_in_page',
status: 'Live',
tags: ['genai'],
link: 'ML and GenAI System Design/GENAI SD/Retrieval-Augmented Generation.md'
},
{
title: 'GraphLink',
image: 'ML and GenAI System Design/MLSD/1. Recommendation & Personalization/miscellaneous/pymk_fof_tree.png',
imageAlt: 'A user, their friends, and friends of friends',
description: 'Designed a graph-based friend-recommendation system for a billion-user social network — GNN-powered edge prediction over mutual-connection signals, feeding a two-stage candidate generation + ranking pipeline behind a LinkedIn-style "People You May Know."',
icon: 'diversity_3',
status: 'Live',
tags: ['classical-ml'],
link: 'ML and GenAI System Design/MLSD/1. Recommendation & Personalization/People You May Know.md'
},
{
title: 'WatchNext',
image: 'ML and GenAI System Design/MLSD/1. Recommendation & Personalization/miscellaneous/video_recommendation_multi_stage_prediction_pipeline.png',
imageAlt: 'Two-stage pipeline: candidate generation then ranking',
description: 'Built a two-stage recommendation pipeline — candidate retrieval + ranking — over a 10-billion-video catalog, engineered for a sub-200ms serving budget: the same core architecture behind YouTube\'s home-feed engine.',
icon: 'smart_display',
status: 'Live',
tags: ['classical-ml'],
link: 'ML and GenAI System Design/MLSD/1. Recommendation & Personalization/Video Recommendation System.md'
},
{
title: 'AutoDraft',
image: 'ML and GenAI System Design/GENAI SD/miscellaneous/gmail_smart_compose_suggested_words.png',
imageAlt: 'Email draft with an inline suggested completion',
description: 'Implemented a decoder-only Transformer for real-time inline text generation, Gmail Smart Compose-style — trained on ~1 billion emails and tuned for imperceptible ~100ms latency with high-confidence-only, bias-checked suggestions.',
icon: 'edit_note',
status: 'Live',
tags: ['genai'],
link: 'ML and GenAI System Design/GENAI SD/Gmail Smart Compose.md'
},
{
title: 'SafeGuard',
image: 'ML and GenAI System Design/MLSD/4. Trust & Safety/miscellaneous/harmful_content_detection_heterogeneous_post_data.png',
imageAlt: 'A post split into its image, text and author signals',
description: 'Designed a proactive moderation system for a 500M-posts-a-day social platform — multimodal fusion of text, image and author signals, with a multi-task classifier that scores violence, nudity, self-harm and hate speech at once.',
icon: 'shield',
status: 'Live',
tags: ['classical-ml'],
link: 'ML and GenAI System Design/MLSD/4. Trust & Safety/Harmful Content Detection.md'
}
];
const sideProjects = [
{
title: 'JSON Trace',
description: 'Lift off with the next-generation JSON visualizer. A highly interactive tool built to parse, format, and interactively trace JSON structures. Received high traffic and user engagement on Netlify.',
icon: 'data_object',
status: 'Live',
tags: ['tools'],
link: 'https://json-trace.netlify.app/',
external: true
}
];
const PROJECT_TAG_LABELS = { 'classical-ml': 'Classical ML', genai: 'Gen-AI', idea: 'Idea', tools: 'Tools' };
// Card data for the hand-built Coding view (#coding). Edit these arrays to add/remove tool
// cards — no markdown files involved, so layout and behavior stay fully under UI control.
// Each entry: { title, description, icon (Material Symbols name), link (external URL) }
const mlCodingTools = [
{
title: 'LeetGPU',
description: 'Write and optimize GPU/CUDA kernels in the browser — the go-to place to get hands-on with the low-level, hardware side of ML performance.',
icon: 'developer_board',
link: 'https://leetgpu.com/joevar'
},
{
title: 'Grind75 ML',
description: 'A wide-ranging, curated problem set spanning ML, LLM, and enterprise coding — the kind of ML problems real companies actually ask.',
icon: 'checklist',
link: 'https://123ofai.com/qnalab/lists/Grind75ML'
},
{
title: 'AI Offerly — Career Guide',
description: 'Real ML interview questions collected from different companies, organized to prep for actual interview loops.',
icon: 'business_center',
link: 'https://www.aiofferly.com/career-guide'
},
{
title: 'AgenticPrep',
description: 'Solve Python agent-loop, tool-calling, memory, RAG, and eval problems used in real AI engineering interviews.',
icon: 'smart_toy',
link: 'https://www.agenticprep.io/'
},
{
title: 'Context Window',
description: 'AI engineer interview prep: 400+ practice questions (100+ coding), worked answers, and video lessons.',
icon: 'quiz',
link: 'https://www.contextwindowprep.com/'
}
];
const genericCodingTools = [
{
title: 'LeetCode',
description: 'Classic data structures & algorithms practice — the baseline every coding interview still comes back to.',
icon: 'code_blocks',
link: 'https://leetcode.com/u/joevarghese/'
},
{
title: 'AlgoMaster — Low-Level Design',
description: 'Object-oriented and low-level system design interview practice, with worked-through case studies.',
icon: 'account_tree',
link: 'https://algomaster.io/interview/low-level-design'
},
{
title: 'Hello Interview — AI Coding',
description: 'Learn the latest AI-coding interview format that companies targeting AI roles are actually using.',
icon: 'psychology',
link: 'https://www.hellointerview.com/learn/ai-coding/overview/introduction'
}
];
// Build a coding-tool card's inner HTML from its data object (see mlCodingTools / genericCodingTools).
function codingToolCardHtml(t, delay = 0) {
return `
<div class="project-card projects-fade-item p-6 bg-surface-container-low rounded-2xl border border-outline-variant hover:border-primary transition-all duration-300 flex flex-col justify-between group text-left" style="animation-delay: ${delay}s;">
<div>
<div class="flex items-center justify-between mb-4">
<div class="project-card-icon w-10 h-10 rounded-xl bg-primary-container/10 text-primary flex items-center justify-center">
<span class="material-symbols-outlined text-xl">${t.icon || 'code'}</span>
</div>
</div>
<h3 class="text-lg font-headline font-bold mb-2">${escapeHtml(t.title)}</h3>
<p class="text-on-surface-variant text-sm leading-relaxed mb-4">${escapeHtml(t.description || '')}</p>
</div>
<a href="${t.link}" target="_blank" rel="noopener noreferrer" class="self-start px-4 py-2 bg-primary/10 text-primary font-bold rounded-lg hover:bg-primary hover:text-white transition-all text-xs font-label flex items-center gap-1.5">
<span>Visit</span>
<span class="material-symbols-outlined text-sm">open_in_new</span>
</a>
</div>`;
}
// Render a grid of coding-tool cards, or a placeholder note if the array is empty.
function renderCodingToolGrid(gridEl, tools) {
if (!tools.length) {
gridEl.innerHTML = `
<div class="col-span-full p-6 rounded-2xl border border-dashed border-outline-variant text-on-surface-variant text-sm">
No tools added here yet.
</div>`;
return;
}
gridEl.innerHTML = tools.map((t, i) => codingToolCardHtml(t, 0.2 + i * 0.08)).join('');
}
// Populate the Coding view's card grids from mlCodingTools / genericCodingTools
function renderCodingView() {
renderCodingToolGrid(document.getElementById('coding-ml-grid'), mlCodingTools);
renderCodingToolGrid(document.getElementById('coding-generic-grid'), genericCodingTools);
}
// Display the hand-built Coding Toolkit view
function showCodingView() {
currentFilePath = '';
setQuickReviseVisible(false);
document.getElementById('home-view').style.display = 'none';
document.getElementById('reader-view').style.display = 'none';
document.getElementById('search-view').style.display = 'none';
document.getElementById('error-view').style.display = 'none';
document.getElementById('author-view').style.display = 'none';
document.getElementById('projects-view').style.display = 'none';
document.getElementById('coding-view').style.display = 'block';
document.getElementById('sidebar-tree-container').style.display = 'none';
document.querySelectorAll('.tree-file').forEach(el => {
el.className = 'tree-file flex items-start gap-2 p-2 rounded-lg text-on-surface-variant hover:bg-surface-container-high transition-colors cursor-pointer text-sm font-label';
});
const catBtns = document.querySelectorAll('.cat-btn');
catBtns.forEach(btn => {
if (btn.dataset.category === 'Coding') {
btn.className = "cat-btn w-full flex items-center justify-between p-3 rounded-lg bg-primary-container text-on-primary-container font-medium transition-all text-left";
} else {
btn.className = "cat-btn w-full flex items-center justify-between p-3 rounded-lg text-on-surface-variant hover:bg-surface-container-high transition-colors text-left";
}
});
document.getElementById('about-author-link').className = 'flex items-center gap-md p-3 text-on-surface-variant hover:bg-surface-container-high rounded-lg transition-colors';
renderCodingView();
document.getElementById('progress-bar').style.width = '0%';
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// Initialize App
document.addEventListener('DOMContentLoaded', () => {
setupTheme();
setupEventListeners();
loadStructure();
});
// Set up dark / light themes
function setupTheme() {
const themeToggleBtn = document.getElementById('theme-toggle-btn');
// Set initial state
updateThemeToggleButton();
themeToggleBtn.addEventListener('click', () => {
const isDark = document.documentElement.classList.contains('dark');
const newTheme = isDark ? 'light' : 'dark';
if (newTheme === 'dark') {
document.documentElement.classList.add('dark');
document.documentElement.classList.remove('light');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.classList.add('light');
document.documentElement.classList.remove('dark');
localStorage.setItem('theme', 'light');
}
if (window.mermaid) {
mermaid.initialize({ theme: newTheme === 'dark' ? 'dark' : 'default' });
}
updateThemeToggleButton();
});
}
function updateThemeToggleButton() {
const themeToggleBtn = document.getElementById('theme-toggle-btn');
const isDark = document.documentElement.classList.contains('dark');
themeToggleBtn.innerText = isDark ? 'light_mode' : 'dark_mode';
}
// Set up Event Listeners
function setupEventListeners() {
// Mobile Menu Toggle
const menuToggle = document.getElementById('menu-toggle-btn');
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('sidebar-overlay');
menuToggle.addEventListener('click', (e) => {
sidebar.classList.toggle('-translate-x-full');
overlay.classList.toggle('hidden');
e.stopPropagation();
});
// Close mobile menu on clicking overlay
overlay.addEventListener('click', () => {
sidebar.classList.add('-translate-x-full');
overlay.classList.add('hidden');
});
// Handle browser navigation (back/forward)
window.addEventListener('hashchange', handleRouting);
// Handle Live Search
const searchInput = document.getElementById('search-input');
searchInput.addEventListener('input', (e) => {
handleSearch(e.target.value);
});
// Close mobile menu when links are clicked inside sidebar
sidebar.addEventListener('click', (e) => {
if (e.target.closest('.tree-file') || e.target.closest('a') || e.target.closest('button')) {
sidebar.classList.add('-translate-x-full');
overlay.classList.add('hidden');
}
});
// Handle scroll progress and scroll-to-top button
const scrollTopBtn = document.getElementById('scroll-top-btn');
window.addEventListener('scroll', () => {
// Progress Bar
const totalHeight = document.documentElement.scrollHeight - window.innerHeight;
if (totalHeight > 0) {
const progress = (window.scrollY / totalHeight) * 100;
document.getElementById('progress-bar').style.width = `${progress}%`;
} else {
document.getElementById('progress-bar').style.width = '0%';
}
// Scroll to top visibility
if (window.scrollY > 300) {
scrollTopBtn.classList.add('visible');
} else {
scrollTopBtn.classList.remove('visible');
}
});
scrollTopBtn.addEventListener('click', () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
// Intercept relative markdown link clicks to navigate within the SPA
document.getElementById('markdown-content').addEventListener('click', (e) => {
const link = e.target.closest('a');
if (!link) return;
const href = link.getAttribute('href');
if (!href) return;
// Handle local page anchor links (prevent changing SPA route hash)
if (href.startsWith('#')) {
e.preventDefault();
const targetId = decodeURIComponent(href.substring(1));
const targetElement = document.getElementById(targetId);
if (targetElement) {
targetElement.scrollIntoView({ behavior: 'smooth' });
}
return;
}
// Skip external or mailto links
if (href.startsWith('http://') || href.startsWith('https://') || href.startsWith('mailto:')) {
return;
}
// Prevent default normal page navigation
e.preventDefault();
// Resolve relative path against current file
const resolved = resolveRelativePath(currentFilePath, href);
navigateToResolvedPath(resolved);
});
// Selection Handling for ChatGPT Tooltip
const chatgptTooltip = document.getElementById('chatgpt-tooltip');
let selectedText = '';
function handleTextSelection() {
const selection = window.getSelection();
const text = selection.toString().trim();
if (!text) {
chatgptTooltip.classList.remove('visible');
selectedText = '';
return;
}
// Only show tooltip in content pages (within markdown-content)
const markdownContent = document.getElementById('markdown-content');
if (!markdownContent || !selection.anchorNode || !markdownContent.contains(selection.anchorNode)) {
chatgptTooltip.classList.remove('visible');
selectedText = '';
return;
}
selectedText = text;
// Position the tooltip above the selected text
try {
const range = selection.getRangeAt(0);
const rect = range.getBoundingClientRect();
// Check if selection bounding box is valid
if (rect.width > 0 && rect.height > 0) {
chatgptTooltip.style.left = `${rect.left + rect.width / 2}px`;
chatgptTooltip.style.top = `${rect.top - 48}px`; // 48px above top of selection
chatgptTooltip.classList.add('visible');
} else {
chatgptTooltip.classList.remove('visible');
}
} catch (e) {
chatgptTooltip.classList.remove('visible');
}
}
document.addEventListener('mouseup', () => {
// Delay slightly to ensure selection state is fully updated
setTimeout(handleTextSelection, 10);
});
document.addEventListener('keyup', (e) => {
// Update selection on arrow keys navigation
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Shift'].includes(e.key)) {
handleTextSelection();
} else if (e.key === 'Escape') {
chatgptTooltip.classList.remove('visible');
window.getSelection().removeAllRanges();
}
});
// Prevent clearing selection immediately when clicking the tooltip itself
chatgptTooltip.addEventListener('mousedown', (e) => {
e.preventDefault();
});
chatgptTooltip.addEventListener('click', (e) => {
const btn = e.target.closest('button[data-mode]');
if (!btn || !selectedText) return;
openChatGPT(btn.dataset.mode, selectedText);
window.getSelection().removeAllRanges();
chatgptTooltip.classList.remove('visible');
});
// Study floating button + menu
const studyToggle = document.getElementById('study-fab-toggle');
const studyMenu = document.getElementById('study-menu');
studyToggle.addEventListener('click', () => setStudyMenuOpen(studyMenu.hidden));
studyMenu.addEventListener('click', (e) => {
const item = e.target.closest('button[role="menuitem"]');
if (!item) return;
setStudyMenuOpen(false);
if (item.dataset.action === 'revise-next') quickRevise();
else openChatGPT(item.dataset.mode);
});
studyMenu.addEventListener('keydown', (e) => {
const items = [...studyMenu.querySelectorAll('[role="menuitem"]')];
const i = items.indexOf(document.activeElement);
if (e.key === 'ArrowDown') { e.preventDefault(); items[(i + 1) % items.length].focus(); }
if (e.key === 'ArrowUp') { e.preventDefault(); items[(i - 1 + items.length) % items.length].focus(); }
});
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && !studyMenu.hidden) { setStudyMenuOpen(false); studyToggle.focus(); }
});
document.addEventListener('click', (e) => {
if (!studyMenu.hidden && !e.target.closest('#quick-revise-btn')) setStudyMenuOpen(false);
});
// Handle page completion toggle button
const donePageBtn = document.getElementById('mark-done-page-btn');
if (donePageBtn) {
donePageBtn.addEventListener('click', () => {
if (currentFilePath) {
toggleFileCompletion(currentFilePath);
}
});
}
}
// Select learning path category in sidebar
function selectCategory(categoryName) {
const cat = categories.find(c => c.name === categoryName);
if (!cat) return;
activeCategory = categoryName;
// Reset About the Author link styles
document.getElementById('about-author-link').className = 'flex items-center gap-md p-3 text-on-surface-variant hover:bg-surface-container-high rounded-lg transition-colors';
// Highlight active category tab in sidebar
const catBtns = document.querySelectorAll('.cat-btn');
catBtns.forEach(btn => {
if (btn.dataset.category === categoryName) {
btn.className = "cat-btn w-full flex items-center justify-between p-3 rounded-lg bg-primary-container text-on-primary-container font-medium transition-all text-left";
} else {
btn.className = "cat-btn w-full flex items-center justify-between p-3 rounded-lg text-on-surface-variant hover:bg-surface-container-high transition-colors text-left";
}
});
// Filter filesTree and render sidebar files navigation
const targetNode = filesTree.find(node => node.name === cat.dir);
if (targetNode && targetNode.children) {
const visibleChildren = filterVisibleFolders(targetNode.children, cat.visibleFolders);
renderSidebar(visibleChildren, document.getElementById('sidebar-menu'), cat.dir);
} else {
document.getElementById('sidebar-menu').innerHTML = `
<div class="p-2 text-on-surface-variant/60 text-xs">
No resources found in this path.
</div>
`;
}
updateCategoryProgress();
}
// Navigate dynamically to the first file of a category via URL hash
function navigateToCategory(categoryName) {
const cat = categories.find(c => c.name === categoryName);
if (!cat) return;
if (cat.locked) {
showToast(`The ${cat.name} path is currently locked.`, 'warning');
return;
}
if (cat.customView) {
window.location.hash = cat.customView;
return;
}
const targetNode = filesTree.find(node => node.name === cat.dir);
if (targetNode && targetNode.children) {
const visibleChildren = filterVisibleFolders(targetNode.children, cat.visibleFolders);
const firstFile = findFirstFile(visibleChildren);
if (firstFile) {
window.location.hash = encodeURIComponent(firstFile.path);
}
}
}
// Restrict a directory's children to a named subset of subfolders (used while a category is
// only partially published). Non-directory entries (e.g. a top-level README) always pass through.
// With no allowlist given, all children pass through unchanged.
function filterVisibleFolders(children, visibleFolders) {
if (!visibleFolders) return children;
return children.filter(n => n.type !== 'directory' || visibleFolders.includes(n.name));
}
// Recursive search for the first readable markdown file in category children
function findFirstFile(nodes) {
// 1. Search for a readme file recursively
const readme = findReadmeRecursively(nodes);
if (readme) return readme;
// 2. If no readme, return the first file we encounter
return findFirstFileRecursively(nodes);
}
function findReadmeRecursively(nodes) {
// First check current level
const readme = nodes.find(n => n.type === 'file' && n.path.toLowerCase().endsWith('readme.md'));
if (readme) return readme;
// Then check subdirectories
for (const n of nodes) {
if (n.type === 'directory' && n.children) {
const f = findReadmeRecursively(n.children);
if (f) return f;
}
}
return null;
}
function findFirstFileRecursively(nodes) {
for (const n of nodes) {
if (n.type === 'file') return n;
if (n.type === 'directory' && n.children) {
const f = findFirstFileRecursively(n.children);
if (f) return f;
}
}
return null;
}
// Resolve relative paths in links/images
function resolveRelativePath(basePath, relativePath) {
relativePath = decodeURIComponent(relativePath);
const parts = basePath.split('/');
parts.pop(); // Remove filename to get parent dir
const relParts = relativePath.split('/');
for (const part of relParts) {
if (part === '.' || part === '') {
continue;
} else if (part === '..') {
parts.pop();
} else {
parts.push(part);
}
}
return parts.join('/');
}
// Route internal link click to dynamic routing hash
function navigateToResolvedPath(resolvedPath) {
const exactFile = flattenedFiles.find(f => f.path === resolvedPath);
if (exactFile) {
window.location.hash = encodeURIComponent(resolvedPath);
return;
}
// Fallbacks for folders
const readmeAlternatives = [
resolvedPath + '/readme.md',
resolvedPath + '/README.md',
resolvedPath + '/Readme.md',
resolvedPath + '/index.html'
];
for (const rPath of readmeAlternatives) {
const readmeFile = flattenedFiles.find(f => f.path === rPath);
if (readmeFile) {
window.location.hash = encodeURIComponent(rPath);
return;
}
}
const dirPrefix = resolvedPath.endsWith('/') ? resolvedPath : resolvedPath + '/';
const childFile = flattenedFiles.find(f => f.path.startsWith(dirPrefix));
if (childFile) {
window.location.hash = encodeURIComponent(childFile.path);
return;
}
console.warn(`Could not resolve route for: ${resolvedPath}`);
window.location.hash = encodeURIComponent(resolvedPath);
}
// Fetch structure.json and load app index
async function loadStructure() {
try {
const response = await fetch('structure.json');
if (!response.ok) throw new Error('Failed to fetch structure index');
filesTree = await response.json();
flattenTree(filesTree);
calculateStats();
// Select first category by default
selectCategory('AI Infrastructure Engineer');
handleRouting();
} catch (err) {
console.error('Error initializing structure:', err);
document.getElementById('sidebar-menu').innerHTML = `
<div class="p-2 text-error text-xs font-semibold">
Failed to build resource navigation. Run the indexing script.