# hyeok-yoo/studymeter architecture

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

- Interactive diagram: https://gitdiagram.com/hyeok-yoo/studymeter
- Repository: https://github.com/hyeok-yoo/studymeter

## Overview

StudyMeter is an offline-first study-tracking app for web, PWA, and Android. The main workflow is to start and manage a study or countdown session, save its record locally, then review statistics or edit past sessions. During study, the focus monitor can analyze camera input for focus and drowsiness; after study, users can record evaluations and receive Gemini coaching based on their data. Settings also cover backups, AI configuration, and optional Home Assistant integration. The graph follows documented capabilities and visible references; several internal web and native integrations were not sampled, so uncertain links are omitted.

Main entry points: [`src/lib/db.ts`](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/db.ts) (Local records), [`src/components/focus/FocusPanel.tsx`](https://github.com/hyeok-yoo/studymeter/blob/main/src/components/focus/FocusPanel.tsx) (Focus monitor), [`src/pages/Study.tsx`](https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/Study.tsx) (Study screen), [`src/lib/ai/aiService.ts`](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/ai/aiService.ts) (AI coaching service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["App routes<br/>[App.tsx]"]
  node_settings["Settings and backup<br/>[Settings.tsx]"]
end

subgraph group_study["Study tracking"]
  node_studyui["Study screen<br/>[Study.tsx]"]
  node_timer["Study timer<br/>[useStudyTimer.ts]"]
  node_eval["Session evaluation"]
  node_countdown["Test countdown<br/>[TestTimerModal.tsx]"]
  node_store[("Local records<br/>[db.ts]")]
end

subgraph group_focus["Focus monitoring"]
  node_focusui["Focus monitor<br/>[FocusPanel.tsx]"]
  node_focusnative["Native focus hook<br/>[useFocusNative.ts]"]
  node_focusweb["Web focus hook<br/>[useFocusWeb.ts]"]
  node_pipeline["Focus pipeline<br/>[pipeline.ts]"]
  node_focusmodel["Local focus model<br/>[localModel.ts]"]
  node_drowsiness["Drowsiness alerts<br/>[useDrowsiness.ts]"]
end

subgraph group_insights["Records and coaching"]
  node_records["Study statistics<br/>[Records.tsx]"]
  node_edit["Record editor<br/>[EditRecords.tsx]"]
  node_chat["AI chat<br/>[GeminiChat.tsx]"]
  node_ai["AI coaching service<br/>[aiService.ts]"]
  node_router["Model selection<br/>[router.ts]"]
  node_gemini["Gemini API client<br/>[gemini.ts]"]
end

subgraph group_native["Native platform"]
  node_nativebridge["Native bridge<br/>[NativeBridge.ts]"]
  node_android["Android plugins<br/>[MainActivity.java]"]
  node_notification["Study notification"]
end

node_user(("Learner"))
node_google["Google Gemini"]
node_camera(("Device camera"))

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_studyui
node_studyui -.->|"manages time"| node_timer
node_timer -.->|"persists sessions"| node_store
node_studyui -.->|"records evaluation"| node_eval
node_studyui -->|"offers countdown"| node_countdown
node_eval -->|"saves evaluation"| node_store
node_user -->|"reviews progress"| node_records
node_records -->|"reads records"| node_store
node_user -->|"edits records"| node_edit
node_edit -.->|"updates records"| node_store
node_user -->|"starts monitoring"| node_focusui
node_focusui -->|"uses native hook"| node_focusnative
node_focusui -->|"uses web hook"| node_focusweb
node_focusnative -.->|"syncs focus data"| node_pipeline
node_focusweb -.->|"runs analysis"| node_pipeline
node_pipeline -->|"loads local model"| node_focusmodel
node_focusui -->|"monitors drowsiness"| node_drowsiness
node_camera -->|"provides video"| node_focusui
node_user -->|"requests coaching"| node_chat
node_chat -.->|"requests advice"| node_ai
node_ai -->|"selects models"| node_router
node_ai -->|"reads and caches"| node_store
node_router -->|"uses model client"| node_gemini
node_gemini -->|"sends requests"| node_google
node_user -->|"configures app"| node_settings
node_settings -->|"configures local data"| node_store
node_nativebridge -.->|"bridges native features"| node_android
node_android -->|"registers service"| node_notification

click node_app "https://github.com/hyeok-yoo/studymeter/blob/main/src/App.tsx"
click node_studyui "https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/Study.tsx"
click node_timer "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/useStudyTimer.ts"
click node_eval "https://github.com/hyeok-yoo/studymeter/blob/main/src/components/SessionEvalModal.tsx"
click node_countdown "https://github.com/hyeok-yoo/studymeter/blob/main/src/components/TestTimerModal.tsx"
click node_store "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/db.ts"
click node_records "https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/Records.tsx"
click node_edit "https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/EditRecords.tsx"
click node_focusui "https://github.com/hyeok-yoo/studymeter/blob/main/src/components/focus/FocusPanel.tsx"
click node_focusnative "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/useFocusNative.ts"
click node_focusweb "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/useFocusWeb.ts"
click node_pipeline "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/focus/pipeline.ts"
click node_focusmodel "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/focus/localModel.ts"
click node_drowsiness "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/useDrowsiness.ts"
click node_chat "https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/GeminiChat.tsx"
click node_ai "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/ai/aiService.ts"
click node_router "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/ai/router.ts"
click node_gemini "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/gemini.ts"
click node_settings "https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/Settings.tsx"
click node_nativebridge "https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/NativeBridge.ts"
click node_android "https://github.com/hyeok-yoo/studymeter/blob/main/android/app/src/main/java/com/studymeter/app/MainActivity.java"
click node_notification "https://github.com/hyeok-yoo/studymeter/blob/main/android/app/src/main/java/com/studymeter/app/StudyNotificationService.java"

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,node_settings toneBlue
class node_studyui,node_timer,node_eval,node_countdown,node_store toneAmber
class node_focusui,node_focusnative,node_focusweb,node_pipeline,node_focusmodel,node_drowsiness toneMint
class node_records,node_edit,node_chat,node_ai,node_router,node_gemini toneRose
class node_nativebridge,node_android,node_notification,node_user,node_google,node_camera toneIndigo
```

## Components

### Web application

- [App routes](https://github.com/hyeok-yoo/studymeter/blob/main/src/App.tsx): `src/App.tsx`
- [Settings and backup](https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/Settings.tsx): `src/pages/Settings.tsx`

### Study tracking

- [Study screen](https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/Study.tsx): `src/pages/Study.tsx`
- [Study timer](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/useStudyTimer.ts): `src/lib/useStudyTimer.ts`
- [Session evaluation](https://github.com/hyeok-yoo/studymeter/blob/main/src/components/SessionEvalModal.tsx): `src/components/SessionEvalModal.tsx`
- [Test countdown](https://github.com/hyeok-yoo/studymeter/blob/main/src/components/TestTimerModal.tsx): `src/components/TestTimerModal.tsx`
- [Local records](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Focus monitoring

- [Focus monitor](https://github.com/hyeok-yoo/studymeter/blob/main/src/components/focus/FocusPanel.tsx): `src/components/focus/FocusPanel.tsx`
- [Native focus hook](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/useFocusNative.ts): `src/lib/useFocusNative.ts`
- [Web focus hook](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/useFocusWeb.ts): `src/lib/useFocusWeb.ts`
- [Focus pipeline](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/focus/pipeline.ts): `src/lib/focus/pipeline.ts`
- [Local focus model](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/focus/localModel.ts): `src/lib/focus/localModel.ts`
- [Drowsiness alerts](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/useDrowsiness.ts): `src/lib/useDrowsiness.ts`

### Records and coaching

- [Study statistics](https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/Records.tsx): `src/pages/Records.tsx`
- [Record editor](https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/EditRecords.tsx): `src/pages/EditRecords.tsx`
- [AI chat](https://github.com/hyeok-yoo/studymeter/blob/main/src/pages/GeminiChat.tsx): `src/pages/GeminiChat.tsx`
- [AI coaching service](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/ai/aiService.ts): `src/lib/ai/aiService.ts`
- [Model selection](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/ai/router.ts): `src/lib/ai/router.ts`
- [Gemini API client](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/gemini.ts): `src/lib/gemini.ts`

### Native platform

- [Native bridge](https://github.com/hyeok-yoo/studymeter/blob/main/src/lib/NativeBridge.ts): `src/lib/NativeBridge.ts`
- [Android plugins](https://github.com/hyeok-yoo/studymeter/blob/main/android/app/src/main/java/com/studymeter/app/MainActivity.java): `android/app/src/main/java/com/studymeter/app/MainActivity.java`
- [Study notification](https://github.com/hyeok-yoo/studymeter/blob/main/android/app/src/main/java/com/studymeter/app/StudyNotificationService.java): `android/app/src/main/java/com/studymeter/app/StudyNotificationService.java`

### Other components

- **Learner**
- **Google Gemini**
- **Device camera**

## Connections

- Learner → App routes: opens (evidence: `README.md`)
- App routes → Study screen: routes to (evidence: `src/App.tsx`)
- Study screen → Study timer: manages time
- Study timer → Local records: persists sessions
- Study screen → Session evaluation: records evaluation
- Study screen → Test countdown: offers countdown (evidence: `README.md`)
- Session evaluation → Local records: saves evaluation (evidence: `src/components/SessionEvalModal.tsx`)
- Learner → Study statistics: reviews progress (evidence: `README.md`)
- Study statistics → Local records: reads records (evidence: `src/pages/Records.tsx`)
- Learner → Record editor: edits records (evidence: `README.md`)
- Record editor → Local records: updates records
- Learner → Focus monitor: starts monitoring (evidence: `README.md`)
- Focus monitor → Native focus hook: uses native hook (evidence: `src/components/focus/FocusPanel.tsx`)
- Focus monitor → Web focus hook: uses web hook (evidence: `src/components/focus/FocusPanel.tsx`)
- Native focus hook → Focus pipeline: syncs focus data
- Web focus hook → Focus pipeline: runs analysis
- Focus pipeline → Local focus model: loads local model (evidence: `src/lib/focus/pipeline.ts`)
- Focus monitor → Drowsiness alerts: monitors drowsiness (evidence: `src/components/focus/FocusPanel.tsx`)
- Device camera → Focus monitor: provides video (evidence: `README.md`)
- Learner → AI chat: requests coaching (evidence: `README.md`)
- AI chat → AI coaching service: requests advice
- AI coaching service → Model selection: selects models (evidence: `src/lib/ai/aiService.ts`)
- AI coaching service → Local records: reads and caches (evidence: `src/lib/ai/aiService.ts`)
- Model selection → Gemini API client: uses model client (evidence: `src/lib/ai/router.ts`)
- Gemini API client → Google Gemini: sends requests (evidence: `README.md`)
- Learner → Settings and backup: configures app (evidence: `README.md`)
- Settings and backup → Local records: configures local data (evidence: `src/pages/Settings.tsx`)
- Native bridge → Android plugins: bridges native features
- Android plugins → Study notification: registers service (evidence: `android/app/src/main/java/com/studymeter/app/MainActivity.java`)
