# abdullahsajidfr/seekho-sikhao architecture

> Architecture diagram of the GitHub repository abdullahsajidfr/seekho-sikhao, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdullahsajidfr/seekho-sikhao
- Repository: https://github.com/abdullahsajidfr/seekho-sikhao

## Overview

1. **Repository shape**
   - This is a two-app monorepo around the same learning-session backend:
     - `app/seekho-sikhao-woz`: a **React/Vite web prototype** with multiple operator/student surfaces.
     - `seekho-student`: a **React Native/Expo mobile student app**.
   - Both are designed to run in a **static demo mode** with no credentials, or in a **live Wizard-of-Oz mode** when Firebase env vars are present.

2. **Primary architectural boundary**
   - The key boundary is between **presentation surfaces** and a shared **Firebase-driven session/logging backend**.
   - The apps do not appear to share a runtime package; instead they share:
     - a common Firebase schema and event vocabulary,
     - similar session/logging concepts,
     - similar surface/route breakdowns,
     - and a shared downstream analytics pipeline to Google Sheets.

3. **Web prototype: single SPA with four surfaces**
   - `app/seekho-sikhao-woz` is a single-page React app that exposes:
     - `/` room entry,
     - `/student` child-facing learning experience,
     - `/wizard` operator console,
     - `/teacher` teacher-facing UI.
   - The SPA is split by **surface folders** under `src/surfaces/*`, which makes the diagram naturally “one host app, many role-based UIs.”

4. **Web student experience**
   - The student surface is further divided into screen-level states such as login, subject selection, chat, workbook, input mode, and past chat.
   - Supporting components include chat bubbles, camera, drawing canvas, smileyometer overlay, top bar, and workbook question cards.
   - This indicates a multimodal tutoring flow: the student can interact through text/chat, drawings, camera, and feedback widgets rather than only a linear form.

5. **Operator surfaces: wizard, teacher, admin**
   - The wizard surface is the human-in-the-loop control plane: composing messages, quick responses, session controls, greetings, incoming messages, and session info.
   - The teacher surface provides higher-level monitoring and oversight: class page, student profile, dashboard, login, and guardrails.
   - The admin surface focuses on live operations and telemetry: event feed, live chat, manual events, task tracking, session control, and smileyometer delivery.
   - In architecture terms, these are different **control/observability planes** over the same live session data.

6. **Mobile student app**
   - `seekho-student` is the child-facing app, also split into entry and student surfaces with screens for login, subject selection, chat, workbook, and input mode.
   - It mirrors the web student journey but is packaged for **native mobile deployment via Expo**.
   - The mobile app appears intentionally narrower than the web app: it does not include wizard/teacher/admin UIs, only the learner-facing path.

7. **Session and state management**
   - Both apps have Firebase helpers under `src/firebase/*` and session hooks such as `useSession`, suggesting that “session” is the main shared domain object.
   - The repository’s structure implies a session flow that begins at room/entry, then drives student state, while wizard/teacher surfaces observe or steer that same session.
   - The presence of `demo.ts` in both apps suggests an offline fixture path for the same screen flow when Firebase is unavailable.

8. **Shared logging/analytics pipeline**
   - Event logging is a first-class subsystem, not an afterthought.
   - Both apps route events through a shared `logEvent` style pipeline that writes to:
     - **Firebase Realtime Database** for per-session logs,
     - and **Google Sheets** via a deployed Apps Script endpoint for downstream analysis.
   - Event records include timing, phase, source surface, and interaction metadata, so the architecture supports both real-time supervision and later usability analysis.

9. **Auto-capture versus semantic events**
   - The web app mounts a global auto-logger that captures navigation, clicks, inputs, submits, and keydowns across all surfaces.
   - The mobile app mirrors the same logging vocabulary using React Native-friendly event hooks and navigation state changes.
   - In addition to auto-capture, important domain events like screen/task/smileyometer milestones are emitted explicitly, meaning the logs combine **interaction telemetry** and **study instrumentation**.

10. **Backend services and infra**
    - Firebase is the shared live backend:
      - **Realtime Database** stores session state and event logs,
      - **Storage** supports student photo uploads,
      - security rules live in repo-managed JSON files.
    - The web prototype also has a **serverless TTS endpoint** at `api/tts.ts`, deployed through Vercel, which proxies text-to-speech and handles Roman Urdu to Urdu transliteration before synthesis.
    - So the backend boundary is not a large custom API; it is mostly **managed Firebase plus one small function**.

11. **Data flow summary**
    - Typical live flow:
      1. Tester enters a room/session code.
      2. Student app connects to the Firebase session.
      3. Wizard/teacher/admin surfaces observe or update session data.
      4. User actions are auto-logged and written to RTDB.
      5. The same events are mirrored into Google Sheets for analysis.
      6. Optional media uploads go to Firebase Storage.
      7. Optional speech output routes through the TTS function.
    - This is a **loosely coupled, event-driven** prototype rather than a tightly centralized API architecture.

12. **Deployment and runtime split**
    - The web app is a browser SPA built with React 19, TypeScript, Vite, and CSS Modules.
    - The mobile app is Expo/React Native/TypeScript.
    - The TTS function is serverless and isolated from the client bundles.
    - The repo therefore has three execution targets: **browser SPA, mobile app, and serverless function**, all converging on the same Firebase-backed study environment.

13. **Important architectural implication**
    - This repo is optimized for **HCI testing and live facilitation**, not for production-scale backend complexity.
    - The core design pattern is “shared study protocol, multiple surfaces, common event schema,” with demo mode allowing the whole system to run without credentials and live mode turning on real-time Firebase coordination.

Main entry points: [`app/seekho-sikhao-woz/src/App.tsx`](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/App.tsx) (Web SPA), [`app/seekho-sikhao-woz/src/lib/autolog.ts`](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/lib/autolog.ts) (Event logging), [`app/seekho-sikhao-woz/src/surfaces/student/StudentApp.tsx`](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/student/StudentApp.tsx) (Student UX), [`app/seekho-sikhao-woz/src/firebase/config.ts`](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/firebase/config.ts) (Firebase core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web prototype"]
  node_web_app["Web SPA<br/>react/vite app<br/>[App.tsx]"]
  node_web_entry["Room entry<br/>entry surface<br/>[EntryPage.tsx]"]
  node_web_student["Student UX<br/>learning surface<br/>[StudentApp.tsx]"]
  node_web_wizard["Wizard console<br/>operator surface<br/>[WizardApp.tsx]"]
  node_web_teacher["Teacher view<br/>oversight surface<br/>[TeacherApp.tsx]"]
  node_web_admin["Admin ops<br/>operations surface<br/>[AdminApp.tsx]"]
  node_student_screens["Student screens<br/>screen states<br/>[ChatScreen.tsx]"]
  node_student_widgets["Student widgets<br/>interaction widgets<br/>[ChatBubble.tsx]"]
  node_wizard_tools["Wizard tools<br/>control widgets<br/>[ComposePanel.tsx]"]
  node_teacher_pages["Teacher pages<br/>monitoring pages"]
  node_admin_panels["Admin panels<br/>ops panels<br/>[EventLogFeed.tsx]"]
end

subgraph group_mobile["Mobile app"]
  node_mobile_app["Mobile app<br/>expo app<br/>[App.tsx]"]
  node_mobile_entry["Mobile entry<br/>entry surface<br/>[EntryScreen.tsx]"]
  node_mobile_student["Mobile student<br/>learning surface<br/>[StudentApp.tsx]"]
  node_mobile_screens["Mobile screens<br/>screen states<br/>[ChatScreen.tsx]"]
end

subgraph group_backend["Shared backend"]
  node_firebase_core[("Firebase core<br/>session backend<br/>[config.ts]")]
  node_event_logging["Event logging<br/>telemetry pipeline<br/>[autolog.ts]"]
  node_storage_tts["Media + TTS<br/>aux services<br/>[storage.ts]"]
  node_sheets_export["Sheets export<br/>analytics sink"]
end

node_web_app -->|"routes to"| node_web_entry
node_web_app -->|"routes to"| node_web_student
node_web_app -->|"routes to"| node_web_wizard
node_web_app -->|"routes to"| node_web_teacher
node_web_app -->|"routes to"| node_web_admin
node_web_student -->|"uses"| node_student_screens
node_web_student -->|"uses"| node_student_widgets
node_web_wizard -->|"uses"| node_wizard_tools
node_web_teacher -->|"uses"| node_teacher_pages
node_web_admin -->|"uses"| node_admin_panels
node_mobile_app -->|"routes to"| node_mobile_entry
node_mobile_app -->|"routes to"| node_mobile_student
node_mobile_student -->|"uses"| node_mobile_screens
node_web_app -->|"connects to"| node_firebase_core
node_mobile_app -->|"connects to"| node_firebase_core
node_web_student -->|"emits"| node_event_logging
node_web_wizard -->|"emits"| node_event_logging
node_web_admin -->|"emits"| node_event_logging
node_mobile_student -->|"emits"| node_event_logging
node_event_logging -->|"writes to"| node_firebase_core
node_event_logging -->|"mirrors to"| node_sheets_export
node_web_student -->|"uses"| node_storage_tts
node_firebase_core -.->|"supports"| node_storage_tts

click node_web_app "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/App.tsx"
click node_web_entry "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/entry/EntryPage.tsx"
click node_web_student "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/student/StudentApp.tsx"
click node_web_wizard "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/wizard/WizardApp.tsx"
click node_web_teacher "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/teacher/TeacherApp.tsx"
click node_web_admin "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/admin/AdminApp.tsx"
click node_student_screens "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/student/screens/ChatScreen.tsx"
click node_student_widgets "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/student/components/ChatBubble.tsx"
click node_wizard_tools "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/wizard/components/ComposePanel.tsx"
click node_teacher_pages "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/teacher/screens/TeacherDashboard.tsx"
click node_admin_panels "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/admin/components/EventLogFeed.tsx"
click node_mobile_app "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/seekho-student/App.tsx"
click node_mobile_entry "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/seekho-student/src/surfaces/entry/EntryScreen.tsx"
click node_mobile_student "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/seekho-student/src/surfaces/student/StudentApp.tsx"
click node_mobile_screens "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/seekho-student/src/surfaces/student/screens/ChatScreen.tsx"
click node_firebase_core "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/firebase/config.ts"
click node_event_logging "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/lib/autolog.ts"
click node_storage_tts "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/firebase/storage.ts"
click node_sheets_export "https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/docs/google-apps-script.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_app,node_web_entry,node_web_student,node_web_wizard,node_web_teacher,node_web_admin,node_student_screens,node_student_widgets,node_wizard_tools,node_teacher_pages,node_admin_panels toneBlue
class node_mobile_app,node_mobile_entry,node_mobile_student,node_mobile_screens toneAmber
class node_firebase_core,node_event_logging,node_storage_tts,node_sheets_export toneMint
```

## Components

### Web prototype

Browser SPA with multiple role-based surfaces.

- [Web SPA](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/App.tsx): react/vite app · Single-page prototype hosting entry, student, wizard, teacher, and admin surfaces. · `app/seekho-sikhao-woz/src/App.tsx`
- [Room entry](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/entry/EntryPage.tsx): entry surface · Join flow for entering a study room or session code. · `app/seekho-sikhao-woz/src/surfaces/entry/EntryPage.tsx`
- [Student UX](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/student/StudentApp.tsx): learning surface · Web student journey with multimodal tutoring states and screens. · `app/seekho-sikhao-woz/src/surfaces/student/StudentApp.tsx`
- [Wizard console](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/wizard/WizardApp.tsx): operator surface · Human-in-the-loop control plane for composing and steering live sessions. · `app/seekho-sikhao-woz/src/surfaces/wizard/WizardApp.tsx`
- [Teacher view](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/teacher/TeacherApp.tsx): oversight surface · Teacher-facing monitoring, class, profile, dashboard, and guardrail pages. · `app/seekho-sikhao-woz/src/surfaces/teacher/TeacherApp.tsx`
- [Admin ops](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/admin/AdminApp.tsx): operations surface · Live operations, event feed, manual events, task tracking, and delivery controls. · `app/seekho-sikhao-woz/src/surfaces/admin/AdminApp.tsx`
- [Student screens](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/student/screens/ChatScreen.tsx): screen states · Login, subject selection, chat, workbook, input mode, and past-chat states. · `app/seekho-sikhao-woz/src/surfaces/student/screens/ChatScreen.tsx`
- [Student widgets](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/student/components/ChatBubble.tsx): interaction widgets · Chat bubbles, camera, drawing canvas, workbook cards, top bar, and feedback overlays. · `app/seekho-sikhao-woz/src/surfaces/student/components/ChatBubble.tsx`
- [Wizard tools](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/wizard/components/ComposePanel.tsx): control widgets · Compose panel, quick responses, greetings, incoming messages, and session info controls. · `app/seekho-sikhao-woz/src/surfaces/wizard/components/ComposePanel.tsx`
- [Teacher pages](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/teacher/screens/TeacherDashboard.tsx): monitoring pages · Login, class page, student profile, dashboard, and guardrails pages. · `app/seekho-sikhao-woz/src/surfaces/teacher/screens/TeacherDashboard.tsx`
- [Admin panels](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/surfaces/admin/components/EventLogFeed.tsx): ops panels · Event log feed, live chat view, manual events, session control, task tracker, and smileyometer delivery. · `app/seekho-sikhao-woz/src/surfaces/admin/components/EventLogFeed.tsx`

### Mobile app

Expo student app for the learner-only path.

- [Mobile app](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/seekho-student/App.tsx): expo app · React Native learner app packaged for native deployment. · `seekho-student/App.tsx`
- [Mobile entry](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/seekho-student/src/surfaces/entry/EntryScreen.tsx): entry surface · Native join flow for entering a session on mobile. · `seekho-student/src/surfaces/entry/EntryScreen.tsx`
- [Mobile student](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/seekho-student/src/surfaces/student/StudentApp.tsx): learning surface · Mobile student journey mirroring the web learner path. · `seekho-student/src/surfaces/student/StudentApp.tsx`
- [Mobile screens](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/seekho-student/src/surfaces/student/screens/ChatScreen.tsx): screen states · Login, subject selection, chat, workbook, and input mode screens. · `seekho-student/src/surfaces/student/screens/ChatScreen.tsx`

### Shared backend

Firebase-backed session, logging, storage, and analysis integrations.

- [Firebase core](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/firebase/config.ts): session backend · Shared live backend for session state, event logs, and demo-vs-live switching. · `app/seekho-sikhao-woz/src/firebase/config.ts`
- [Event logging](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/lib/autolog.ts): telemetry pipeline · Auto-capture and explicit domain events routed into session logs. · `app/seekho-sikhao-woz/src/lib/autolog.ts`
- [Media + TTS](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/seekho-sikhao-woz/src/firebase/storage.ts): aux services · Photo uploads in Firebase Storage and text-to-speech via the Vercel function. · `app/seekho-sikhao-woz/src/firebase/storage.ts`
- [Sheets export](https://github.com/abdullahsajidfr/seekho-sikhao/blob/main/app/docs/google-apps-script.js): analytics sink · Apps Script endpoint that mirrors study events into Google Sheets for analysis. · `app/docs/google-apps-script.js`

## Connections

- Web SPA → Room entry: routes to · Top-level SPA dispatches to room entry.
- Web SPA → Student UX: routes to · Top-level SPA dispatches to learner experience.
- Web SPA → Wizard console: routes to · Top-level SPA dispatches to operator console.
- Web SPA → Teacher view: routes to · Top-level SPA dispatches to teacher view.
- Web SPA → Admin ops: routes to · Top-level SPA dispatches to admin operations.
- Student UX → Student screens: uses · Learner flow is organized into screen states.
- Student UX → Student widgets: uses · Learner flow is composed from interactive widgets.
- Wizard console → Wizard tools: uses · Wizard console is built from control widgets.
- Teacher view → Teacher pages: uses · Teacher view is split into oversight pages.
- Admin ops → Admin panels: uses · Admin surface is assembled from operational panels.
- Mobile app → Mobile entry: routes to · Native app begins with session entry.
- Mobile app → Mobile student: routes to · Native app enters the learner experience.
- Mobile student → Mobile screens: uses · Mobile learner flow is organized into screens.
- Web SPA → Firebase core: connects to · Web surfaces read/write live session state when credentials are present.
- Mobile app → Firebase core: connects to · Mobile surfaces read/write the same session backend.
- Student UX → Event logging: emits · Student interaction telemetry is auto-captured and logged.
- Wizard console → Event logging: emits · Wizard actions and controls are logged as session events.
- Admin ops → Event logging: emits · Admin operations feed the same event stream.
- Mobile student → Event logging: emits · Mobile navigation and interaction telemetry is logged.
- Event logging → Firebase core: writes to · Primary per-session event store in Realtime Database.
- Event logging → Sheets export: mirrors to · Analytics events are exported for later analysis.
- Student UX → Media + TTS: uses · Learner flow can upload media and trigger speech output.
- Firebase core → Media + TTS: supports · Firebase Storage is the shared media backend; TTS is adjacent serverless support.
