# motiandalou/typeflow architecture

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

- Interactive diagram: https://gitdiagram.com/motiandalou/typeflow
- Repository: https://github.com/motiandalou/typeflow

## Overview

TypeFlow is a browser-based English typing trainer. Users choose a built-in passage or paste their own text on the home page, then practice in a routed typing session; the session displays character-level feedback and timing/statistics, and completed runs are recorded for the history page. The app also offers word lookup and pronunciation during practice. Text and session history are held in client-side state, with history persisted in localStorage. Edges reflect shown imports, calls, and documented capabilities; the ResultDialog-to-session relationship is unverified.

Main entry points: [`src/pages/Practice.tsx`](https://github.com/motiandalou/typeflow/blob/main/src/pages/Practice.tsx) (Practice session), [`src/pages/Home.tsx`](https://github.com/motiandalou/typeflow/blob/main/src/pages/Home.tsx) (Text selection), [`src/store/typingStore.ts`](https://github.com/motiandalou/typeflow/blob/main/src/store/typingStore.ts) (Typing state), [`src/App.tsx`](https://github.com/motiandalou/typeflow/blob/main/src/App.tsx) (Route shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["App navigation"]
  node_app["Route shell<br/>[App.tsx]"]
  node_home["Text selection<br/>[Home.tsx]"]
end

subgraph group_practice["Practice content"]
  node_paste["Paste dialog<br/>[PasteDialog.tsx]"]
  node_library["Passage library<br/>[texts.ts]"]
  node_practice["Practice session<br/>[Practice.tsx]"]
end

subgraph group_engine["Typing engine"]
  node_typing["Character feedback<br/>[TypingText.tsx]"]
  node_metrics["Typing metrics<br/>[useTyping.ts]"]
  node_timer["Session timer<br/>[useTimer.ts]"]
  node_stats["Stats display<br/>[StatsBar.tsx]"]
  node_results["Result dialog<br/>[ResultDialog.tsx]"]
  node_sound["Typing sounds<br/>[sound.ts]"]
end

subgraph group_state["Session and history"]
  node_store["Typing state<br/>[typingStore.ts]"]
  node_history["History view<br/>[History.tsx]"]
end

node_user(("Learner"))
node_browser_audio["Browser audio"]
node_dictionary["Translation API"]
node_speech["Speech synthesis"]
node_local[("Browser storage")]

node_user -->|"selects text"| node_home
node_user -->|"pastes text"| node_paste
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_practice
node_app -->|"routes to"| node_history
node_home -->|"reads"| node_library
node_home -->|"renders"| node_paste
node_home -->|"sets text"| node_store
node_home -->|"navigates to"| node_practice
node_practice -->|"reads and updates"| node_store
node_practice -->|"calculates"| node_metrics
node_practice -->|"tracks time"| node_timer
node_practice -->|"renders"| node_typing
node_practice -->|"renders"| node_stats
node_practice -->|"plays"| node_sound
node_sound -->|"plays audio"| node_browser_audio
node_practice -->|"queries"| node_dictionary
node_practice -->|"speaks word"| node_speech
node_practice -.->|"may display"| node_results
node_practice -->|"records completion"| node_store
node_store -->|"persists history"| node_local
node_history -->|"reads history"| node_store

click node_app "https://github.com/motiandalou/typeflow/blob/main/src/App.tsx"
click node_home "https://github.com/motiandalou/typeflow/blob/main/src/pages/Home.tsx"
click node_paste "https://github.com/motiandalou/typeflow/blob/main/src/components/PasteDialog.tsx"
click node_library "https://github.com/motiandalou/typeflow/blob/main/src/data/texts.ts"
click node_practice "https://github.com/motiandalou/typeflow/blob/main/src/pages/Practice.tsx"
click node_typing "https://github.com/motiandalou/typeflow/blob/main/src/components/TypingText.tsx"
click node_metrics "https://github.com/motiandalou/typeflow/blob/main/src/hooks/useTyping.ts"
click node_timer "https://github.com/motiandalou/typeflow/blob/main/src/hooks/useTimer.ts"
click node_stats "https://github.com/motiandalou/typeflow/blob/main/src/components/StatsBar.tsx"
click node_results "https://github.com/motiandalou/typeflow/blob/main/src/components/ResultDialog.tsx"
click node_sound "https://github.com/motiandalou/typeflow/blob/main/src/lib/sound.ts"
click node_store "https://github.com/motiandalou/typeflow/blob/main/src/store/typingStore.ts"
click node_history "https://github.com/motiandalou/typeflow/blob/main/src/pages/History.tsx"

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_home,node_browser_audio toneBlue
class node_paste,node_library,node_practice,node_local toneAmber
class node_typing,node_metrics,node_timer,node_stats,node_results,node_sound,node_dictionary toneMint
class node_store,node_history toneRose
class node_user,node_speech toneIndigo
```

## Components

### App navigation

- [Route shell](https://github.com/motiandalou/typeflow/blob/main/src/App.tsx): `src/App.tsx`
- [Text selection](https://github.com/motiandalou/typeflow/blob/main/src/pages/Home.tsx): `src/pages/Home.tsx`

### Practice content

- [Paste dialog](https://github.com/motiandalou/typeflow/blob/main/src/components/PasteDialog.tsx): `src/components/PasteDialog.tsx`
- [Passage library](https://github.com/motiandalou/typeflow/blob/main/src/data/texts.ts): `src/data/texts.ts`
- [Practice session](https://github.com/motiandalou/typeflow/blob/main/src/pages/Practice.tsx): `src/pages/Practice.tsx`

### Typing engine

- [Character feedback](https://github.com/motiandalou/typeflow/blob/main/src/components/TypingText.tsx): `src/components/TypingText.tsx`
- [Typing metrics](https://github.com/motiandalou/typeflow/blob/main/src/hooks/useTyping.ts): `src/hooks/useTyping.ts`
- [Session timer](https://github.com/motiandalou/typeflow/blob/main/src/hooks/useTimer.ts): `src/hooks/useTimer.ts`
- [Stats display](https://github.com/motiandalou/typeflow/blob/main/src/components/StatsBar.tsx): `src/components/StatsBar.tsx`
- [Result dialog](https://github.com/motiandalou/typeflow/blob/main/src/components/ResultDialog.tsx): `src/components/ResultDialog.tsx`
- [Typing sounds](https://github.com/motiandalou/typeflow/blob/main/src/lib/sound.ts): `src/lib/sound.ts`

### Session and history

- [Typing state](https://github.com/motiandalou/typeflow/blob/main/src/store/typingStore.ts): `src/store/typingStore.ts`
- [History view](https://github.com/motiandalou/typeflow/blob/main/src/pages/History.tsx): `src/pages/History.tsx`

### Other components

- **Learner**
- **Browser audio**
- **Translation API**
- **Speech synthesis**
- **Browser storage**

## Connections

- Learner → Text selection: selects text (evidence: `README.md`)
- Learner → Paste dialog: pastes text (evidence: `README.md`)
- Route shell → Text selection: routes to (evidence: `src/App.tsx`)
- Route shell → Practice session: routes to (evidence: `src/App.tsx`)
- Route shell → History view: routes to (evidence: `src/App.tsx`)
- Text selection → Passage library: reads (evidence: `src/pages/Home.tsx`)
- Text selection → Paste dialog: renders (evidence: `src/pages/Home.tsx`)
- Text selection → Typing state: sets text (evidence: `src/pages/Home.tsx`)
- Text selection → Practice session: navigates to (evidence: `src/pages/Home.tsx`)
- Practice session → Typing state: reads and updates (evidence: `src/pages/Practice.tsx`)
- Practice session → Typing metrics: calculates (evidence: `src/pages/Practice.tsx`)
- Practice session → Session timer: tracks time (evidence: `src/pages/Practice.tsx`)
- Practice session → Character feedback: renders (evidence: `src/pages/Practice.tsx`)
- Practice session → Stats display: renders (evidence: `src/pages/Practice.tsx`)
- Practice session → Typing sounds: plays (evidence: `src/pages/Practice.tsx`)
- Typing sounds → Browser audio: plays audio (evidence: `src/lib/sound.ts`)
- Practice session → Translation API: queries (evidence: `src/pages/Practice.tsx`)
- Practice session → Speech synthesis: speaks word (evidence: `src/pages/Practice.tsx`)
- Practice session → Result dialog: may display
- Practice session → Typing state: records completion (evidence: `src/pages/Practice.tsx`)
- Typing state → Browser storage: persists history (evidence: `src/store/typingStore.ts`)
- History view → Typing state: reads history (evidence: `src/pages/History.tsx`)
