Skip to content

Instantly share code, notes, and snippets.

@merelinguist
Created March 23, 2022 15:04
Show Gist options
  • Save merelinguist/3cff34bc03502607ecd88c4ee919f73f to your computer and use it in GitHub Desktop.
Save merelinguist/3cff34bc03502607ecd88c4ee919f73f to your computer and use it in GitHub Desktop.

How Strove Works

If you’re familiar with spaced reptition, you’ll know that there are a lot of approaches out there, and a lot of research. Anki, SuperMemo, Quizlet, Duolingo etc, all have their own proprietary algorithms implementing some variation on learning curves. When prototyping Strove, one of the things I discovered is that many of these algorithms, require a lot of unique information to be stored. For instance, SM2 stores an easinessFactor, dueDate, and interval for each card a user wants to learn. This is fine if you’re confident in an algorithm, but I wanted a more general-purpose solution that would allow me to fine-tune lesson generation over time.

Instead, the Prisma model looks something like this:

model Card {
  id        String  
  createdAt DateTime 
  front     String
  back      String
  answers   Answer[]
}

model Answer {
  id          String  
  createdAt   DateTime 
  correctness Float
  card        Card 
  cardId      String
}

This minimal solution, where we just store an answer each time a user attempts a card, actually contains everything we need to know! Now, instead of storing state, as is traditionally recommended, we can derive it from each Card's Answers.

to be continued

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment