# jmurarka/sahayak architecture

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

- Interactive diagram: https://gitdiagram.com/jmurarka/sahayak
- Repository: https://github.com/jmurarka/sahayak

## Overview

Sahayak is a voice-first math tutoring workspace: students work on a shared whiteboard, request a check or ask a spoken question, and receive step-level explanations and canvas annotations. The graph follows the documented board-to-diagnosis-to-feedback flow and the sampled API, AI, board, and voice calls. Some UI-to-API wiring and live-tool handling are not fully shown in the excerpts; those documented relationships cite the README, while uncertain implementation links are omitted.

Main entry points: [`app/page.tsx`](https://github.com/jmurarka/sahayak/blob/main/app/page.tsx) (Tutor Workspace), [`lib/ai.ts`](https://github.com/jmurarka/sahayak/blob/main/lib/ai.ts) (Math Reasoning), [`components/TutorPanel.tsx`](https://github.com/jmurarka/sahayak/blob/main/components/TutorPanel.tsx) (Tutor Panel), [`lib/gemini-live.ts`](https://github.com/jmurarka/sahayak/blob/main/lib/gemini-live.ts) (Gemini Live Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Tutoring Workspace"]
  node_workspace["Tutor Workspace<br/>[page.tsx]"]
  node_whiteboard["Interactive Board<br/>[Whiteboard.tsx]"]
  node_tutor["Tutor Panel<br/>[TutorPanel.tsx]"]
  node_language["Language Selector"]
  node_voicecontrols["Voice Controls<br/>[VoiceControls.tsx]"]
  node_annotations["Annotation Display<br/>[AIAnnotations.tsx]"]
end

subgraph group_reasoning["Board and Reasoning"]
  node_boardlogic["Board Perception<br/>[board.ts]"]
  node_analyze["Board Analysis API<br/>[route.ts]"]
  node_solve["Solve API<br/>[route.ts]"]
  node_reasoner["Math Reasoning<br/>[ai.ts]"]
  node_prompts["Tutoring Prompts<br/>[prompts.ts]"]
end

subgraph group_voice["Voice Interaction"]
  node_talkapi["Transcription API<br/>[route.ts]"]
  node_voiceapi["Voice Session API<br/>[route.ts]"]
  node_voiceclient["Voice Requests<br/>[voice.ts]"]
  node_livevoice["Gemini Live Client<br/>[gemini-live.ts]"]
end

subgraph group_contracts["Shared Contracts"]
  node_contracts["Board and Tutor Types<br/>[board-actions.ts]"]
end

node_student(("Student"))
node_groq{{"Groq Services"}}
node_gemini{{"Gemini Services"}}
node_browser{{"Browser Speech"}}

node_student -->|"works in"| node_workspace
node_workspace -->|"displays"| node_whiteboard
node_workspace -->|"displays"| node_tutor
node_tutor -->|"renders"| node_language
node_tutor -->|"renders"| node_voicecontrols
node_tutor -->|"renders"| node_annotations
node_whiteboard -->|"uses"| node_boardlogic
node_workspace -->|"captures board"| node_boardlogic
node_workspace -->|"submits board"| node_analyze
node_workspace -->|"submits question"| node_solve
node_analyze -->|"calls"| node_reasoner
node_solve -->|"calls"| node_reasoner
node_reasoner -->|"uses instructions"| node_prompts
node_reasoner -.->|"requests reasoning"| node_gemini
node_reasoner -.->|"requests reasoning"| node_groq
node_reasoner -.->|"returns board actions"| node_boardlogic
node_workspace -.->|"sends audio"| node_talkapi
node_voicecontrols -->|"transcribes audio"| node_voiceclient
node_voiceclient -->|"posts recording"| node_talkapi
node_talkapi -.->|"transcribes with"| node_groq
node_voicecontrols -.->|"fallback speech"| node_browser
node_workspace -->|"starts live tutoring"| node_livevoice
node_livevoice -->|"requests token"| node_voiceclient
node_voiceclient -->|"requests session"| node_voiceapi
node_voiceapi -->|"mints live token"| node_gemini
node_livevoice -.->|"streams audio"| node_gemini
node_livevoice -.->|"requests annotations"| node_boardlogic
node_workspace -->|"uses shared types"| node_contracts
node_reasoner -->|"uses shared types"| node_contracts

click node_workspace "https://github.com/jmurarka/sahayak/blob/main/app/page.tsx"
click node_whiteboard "https://github.com/jmurarka/sahayak/blob/main/components/Whiteboard.tsx"
click node_tutor "https://github.com/jmurarka/sahayak/blob/main/components/TutorPanel.tsx"
click node_language "https://github.com/jmurarka/sahayak/blob/main/components/LanguageSelector.tsx"
click node_voicecontrols "https://github.com/jmurarka/sahayak/blob/main/components/VoiceControls.tsx"
click node_annotations "https://github.com/jmurarka/sahayak/blob/main/components/AIAnnotations.tsx"
click node_boardlogic "https://github.com/jmurarka/sahayak/blob/main/lib/board.ts"
click node_analyze "https://github.com/jmurarka/sahayak/blob/main/app/api/analyze-board/route.ts"
click node_solve "https://github.com/jmurarka/sahayak/blob/main/app/api/solve/route.ts"
click node_reasoner "https://github.com/jmurarka/sahayak/blob/main/lib/ai.ts"
click node_prompts "https://github.com/jmurarka/sahayak/blob/main/lib/prompts.ts"
click node_talkapi "https://github.com/jmurarka/sahayak/blob/main/app/api/transcribe/route.ts"
click node_voiceapi "https://github.com/jmurarka/sahayak/blob/main/app/api/voice-session/route.ts"
click node_voiceclient "https://github.com/jmurarka/sahayak/blob/main/lib/voice.ts"
click node_livevoice "https://github.com/jmurarka/sahayak/blob/main/lib/gemini-live.ts"
click node_contracts "https://github.com/jmurarka/sahayak/blob/main/types/board-actions.ts"

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_workspace,node_whiteboard,node_tutor,node_language,node_voicecontrols,node_annotations,node_browser toneBlue
class node_boardlogic,node_analyze,node_solve,node_reasoner,node_prompts toneAmber
class node_talkapi,node_voiceapi,node_voiceclient,node_livevoice toneMint
class node_contracts toneRose
class node_student,node_groq,node_gemini toneIndigo
```

## Components

### Tutoring Workspace

- [Tutor Workspace](https://github.com/jmurarka/sahayak/blob/main/app/page.tsx): `app/page.tsx`
- [Interactive Board](https://github.com/jmurarka/sahayak/blob/main/components/Whiteboard.tsx): `components/Whiteboard.tsx`
- [Tutor Panel](https://github.com/jmurarka/sahayak/blob/main/components/TutorPanel.tsx): `components/TutorPanel.tsx`
- [Language Selector](https://github.com/jmurarka/sahayak/blob/main/components/LanguageSelector.tsx): `components/LanguageSelector.tsx`
- [Voice Controls](https://github.com/jmurarka/sahayak/blob/main/components/VoiceControls.tsx): `components/VoiceControls.tsx`
- [Annotation Display](https://github.com/jmurarka/sahayak/blob/main/components/AIAnnotations.tsx): `components/AIAnnotations.tsx`

### Board and Reasoning

- [Board Perception](https://github.com/jmurarka/sahayak/blob/main/lib/board.ts): `lib/board.ts`
- [Board Analysis API](https://github.com/jmurarka/sahayak/blob/main/app/api/analyze-board/route.ts): `app/api/analyze-board/route.ts`
- [Solve API](https://github.com/jmurarka/sahayak/blob/main/app/api/solve/route.ts): `app/api/solve/route.ts`
- [Math Reasoning](https://github.com/jmurarka/sahayak/blob/main/lib/ai.ts): `lib/ai.ts`
- [Tutoring Prompts](https://github.com/jmurarka/sahayak/blob/main/lib/prompts.ts): `lib/prompts.ts`

### Voice Interaction

- [Transcription API](https://github.com/jmurarka/sahayak/blob/main/app/api/transcribe/route.ts): `app/api/transcribe/route.ts`
- [Voice Session API](https://github.com/jmurarka/sahayak/blob/main/app/api/voice-session/route.ts): `app/api/voice-session/route.ts`
- [Voice Requests](https://github.com/jmurarka/sahayak/blob/main/lib/voice.ts): `lib/voice.ts`
- [Gemini Live Client](https://github.com/jmurarka/sahayak/blob/main/lib/gemini-live.ts): `lib/gemini-live.ts`

### Shared Contracts

- [Board and Tutor Types](https://github.com/jmurarka/sahayak/blob/main/types/board-actions.ts): `types/board-actions.ts`

### Other components

- **Student**
- **Groq Services**
- **Gemini Services**
- **Browser Speech**

## Connections

- Student → Tutor Workspace: works in (evidence: `README.md`)
- Tutor Workspace → Interactive Board: displays (evidence: `app/page.tsx`)
- Tutor Workspace → Tutor Panel: displays (evidence: `app/page.tsx`)
- Tutor Panel → Language Selector: renders (evidence: `components/TutorPanel.tsx`)
- Tutor Panel → Voice Controls: renders (evidence: `components/TutorPanel.tsx`)
- Tutor Panel → Annotation Display: renders (evidence: `components/TutorPanel.tsx`)
- Interactive Board → Board Perception: uses (evidence: `components/Whiteboard.tsx`)
- Tutor Workspace → Board Perception: captures board (evidence: `app/page.tsx`)
- Tutor Workspace → Board Analysis API: submits board (evidence: `README.md`)
- Tutor Workspace → Solve API: submits question (evidence: `README.md`)
- Board Analysis API → Math Reasoning: calls (evidence: `app/api/analyze-board/route.ts`)
- Solve API → Math Reasoning: calls (evidence: `app/api/solve/route.ts`)
- Math Reasoning → Tutoring Prompts: uses instructions (evidence: `lib/ai.ts`)
- Math Reasoning → Gemini Services: requests reasoning (evidence: `README.md`)
- Math Reasoning → Groq Services: requests reasoning (evidence: `README.md`)
- Math Reasoning → Board Perception: returns board actions (evidence: `README.md`)
- Tutor Workspace → Transcription API: sends audio (evidence: `README.md`)
- Voice Controls → Voice Requests: transcribes audio (evidence: `components/VoiceControls.tsx`)
- Voice Requests → Transcription API: posts recording (evidence: `lib/voice.ts`)
- Transcription API → Groq Services: transcribes with (evidence: `README.md`)
- Voice Controls → Browser Speech: fallback speech (evidence: `README.md`)
- Tutor Workspace → Gemini Live Client: starts live tutoring (evidence: `README.md`)
- Gemini Live Client → Voice Requests: requests token (evidence: `lib/gemini-live.ts`)
- Voice Requests → Voice Session API: requests session (evidence: `lib/voice.ts`)
- Voice Session API → Gemini Services: mints live token (evidence: `app/api/voice-session/route.ts`)
- Gemini Live Client → Gemini Services: streams audio (evidence: `README.md`)
- Gemini Live Client → Board Perception: requests annotations (evidence: `README.md`)
- Tutor Workspace → Board and Tutor Types: uses shared types (evidence: `app/page.tsx`)
- Math Reasoning → Board and Tutor Types: uses shared types (evidence: `lib/ai.ts`)
