• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
jonmaim

jonmaim

flashcard

anki-style flash cards
Public
Like
flashcard
Home
Code
10
backend
4
frontend
3
shared
2
.vtignore
AGENTS.md
ARCHITECTURE.md
GETTING_STARTED.md
README.md
deno.json
H
main.ts
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
shared
/
README.md
Code
/
shared
/
README.md
Search
11/11/2025
Viewing readonly version of main branch: v88
View latest version
README.md

Shared

This directory contains code shared between frontend and backend.

Files

  • types.ts - TypeScript interfaces and spaced repetition algorithm

Important Notes

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

Types

Data Models

  • Deck - Flashcard deck
  • Card - Individual flashcard with SR parameters
  • StudySession - Completed study session record
  • UserStats - Calculated statistics
  • UserData - Complete user data structure

Algorithm

  • Rating - Enum for card difficulty ratings (1-4)
  • ReviewResult - Result of SR calculation

Spaced Repetition Functions

calculateNextReview()

Implements the SM-2 algorithm to determine:

  • Next review date
  • Updated ease factor
  • Updated interval

isCardDue()

Checks if a card should be shown for review.

generateId()

Creates unique IDs for new records.

Algorithm Details

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.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.