# kayadhomrtg-del/studyhub architecture

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

- Interactive diagram: https://gitdiagram.com/kayadhomrtg-del/studyhub
- Repository: https://github.com/kayadhomrtg-del/studyhub

## Overview

College Study Hub is a browser-first, local study workspace. Learners organize course modules and materials, then manage notes, assignments, search, and planned or guided-recall sessions; records and imported files stay in on-device IndexedDB. The optional AI branch extracts selected material, prepares a reviewable request, and sends it through a gated local proxy only after approval. Backup/restore and offline app-shell support are additional capabilities. Some page and server internals were not excerpted, so those links are included only where the README or source index supports them.

Main entry points: [`src/App.tsx`](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/App.tsx) (Browser app), [`src/features/modules/moduleDatabase.ts`](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/modules/moduleDatabase.ts) (IndexedDB), [`server/ai/pipeline.ts`](https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/pipeline.ts) (Request pipeline), [`src/features/materials/MaterialService.ts`](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/materials/MaterialService.ts) (Materials)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Study workspace"]
  node_app["Browser app<br/>[App.tsx]"]
end

subgraph group_study["Study features"]
  node_materials["Materials<br/>[MaterialService.ts]"]
  node_modules["Modules and topics<br/>[ModuleService.ts]"]
  node_notes["Notes<br/>[NoteService.ts]"]
  node_tasks["Assignments<br/>[TaskService.ts]"]
  node_sessions["Study sessions"]
  node_recall["Guided recall"]
  node_search["Workspace search<br/>[SearchService.ts]"]
  node_searchrepo["Search corpus"]
end

subgraph group_persistence["Local data"]
  node_database[("IndexedDB<br/>[moduleDatabase.ts]")]
end

subgraph group_ai["Optional AI"]
  node_aiui["AI review UI<br/>[AiSummaryPage.tsx]"]
  node_airequest["AI request client"]
  node_aipipeline["Request pipeline<br/>[pipeline.ts]"]
  node_aigates["Runtime gates<br/>[gates.ts]"]
  node_aivalidation["Request validation"]
  node_aiprovider["Provider dispatch<br/>[provider.ts]"]
end

subgraph group_resilience["Backup and offline"]
  node_backup["Backup and restore<br/>[BackupService.ts]"]
  node_serviceworker["Offline app shell<br/>[sw.js]"]
end

node_learner(("Learner"))
node_gemini{{"Gemini"}}

node_learner -->|"uses"| node_app
node_app -->|"stores study data"| node_database
node_app -->|"opens materials"| node_materials
node_app -->|"organizes courses"| node_modules
node_app -->|"manages notes"| node_notes
node_app -->|"tracks assignments"| node_tasks
node_app -->|"plans sessions"| node_sessions
node_app -->|"searches workspace"| node_search
node_app -->|"exports or restores"| node_backup
node_app -->|"runs offline shell"| node_serviceworker
node_recall -->|"loads and saves"| node_sessions
node_recall -->|"saves recall notes"| node_notes
node_search -->|"gets corpus"| node_searchrepo
node_searchrepo -->|"reads records"| node_database
node_materials -->|"persists materials"| node_database
node_notes -->|"uses local store"| node_database
node_tasks -->|"uses local store"| node_database
node_sessions -->|"uses local store"| node_database
node_aiui -.->|"requests assistance"| node_airequest
node_airequest -.->|"sends approved request"| node_aipipeline
node_aipipeline -->|"evaluates gates"| node_aigates
node_aipipeline -->|"validates payload"| node_aivalidation
node_aipipeline -.->|"dispatches request"| node_aiprovider
node_aiprovider -.->|"calls provider"| node_gemini
node_materials -->|"provides selected text"| node_aiui

click node_app "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/App.tsx"
click node_materials "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/materials/MaterialService.ts"
click node_modules "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/modules/ModuleService.ts"
click node_notes "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/notes/NoteService.ts"
click node_tasks "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/tasks/TaskService.ts"
click node_sessions "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/studySessions/StudySessionService.ts"
click node_recall "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/pages/StudySessionReviewPage.tsx"
click node_search "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/search/SearchService.ts"
click node_searchrepo "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/search/SearchRepository.ts"
click node_database "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/modules/moduleDatabase.ts"
click node_backup "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/backup/BackupService.ts"
click node_serviceworker "https://github.com/kayadhomrtg-del/studyhub/blob/main/public/sw.js"
click node_aiui "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/ai/AiSummaryPage.tsx"
click node_airequest "https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/ai/useAiFeatureRequest.ts"
click node_aipipeline "https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/pipeline.ts"
click node_aigates "https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/gates.ts"
click node_aivalidation "https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/requestValidation.ts"
click node_aiprovider "https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/provider.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_app toneBlue
class node_materials,node_modules,node_notes,node_tasks,node_sessions,node_recall,node_search,node_searchrepo toneAmber
class node_database toneMint
class node_aiui,node_airequest,node_aipipeline,node_aigates,node_aivalidation,node_aiprovider toneRose
class node_backup,node_serviceworker,node_learner,node_gemini toneIndigo
```

## Components

### Study workspace

- [Browser app](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/App.tsx): `src/App.tsx`

### Study features

- [Materials](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/materials/MaterialService.ts): `src/features/materials/MaterialService.ts`
- [Modules and topics](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/modules/ModuleService.ts): `src/features/modules/ModuleService.ts`
- [Notes](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/notes/NoteService.ts): `src/features/notes/NoteService.ts`
- [Assignments](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/tasks/TaskService.ts): `src/features/tasks/TaskService.ts`
- [Study sessions](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/studySessions/StudySessionService.ts): `src/features/studySessions/StudySessionService.ts`
- [Guided recall](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/pages/StudySessionReviewPage.tsx): `src/pages/StudySessionReviewPage.tsx`
- [Workspace search](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/search/SearchService.ts): `src/features/search/SearchService.ts`
- [Search corpus](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/search/SearchRepository.ts): `src/features/search/SearchRepository.ts`

### Local data

- [IndexedDB](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/modules/moduleDatabase.ts): `src/features/modules/moduleDatabase.ts`

### Optional AI

- [AI review UI](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/ai/AiSummaryPage.tsx): `src/features/ai/AiSummaryPage.tsx`
- [AI request client](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/ai/useAiFeatureRequest.ts): `src/features/ai/useAiFeatureRequest.ts`
- [Request pipeline](https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/pipeline.ts): `server/ai/pipeline.ts`
- [Runtime gates](https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/gates.ts): `server/ai/gates.ts`
- [Request validation](https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/requestValidation.ts): `server/ai/requestValidation.ts`
- [Provider dispatch](https://github.com/kayadhomrtg-del/studyhub/blob/main/server/ai/provider.ts): `server/ai/provider.ts`

### Backup and offline

- [Backup and restore](https://github.com/kayadhomrtg-del/studyhub/blob/main/src/features/backup/BackupService.ts): `src/features/backup/BackupService.ts`
- [Offline app shell](https://github.com/kayadhomrtg-del/studyhub/blob/main/public/sw.js): `public/sw.js`

### Other components

- **Learner**
- **Gemini**

## Connections

- Learner → Browser app: uses (evidence: `README.md`)
- Browser app → IndexedDB: stores study data (evidence: `README.md`)
- Browser app → Materials: opens materials (evidence: `README.md`)
- Browser app → Modules and topics: organizes courses (evidence: `README.md`)
- Browser app → Notes: manages notes (evidence: `README.md`)
- Browser app → Assignments: tracks assignments (evidence: `README.md`)
- Browser app → Study sessions: plans sessions (evidence: `README.md`)
- Browser app → Workspace search: searches workspace (evidence: `README.md`)
- Browser app → Backup and restore: exports or restores (evidence: `README.md`)
- Browser app → Offline app shell: runs offline shell (evidence: `README.md`)
- Guided recall → Study sessions: loads and saves (evidence: `src/pages/StudySessionReviewPage.tsx`)
- Guided recall → Notes: saves recall notes (evidence: `src/pages/StudySessionReviewPage.tsx`)
- Workspace search → Search corpus: gets corpus (evidence: `src/features/search/SearchService.ts`)
- Search corpus → IndexedDB: reads records (evidence: `src/features/search/SearchRepository.ts`)
- Materials → IndexedDB: persists materials (evidence: `src/features/materials/MaterialService.ts`)
- Notes → IndexedDB: uses local store (evidence: `src/features/notes/NoteService.ts`)
- Assignments → IndexedDB: uses local store (evidence: `src/features/tasks/TaskService.ts`)
- Study sessions → IndexedDB: uses local store (evidence: `src/features/studySessions/StudySessionService.ts`)
- AI review UI → AI request client: requests assistance
- AI request client → Request pipeline: sends approved request
- Request pipeline → Runtime gates: evaluates gates (evidence: `server/ai/pipeline.ts`)
- Request pipeline → Request validation: validates payload (evidence: `server/ai/pipeline.ts`)
- Request pipeline → Provider dispatch: dispatches request (evidence: `server/ai/pipeline.ts`)
- Provider dispatch → Gemini: calls provider
- Materials → AI review UI: provides selected text (evidence: `README.md`)
