# tnm/hsk architecture

> Architecture diagram of the GitHub repository tnm/hsk, 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/tnm/hsk
- Repository: https://github.com/tnm/hsk

## Overview

HSK Cards is a browser-based vocabulary flashcard app. The user selects an HSK level, the app fetches its CSV deck and parses cards, then presents cards for flipping and navigation while tracking learned status. Shuffle, unlearned filtering, focus mode, keyboard/touch interaction, and dark mode are additional study capabilities. FlashcardApp owns deck loading and study state; browser local storage preserves preferences and progress. Some component internals and persistence details are outside the excerpts, so only documented or visible relationships are shown.

Main entry points: [`src/components/FlashcardApp.tsx`](https://github.com/tnm/hsk/blob/main/src/components/FlashcardApp.tsx) (Study orchestrator), [`src/App.tsx`](https://github.com/tnm/hsk/blob/main/src/App.tsx) (App entry), [`src/services/deckParsers.ts`](https://github.com/tnm/hsk/blob/main/src/services/deckParsers.ts) (CSV parser), [`src/components/DeckImporter.tsx`](https://github.com/tnm/hsk/blob/main/src/components/DeckImporter.tsx) (Deck importer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app_entry["App entry<br/>[App.tsx]"]
  node_study_orchestrator["Study orchestrator<br/>[FlashcardApp.tsx]"]
end

subgraph group_decks["Decks and parsing"]
  node_vocabulary_files["HSK 1–6 CSV"]
  node_csv_parser["CSV parser<br/>[deckParsers.ts]"]
  node_deck_importer["Deck importer<br/>[DeckImporter.tsx]"]
end

subgraph group_study["Study experience"]
  node_study_interface["Study components"]
  node_flashcard["Flashcard view<br/>[Flashcard.tsx]"]
  node_study_controls["Study controls<br/>[Controls.tsx]"]
  node_deck_selector["Deck selector<br/>[DeckSelector.tsx]"]
  node_navigation["Card navigation<br/>[Navigation.tsx]"]
  node_focus_controls["Focus controls<br/>[FocusControls.tsx]"]
end

subgraph group_browser["Browser state"]
  node_local_storage[("Local storage")]
end

node_learner(("Learner"))

node_learner -.->|"studies with"| node_app_entry
node_app_entry -->|"renders"| node_study_orchestrator
node_study_orchestrator -->|"fetches"| node_vocabulary_files
node_study_orchestrator -->|"parses with"| node_csv_parser
node_deck_importer -->|"uses parser"| node_csv_parser
node_study_orchestrator -->|"renders"| node_study_interface
node_study_orchestrator -->|"reads and writes"| node_local_storage
node_study_orchestrator -->|"renders"| node_flashcard
node_study_orchestrator -->|"renders"| node_deck_selector
node_study_orchestrator -->|"renders"| node_focus_controls

click node_app_entry "https://github.com/tnm/hsk/blob/main/src/App.tsx"
click node_study_orchestrator "https://github.com/tnm/hsk/blob/main/src/components/FlashcardApp.tsx"
click node_vocabulary_files "https://github.com/tnm/hsk/tree/main/public/data"
click node_csv_parser "https://github.com/tnm/hsk/blob/main/src/services/deckParsers.ts"
click node_deck_importer "https://github.com/tnm/hsk/blob/main/src/components/DeckImporter.tsx"
click node_study_interface "https://github.com/tnm/hsk/tree/main/src/components"
click node_flashcard "https://github.com/tnm/hsk/blob/main/src/components/Flashcard.tsx"
click node_study_controls "https://github.com/tnm/hsk/blob/main/src/components/Controls.tsx"
click node_deck_selector "https://github.com/tnm/hsk/blob/main/src/components/DeckSelector.tsx"
click node_navigation "https://github.com/tnm/hsk/blob/main/src/components/Navigation.tsx"
click node_focus_controls "https://github.com/tnm/hsk/blob/main/src/components/FocusControls.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_entry,node_study_orchestrator toneBlue
class node_vocabulary_files,node_csv_parser,node_deck_importer toneAmber
class node_study_interface,node_flashcard,node_study_controls,node_deck_selector,node_navigation,node_focus_controls toneMint
class node_local_storage toneRose
class node_learner toneIndigo
```

## Components

### Application

- [App entry](https://github.com/tnm/hsk/blob/main/src/App.tsx): `src/App.tsx`
- [Study orchestrator](https://github.com/tnm/hsk/blob/main/src/components/FlashcardApp.tsx): `src/components/FlashcardApp.tsx`

### Decks and parsing

- [HSK 1–6 CSV](https://github.com/tnm/hsk/tree/main/public/data): `public/data`
- [CSV parser](https://github.com/tnm/hsk/blob/main/src/services/deckParsers.ts): `src/services/deckParsers.ts`
- [Deck importer](https://github.com/tnm/hsk/blob/main/src/components/DeckImporter.tsx): `src/components/DeckImporter.tsx`

### Study experience

- [Study components](https://github.com/tnm/hsk/tree/main/src/components): `src/components`
- [Flashcard view](https://github.com/tnm/hsk/blob/main/src/components/Flashcard.tsx): `src/components/Flashcard.tsx`
- [Study controls](https://github.com/tnm/hsk/blob/main/src/components/Controls.tsx): `src/components/Controls.tsx`
- [Deck selector](https://github.com/tnm/hsk/blob/main/src/components/DeckSelector.tsx): `src/components/DeckSelector.tsx`
- [Card navigation](https://github.com/tnm/hsk/blob/main/src/components/Navigation.tsx): `src/components/Navigation.tsx`
- [Focus controls](https://github.com/tnm/hsk/blob/main/src/components/FocusControls.tsx): `src/components/FocusControls.tsx`

### Browser state

- **Local storage**

### Other components

- **Learner**

## Connections

- Learner → App entry: studies with (evidence: `README.md`)
- App entry → Study orchestrator: renders (evidence: `src/App.tsx`)
- Study orchestrator → HSK 1–6 CSV: fetches (evidence: `src/components/FlashcardApp.tsx`)
- Study orchestrator → CSV parser: parses with (evidence: `src/components/FlashcardApp.tsx`)
- Deck importer → CSV parser: uses parser (evidence: `src/components/DeckImporter.tsx`)
- Study orchestrator → Study components: renders (evidence: `src/components/FlashcardApp.tsx`)
- Study orchestrator → Local storage: reads and writes (evidence: `src/components/FlashcardApp.tsx`)
- Study orchestrator → Flashcard view: renders (evidence: `src/components/FlashcardApp.tsx`)
- Study orchestrator → Deck selector: renders (evidence: `src/components/FlashcardApp.tsx`)
- Study orchestrator → Focus controls: renders (evidence: `src/components/FlashcardApp.tsx`)
