# taoist22/sn-flashcards architecture

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

- Interactive diagram: https://gitdiagram.com/taoist22/sn-flashcards
- Repository: https://github.com/taoist22/sn-flashcards

## Overview

Flashcards for Supernote is a React Native spaced-repetition plugin. Users create or import cards, optionally capture handwriting from a note, organize cards into decks, then study and record FSRS reviews; cards and settings persist locally, with optional Anki text exchange and image/ink features. App.tsx is the sampled UI orchestrator. README capabilities such as note-based deck suggestions, hints, images, and stats are represented, though their internal implementation is not fully sampled; only shown or documented relationships are connected.

Main entry points: [`App.tsx`](https://github.com/taoist22/sn-flashcards/blob/main/App.tsx) (Plugin UI), [`src/services/ankiText.ts`](https://github.com/taoist22/sn-flashcards/blob/main/src/services/ankiText.ts) (Anki text exchange), [`src/services/store.ts`](https://github.com/taoist22/sn-flashcards/blob/main/src/services/store.ts) (Domain store), [`src/services/inkCapture.ts`](https://github.com/taoist22/sn-flashcards/blob/main/src/services/inkCapture.ts) (Ink and image capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product["Plugin workflow"]
  node_app["Plugin UI<br/>[App.tsx]"]
  node_deck["Deck management<br/>[App.tsx]"]
  node_cardcreate["Card creation<br/>[App.tsx]"]
  node_notelink["Note suggestions<br/>[App.tsx]"]
  node_study["Study and stats<br/>[App.tsx]"]
  node_ocr["Lasso OCR<br/>[lassoOcr.ts]"]
  node_capture["Ink and image capture<br/>[inkCapture.ts]"]
end

subgraph group_domain["Cards and scheduling"]
  node_cardmodel["Card and deck model<br/>[flashcards.ts]"]
  node_store["Domain store<br/>[store.ts]"]
  node_scheduler["FSRS scheduling<br/>[fsrsScheduler.ts]"]
end

subgraph group_platform["Device services"]
  node_inkjs["Ink surface bridge<br/>[inkSurface.ts]"]
  node_inkcomponent["Ink surface view<br/>[InkSurface.tsx]"]
  node_inknative["Native pen engine"]
  node_inkview["Native host view"]
  node_storagejs["Storage bridge<br/>[nativeStorage.ts]"]
  node_storageandroid[("Android file storage")]
  node_permissions["File permissions"]
end

subgraph group_exchange["Anki exchange"]
  node_backup["Backup and restore<br/>[backup.ts]"]
  node_anki["Anki text exchange<br/>[ankiText.ts]"]
end

node_user(("Supernote user"))
node_note["Current note"]
node_ankiuser["Anki text files"]

node_user -->|"uses"| node_app
node_app -->|"manages"| node_deck
node_app -->|"creates"| node_cardcreate
node_app -->|"configures"| node_notelink
node_app -->|"starts"| node_study
node_note -->|"provides context"| node_app
node_app -->|"requests recognition"| node_ocr
node_ocr -->|"renders lasso images"| node_capture
node_app -->|"imports images"| node_capture
node_app -->|"updates domain state"| node_store
node_store -->|"uses types"| node_cardmodel
node_store -->|"schedules reviews"| node_scheduler
node_store -->|"loads and saves"| node_storagejs
node_storagejs -->|"calls native storage"| node_storageandroid
node_app -->|"backs up data"| node_backup
node_app -->|"imports and exports"| node_anki
node_anki -->|"fingerprints cards"| node_store
node_anki -->|"reads and writes files"| node_storagejs
node_anki -->|"exchanges text files"| node_ankiuser
node_app -->|"checks permissions"| node_permissions
node_capture -->|"requests access"| node_permissions
node_anki -->|"requests access"| node_permissions
node_app -->|"renders"| node_inkcomponent
node_inkcomponent -.->|"uses bridge"| node_inkjs
node_inknative -->|"hosts pen engine"| node_inkview

click node_app "https://github.com/taoist22/sn-flashcards/blob/main/App.tsx"
click node_deck "https://github.com/taoist22/sn-flashcards/blob/main/App.tsx"
click node_cardcreate "https://github.com/taoist22/sn-flashcards/blob/main/App.tsx"
click node_notelink "https://github.com/taoist22/sn-flashcards/blob/main/App.tsx"
click node_study "https://github.com/taoist22/sn-flashcards/blob/main/App.tsx"
click node_cardmodel "https://github.com/taoist22/sn-flashcards/blob/main/src/types/flashcards.ts"
click node_store "https://github.com/taoist22/sn-flashcards/blob/main/src/services/store.ts"
click node_scheduler "https://github.com/taoist22/sn-flashcards/blob/main/src/services/fsrsScheduler.ts"
click node_ocr "https://github.com/taoist22/sn-flashcards/blob/main/src/services/lassoOcr.ts"
click node_capture "https://github.com/taoist22/sn-flashcards/blob/main/src/services/inkCapture.ts"
click node_inkjs "https://github.com/taoist22/sn-flashcards/blob/main/src/services/inkSurface.ts"
click node_inkcomponent "https://github.com/taoist22/sn-flashcards/blob/main/src/components/InkSurface.tsx"
click node_inknative "https://github.com/taoist22/sn-flashcards/blob/main/android/app/src/main/java/com/supernoteflashcards/InkSurfaceModule.kt"
click node_inkview "https://github.com/taoist22/sn-flashcards/blob/main/android/app/src/main/java/com/supernoteflashcards/InkSurfaceViewManager.kt"
click node_storagejs "https://github.com/taoist22/sn-flashcards/blob/main/src/services/nativeStorage.ts"
click node_storageandroid "https://github.com/taoist22/sn-flashcards/blob/main/android/app/src/main/java/com/supernoteflashcards/FlashcardStorageModule.java"
click node_permissions "https://github.com/taoist22/sn-flashcards/blob/main/src/services/pluginPermissions.ts"
click node_backup "https://github.com/taoist22/sn-flashcards/blob/main/src/services/backup.ts"
click node_anki "https://github.com/taoist22/sn-flashcards/blob/main/src/services/ankiText.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,node_deck,node_cardcreate,node_notelink,node_study,node_ocr,node_capture,node_user toneBlue
class node_cardmodel,node_store,node_scheduler toneAmber
class node_inkjs,node_inkcomponent,node_inknative,node_inkview,node_storagejs,node_storageandroid,node_permissions toneMint
class node_backup,node_anki toneRose
class node_note,node_ankiuser toneIndigo
```

## Components

### Plugin workflow

- [Plugin UI](https://github.com/taoist22/sn-flashcards/blob/main/App.tsx): `App.tsx`
- [Deck management](https://github.com/taoist22/sn-flashcards/blob/main/App.tsx): `App.tsx`
- [Card creation](https://github.com/taoist22/sn-flashcards/blob/main/App.tsx): `App.tsx`
- [Note suggestions](https://github.com/taoist22/sn-flashcards/blob/main/App.tsx): `App.tsx`
- [Study and stats](https://github.com/taoist22/sn-flashcards/blob/main/App.tsx): `App.tsx`
- [Lasso OCR](https://github.com/taoist22/sn-flashcards/blob/main/src/services/lassoOcr.ts): `src/services/lassoOcr.ts`
- [Ink and image capture](https://github.com/taoist22/sn-flashcards/blob/main/src/services/inkCapture.ts): `src/services/inkCapture.ts`

### Cards and scheduling

- [Card and deck model](https://github.com/taoist22/sn-flashcards/blob/main/src/types/flashcards.ts): `src/types/flashcards.ts`
- [Domain store](https://github.com/taoist22/sn-flashcards/blob/main/src/services/store.ts): `src/services/store.ts`
- [FSRS scheduling](https://github.com/taoist22/sn-flashcards/blob/main/src/services/fsrsScheduler.ts): `src/services/fsrsScheduler.ts`

### Device services

- [Ink surface bridge](https://github.com/taoist22/sn-flashcards/blob/main/src/services/inkSurface.ts): `src/services/inkSurface.ts`
- [Ink surface view](https://github.com/taoist22/sn-flashcards/blob/main/src/components/InkSurface.tsx): `src/components/InkSurface.tsx`
- [Native pen engine](https://github.com/taoist22/sn-flashcards/blob/main/android/app/src/main/java/com/supernoteflashcards/InkSurfaceModule.kt): `android/app/src/main/java/com/supernoteflashcards/InkSurfaceModule.kt`
- [Native host view](https://github.com/taoist22/sn-flashcards/blob/main/android/app/src/main/java/com/supernoteflashcards/InkSurfaceViewManager.kt): `android/app/src/main/java/com/supernoteflashcards/InkSurfaceViewManager.kt`
- [Storage bridge](https://github.com/taoist22/sn-flashcards/blob/main/src/services/nativeStorage.ts): `src/services/nativeStorage.ts`
- [Android file storage](https://github.com/taoist22/sn-flashcards/blob/main/android/app/src/main/java/com/supernoteflashcards/FlashcardStorageModule.java): `android/app/src/main/java/com/supernoteflashcards/FlashcardStorageModule.java`
- [File permissions](https://github.com/taoist22/sn-flashcards/blob/main/src/services/pluginPermissions.ts): `src/services/pluginPermissions.ts`

### Anki exchange

- [Backup and restore](https://github.com/taoist22/sn-flashcards/blob/main/src/services/backup.ts): `src/services/backup.ts`
- [Anki text exchange](https://github.com/taoist22/sn-flashcards/blob/main/src/services/ankiText.ts): `src/services/ankiText.ts`

### Other components

- **Supernote user**
- **Current note**
- **Anki text files**

## Connections

- Supernote user → Plugin UI: uses (evidence: `README.md`)
- Plugin UI → Deck management: manages (evidence: `README.md`)
- Plugin UI → Card creation: creates (evidence: `README.md`)
- Plugin UI → Note suggestions: configures (evidence: `README.md`)
- Plugin UI → Study and stats: starts (evidence: `README.md`)
- Current note → Plugin UI: provides context (evidence: `README.md`)
- Plugin UI → Lasso OCR: requests recognition (evidence: `App.tsx`)
- Lasso OCR → Ink and image capture: renders lasso images (evidence: `src/services/lassoOcr.ts`)
- Plugin UI → Ink and image capture: imports images (evidence: `App.tsx`)
- Plugin UI → Domain store: updates domain state (evidence: `App.tsx`)
- Domain store → Card and deck model: uses types (evidence: `src/services/store.ts`)
- Domain store → FSRS scheduling: schedules reviews (evidence: `src/services/store.ts`)
- Domain store → Storage bridge: loads and saves (evidence: `src/services/store.ts`)
- Storage bridge → Android file storage: calls native storage (evidence: `src/services/nativeStorage.ts`)
- Plugin UI → Backup and restore: backs up data (evidence: `App.tsx`)
- Plugin UI → Anki text exchange: imports and exports (evidence: `App.tsx`)
- Anki text exchange → Domain store: fingerprints cards (evidence: `src/services/ankiText.ts`)
- Anki text exchange → Storage bridge: reads and writes files (evidence: `src/services/ankiText.ts`)
- Anki text exchange → Anki text files: exchanges text files (evidence: `README.md`)
- Plugin UI → File permissions: checks permissions (evidence: `App.tsx`)
- Ink and image capture → File permissions: requests access (evidence: `src/services/inkCapture.ts`)
- Anki text exchange → File permissions: requests access (evidence: `src/services/ankiText.ts`)
- Plugin UI → Ink surface view: renders (evidence: `App.tsx`)
- Ink surface view → Ink surface bridge: uses bridge
- Native pen engine → Native host view: hosts pen engine (evidence: `android/app/src/main/java/com/supernoteflashcards/InkSurfaceViewManager.kt`)
