My App
LoopKitBackend

Card Generator

Automatic card generation from notes and templates

CardGenerator

Automatically generates flashcards when notes are created or templates are added to a note type.

Methods

generateCardsForNote

generateCardsForNote(
    note: NoteBase,
    noteType: NoteType,
    deckId: string,
    config: DeckConfig,
): CreateCardInput[]

Creates one CreateCardInput per template in the note type. Each card is initialized with the SRS algorithm's initial state (new state, starting ease factor from config).

Example: A "Basic + Reverse" note type with 2 templates generates 2 cards per note.

generateCardsForNewTemplate

generateCardsForNewTemplate(
    template: { id: string },
    notes: NoteBase[],
    deckId: string,
    config: DeckConfig,
): CreateCardInput[]

Generates cards for an existing set of notes when a new template is added to their note type. Creates one card per note for the new template.

How It Works

  1. The SRSAlgorithm.getInitialState() provides the starting SRS parameters
  2. Each card gets: state: 'new', easeFactor: config.startingEaseFactor, interval: 0
  3. Cards are linked to both the note (noteId) and the template (templateId)
  4. The deckId determines which deck the card belongs to

On this page