# jdmrtne/studykey architecture

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

- Interactive diagram: https://gitdiagram.com/jdmrtne/studykey
- Repository: https://github.com/jdmrtne/studykey

## Overview

Memora is a browser-only AI study companion: students add lessons, then use them to generate and study reviewers, quizzes, flashcards, and lesson-aware chat. The graph follows the documented lesson-ingestion and reviewer paths, and preserves quiz, flashcard, chat, reading, settings, and PWA capabilities. Source excerpts support the detailed ingestion, reviewer, AI-service, and persistence links; other capability links are dashed where implementation wiring was not shown.

Main entry points: [`src/App.tsx`](https://github.com/jdmrtne/studykey/blob/main/src/App.tsx) (Routes and shell), [`src/pages/Reviewer.tsx`](https://github.com/jdmrtne/studykey/blob/main/src/pages/Reviewer.tsx) (Reviewer generation), [`src/lib/aiService.ts`](https://github.com/jdmrtne/studykey/blob/main/src/lib/aiService.ts) (Generation and validation), [`src/pages/Lessons.tsx`](https://github.com/jdmrtne/studykey/blob/main/src/pages/Lessons.tsx) (Lesson management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App navigation"]
  node_router["Routes and shell<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
end

subgraph group_lessons["Lesson library"]
  node_lesson_manage["Lesson management<br/>[Lessons.tsx]"]
  node_pipeline["Document extraction"]
  node_lesson_state["Lesson library state<br/>[lessonsStore.ts]"]
  node_file_storage[("Original files<br/>[fileStore.ts]")]
  node_lesson_read["Lesson reader<br/>[LessonReader.tsx]"]
end

subgraph group_study["Study tools"]
  node_quiz["Quiz practice<br/>[Quiz.tsx]"]
  node_quiz_engine["Quiz gameplay<br/>[useQuizEngine.ts]"]
  node_flashcards["Flashcard generation<br/>[Flashcards.tsx]"]
  node_reviewer["Reviewer generation<br/>[Reviewer.tsx]"]
  node_review_view["Reviewer study view<br/>[ReviewerView.tsx]"]
  node_chat["Lesson chat<br/>[Chat.tsx]"]
  node_review_state[("Reviewer history<br/>[reviewerStore.ts]")]
end

subgraph group_ai["AI services"]
  node_ai_settings["AI settings<br/>[AISettings.tsx]"]
  node_ai_state["AI configuration state<br/>[aiSettingsStore.ts]"]
  node_ai_service["Generation and validation<br/>[aiService.ts]"]
  node_prompts["Generation prompts"]
  node_providers["Provider adapters"]
end

subgraph group_platform["Browser platform"]
  node_ai_storage[("Key persistence<br/>[storage.ts]")]
  node_local_storage[("Browser storage")]
  node_pwa["Install and offline support<br/>[installPrompt.ts]"]
end

node_student(("Student"))
node_external_ai{{"AI provider"}}

node_student -->|"opens"| node_router
node_router -->|"routes to"| node_dashboard
node_router -->|"routes to"| node_lesson_manage
node_router -->|"routes to"| node_lesson_read
node_router -->|"routes to"| node_quiz
node_router -->|"routes to"| node_flashcards
node_router -->|"routes to"| node_reviewer
node_router -->|"routes to"| node_chat
node_router -->|"routes to"| node_ai_settings
node_lesson_manage -->|"extracts and chunks"| node_pipeline
node_lesson_manage -->|"stores originals"| node_file_storage
node_lesson_manage -->|"adds lessons"| node_lesson_state
node_lesson_state -->|"persists lessons"| node_local_storage
node_lesson_state -->|"deletes originals"| node_file_storage
node_lesson_read -.->|"reads selected lesson"| node_lesson_state
node_quiz -.->|"runs practice"| node_quiz_engine
node_quiz -.->|"generates questions"| node_ai_service
node_flashcards -->|"generates cards"| node_ai_service
node_flashcards -->|"builds request"| node_prompts
node_reviewer -->|"requests generation"| node_ai_service
node_reviewer -->|"builds request"| node_prompts
node_reviewer -->|"saves reviewer"| node_review_state
node_reviewer -->|"renders result"| node_review_view
node_review_state -->|"persists history"| node_local_storage
node_chat -.->|"generates replies"| node_ai_service
node_chat -.->|"uses chat prompt"| node_prompts
node_ai_settings -->|"updates config"| node_ai_state
node_ai_state -->|"loads and saves"| node_ai_storage
node_ai_storage -->|"persists key"| node_local_storage
node_ai_state -->|"selects model"| node_providers
node_ai_service -->|"dispatches generation"| node_providers
node_providers -.->|"sends requests"| node_external_ai
node_pwa -.->|"offers installation"| node_student

click node_router "https://github.com/jdmrtne/studykey/blob/main/src/App.tsx"
click node_dashboard "https://github.com/jdmrtne/studykey/blob/main/src/pages/Dashboard.tsx"
click node_lesson_manage "https://github.com/jdmrtne/studykey/blob/main/src/pages/Lessons.tsx"
click node_pipeline "https://github.com/jdmrtne/studykey/blob/main/src/lib/documentPipeline.ts"
click node_lesson_state "https://github.com/jdmrtne/studykey/blob/main/src/store/lessonsStore.ts"
click node_file_storage "https://github.com/jdmrtne/studykey/blob/main/src/lib/fileStore.ts"
click node_lesson_read "https://github.com/jdmrtne/studykey/blob/main/src/pages/LessonReader.tsx"
click node_quiz "https://github.com/jdmrtne/studykey/blob/main/src/pages/Quiz.tsx"
click node_quiz_engine "https://github.com/jdmrtne/studykey/blob/main/src/hooks/useQuizEngine.ts"
click node_flashcards "https://github.com/jdmrtne/studykey/blob/main/src/pages/Flashcards.tsx"
click node_reviewer "https://github.com/jdmrtne/studykey/blob/main/src/pages/Reviewer.tsx"
click node_review_view "https://github.com/jdmrtne/studykey/blob/main/src/components/reviewer/ReviewerView.tsx"
click node_chat "https://github.com/jdmrtne/studykey/blob/main/src/pages/Chat.tsx"
click node_ai_settings "https://github.com/jdmrtne/studykey/blob/main/src/pages/AISettings.tsx"
click node_ai_state "https://github.com/jdmrtne/studykey/blob/main/src/store/aiSettingsStore.ts"
click node_ai_storage "https://github.com/jdmrtne/studykey/blob/main/src/lib/storage.ts"
click node_ai_service "https://github.com/jdmrtne/studykey/blob/main/src/lib/aiService.ts"
click node_prompts "https://github.com/jdmrtne/studykey/tree/main/src/prompts"
click node_providers "https://github.com/jdmrtne/studykey/tree/main/src/lib/providers"
click node_review_state "https://github.com/jdmrtne/studykey/blob/main/src/store/reviewerStore.ts"
click node_pwa "https://github.com/jdmrtne/studykey/blob/main/src/lib/pwa/installPrompt.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_router,node_dashboard toneBlue
class node_lesson_manage,node_pipeline,node_lesson_state,node_file_storage,node_lesson_read toneAmber
class node_quiz,node_quiz_engine,node_flashcards,node_reviewer,node_review_view,node_chat,node_review_state toneMint
class node_ai_settings,node_ai_state,node_ai_service,node_prompts,node_providers toneRose
class node_ai_storage,node_local_storage,node_pwa,node_student,node_external_ai toneIndigo
```

## Components

### App navigation

- [Routes and shell](https://github.com/jdmrtne/studykey/blob/main/src/App.tsx): `src/App.tsx`
- [Dashboard](https://github.com/jdmrtne/studykey/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`

### Lesson library

- [Lesson management](https://github.com/jdmrtne/studykey/blob/main/src/pages/Lessons.tsx): `src/pages/Lessons.tsx`
- [Document extraction](https://github.com/jdmrtne/studykey/blob/main/src/lib/documentPipeline.ts): `src/lib/documentPipeline.ts`
- [Lesson library state](https://github.com/jdmrtne/studykey/blob/main/src/store/lessonsStore.ts): `src/store/lessonsStore.ts`
- [Original files](https://github.com/jdmrtne/studykey/blob/main/src/lib/fileStore.ts): `src/lib/fileStore.ts`
- [Lesson reader](https://github.com/jdmrtne/studykey/blob/main/src/pages/LessonReader.tsx): `src/pages/LessonReader.tsx`

### Study tools

- [Quiz practice](https://github.com/jdmrtne/studykey/blob/main/src/pages/Quiz.tsx): `src/pages/Quiz.tsx`
- [Quiz gameplay](https://github.com/jdmrtne/studykey/blob/main/src/hooks/useQuizEngine.ts): `src/hooks/useQuizEngine.ts`
- [Flashcard generation](https://github.com/jdmrtne/studykey/blob/main/src/pages/Flashcards.tsx): `src/pages/Flashcards.tsx`
- [Reviewer generation](https://github.com/jdmrtne/studykey/blob/main/src/pages/Reviewer.tsx): `src/pages/Reviewer.tsx`
- [Reviewer study view](https://github.com/jdmrtne/studykey/blob/main/src/components/reviewer/ReviewerView.tsx): `src/components/reviewer/ReviewerView.tsx`
- [Lesson chat](https://github.com/jdmrtne/studykey/blob/main/src/pages/Chat.tsx): `src/pages/Chat.tsx`
- [Reviewer history](https://github.com/jdmrtne/studykey/blob/main/src/store/reviewerStore.ts): `src/store/reviewerStore.ts`

### AI services

- [AI settings](https://github.com/jdmrtne/studykey/blob/main/src/pages/AISettings.tsx): `src/pages/AISettings.tsx`
- [AI configuration state](https://github.com/jdmrtne/studykey/blob/main/src/store/aiSettingsStore.ts): `src/store/aiSettingsStore.ts`
- [Generation and validation](https://github.com/jdmrtne/studykey/blob/main/src/lib/aiService.ts): `src/lib/aiService.ts`
- [Generation prompts](https://github.com/jdmrtne/studykey/tree/main/src/prompts): `src/prompts`
- [Provider adapters](https://github.com/jdmrtne/studykey/tree/main/src/lib/providers): `src/lib/providers`

### Browser platform

- [Key persistence](https://github.com/jdmrtne/studykey/blob/main/src/lib/storage.ts): `src/lib/storage.ts`
- **Browser storage**
- [Install and offline support](https://github.com/jdmrtne/studykey/blob/main/src/lib/pwa/installPrompt.ts): `src/lib/pwa/installPrompt.ts`

### Other components

- **Student**
- **AI provider**

## Connections

- Student → Routes and shell: opens (evidence: `src/App.tsx`)
- Routes and shell → Dashboard: routes to (evidence: `src/App.tsx`)
- Routes and shell → Lesson management: routes to (evidence: `src/App.tsx`)
- Routes and shell → Lesson reader: routes to (evidence: `src/App.tsx`)
- Routes and shell → Quiz practice: routes to (evidence: `src/App.tsx`)
- Routes and shell → Flashcard generation: routes to (evidence: `src/App.tsx`)
- Routes and shell → Reviewer generation: routes to (evidence: `src/App.tsx`)
- Routes and shell → Lesson chat: routes to (evidence: `src/App.tsx`)
- Routes and shell → AI settings: routes to (evidence: `src/App.tsx`)
- Lesson management → Document extraction: extracts and chunks (evidence: `src/pages/Lessons.tsx`)
- Lesson management → Original files: stores originals (evidence: `src/pages/Lessons.tsx`)
- Lesson management → Lesson library state: adds lessons (evidence: `src/pages/Lessons.tsx`)
- Lesson library state → Browser storage: persists lessons (evidence: `src/store/lessonsStore.ts`)
- Lesson library state → Original files: deletes originals (evidence: `src/store/lessonsStore.ts`)
- Lesson reader → Lesson library state: reads selected lesson
- Quiz practice → Quiz gameplay: runs practice
- Quiz practice → Generation and validation: generates questions
- Flashcard generation → Generation and validation: generates cards (evidence: `src/lib/aiService.ts`)
- Flashcard generation → Generation prompts: builds request (evidence: `src/pages/Flashcards.tsx`)
- Reviewer generation → Generation and validation: requests generation (evidence: `src/pages/Reviewer.tsx`)
- Reviewer generation → Generation prompts: builds request (evidence: `src/pages/Reviewer.tsx`)
- Reviewer generation → Reviewer history: saves reviewer (evidence: `src/pages/Reviewer.tsx`)
- Reviewer generation → Reviewer study view: renders result (evidence: `src/pages/Reviewer.tsx`)
- Reviewer history → Browser storage: persists history (evidence: `src/store/reviewerStore.ts`)
- Lesson chat → Generation and validation: generates replies
- Lesson chat → Generation prompts: uses chat prompt
- AI settings → AI configuration state: updates config (evidence: `src/pages/AISettings.tsx`)
- AI configuration state → Key persistence: loads and saves (evidence: `src/store/aiSettingsStore.ts`)
- Key persistence → Browser storage: persists key (evidence: `src/lib/storage.ts`)
- AI configuration state → Provider adapters: selects model (evidence: `src/store/aiSettingsStore.ts`)
- Generation and validation → Provider adapters: dispatches generation (evidence: `src/lib/aiService.ts`)
- Provider adapters → AI provider: sends requests
- Install and offline support → Student: offers installation
