flashcard
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v89View latest version
This directory contains code shared between frontend and backend.
- types.ts - TypeScript interfaces and spaced repetition algorithm
Code in this directory must work in both environments:
- β Standard JavaScript/TypeScript
- β No Deno-specific APIs (
Deno.*) - β No browser-specific APIs (
window,document) - β Use only standard ES modules
Deck- Flashcard deckCard- Individual flashcard with SR parametersStudySession- Completed study session recordUserStats- Calculated statisticsUserData- Complete user data structure
Rating- Enum for card difficulty ratings (1-4)ReviewResult- Result of SR calculation
Implements the SM-2 algorithm to determine:
- Next review date
- Updated ease factor
- Updated interval
Checks if a card should be shown for review.
Creates unique IDs for new records.
The SM-2 (SuperMemo 2) algorithm is the foundation of Anki's spaced repetition:
- easeFactor: How "easy" the card is (higher = longer intervals)
- interval: Days until next review
- nextReview: Specific date/time for next review
See ARCHITECTURE.md for full algorithm documentation.