(Jekyll + WebR + JS)"] --> Auth["Firebase Authentication
(Google, GitHub, Email)"] Client --> Firestore["Cloud Firestore
(NoSQL Documents + Vectors)"] Client --> Storage["Firebase Storage
(Submissions / Figures)"] Client --> Functions["Firebase Cloud Functions
(Node.js / Gemini / RAG)"] ``` * **Firebase Authentication:** User identity, email verification, and role-based permissions. * **Cloud Firestore:** Real-time NoSQL database holding student progress, vector embeddings, collaborative table states, and study manifests. * **Firebase Storage:** Secure bucket storage for student figure uploads, PDF assignments, and automated GCS backups. * **Firebase Cloud Functions:** Backend serverless endpoints handling real-time token streaming (SSE), vector chunking, and administrative batch jobs. --- ## 2. Cloud Firestore Collections & Data Models ### `/users/{uid}` Stores the core profile and authorization metadata for each registered learner: ```typescript interface UserProfile { uid: string; email: string; displayName: string; photoURL?: string; createdAt: Timestamp; lastLogin: Timestamp; enrollment: 'in-person' | 'virtual'; // Enforced by admin tags: string[]; // e.g. ['TA', 'Honors'] course_review_status: 'none' | 'requested' | 'certified'; certified_at?: Timestamp; } ``` #### Subcollections under `/users/{uid}`: * **`/users/{uid}/page_notes/{lectureId}`:** Auto-saved markdown notes written by the student inside the Lecture Companion sidebar. * **`/users/{uid}/progress/{lectureId}`:** Video playhead tracking (last timestamp, percent watched, completed flag). * **`/users/{uid}/lab_progress/{labId}`:** Lab task checklists, draft links, and submission timestamps. * **`/users/{uid}/webr_progress/{stepId}`:** Tracks completion of WebR curriculum steps. Stores `completed`, `completed_at`, `error_count`, and `last_used`. * **`/users/{uid}/my_studies/{studyId}`:** Cloud backup of the student's custom count analysis manifests: ```typescript interface StudyManifest { studyId: string; name: string; sampleCount: number; geneCount: number; factors: Record