All open-source packages
AISwift

educationai

Swift package for study apps: FSRS-6 spaced repetition, study queue, typed-answer matching and quizzes.

2StarsLatest Release: v2.0.0 · Updated: October 15, 2026
Platforms:iOS 17macOS 14tvOS 17watchOS 10visionOS 1

License: MIT

Summary

  • Learning logic for flashcard apps: FSRS-6 spaced repetition, a study queue, typed-answer grading and quizzes.
  • The tests replay 2,400 reviews from py-fsrs 6.3.2 over eight configurations and compare the results after every review.
  • SM2Scheduler keeps SM-2 data working and converts SM-2 cards to FSRS while keeping each card's due date.
  • It runs on the device with only Foundation, for Swift 6 strict concurrency, and contains no neural network.
  • 124 tests in 11 suites passed at tag v2.0.0 with Swift 6.4 on macOS 27.0.1.

EducationAI holds the learning logic of a flashcard or study app. FSRSScheduler decides when each card comes back with FSRS-6, the memory model behind Anki's FSRS scheduler, and its tests compare 2,400 reviews with the reference implementation, py-fsrs 6.3.2. SM2Scheduler keeps SM-2 data working and converts it to FSRS. Around the scheduler there is a study queue, typed-answer grading with typo tolerance, quizzes, a difficulty adjuster, a workload forecast, review statistics and study streaks. It runs on the device, uses only Foundation and is written for Swift 6 strict concurrency. There is no neural network in it: FSRS is a statistical memory model.

Features

  • FSRS-6 checked against the reference: the tests replay 2,400 reviews computed by py-fsrs 6.3.2 over eight configurations and compare stability, difficulty, due date and retrievability after every review
  • Learning and relearning steps, desired retention, maximum interval, interval fuzz and custom weights (21 from FSRS-6 or 19 from FSRS-5); a preview of all four ratings for the answer buttons
  • SM-2 as published, and a conversion of SM-2 cards to FSRS that keeps each card's due date
  • Typed-answer grading that ignores case, accents, width and punctuation without depending on the device language, forgives typos by answer length and does bounded work on hostile input
  • Multiple-choice and typed quizzes built from cards; each result suggests a rating for the scheduler, and a saved quiz is graded again when it is loaded
  • A study queue with daily limits, a per-day forecast, retention statistics, streaks counted in the learner's calendar days and a difficulty adjuster that keeps accuracy in a target band
  • Sendable, Codable value types: every function takes the date it works with, randomness comes from a generator you can seed, and stored values are checked before use instead of crashing
  • No dependencies, only Foundation; DocC reference with four guides and a StudyDeck example app for iOS and macOS

Quickstart

swift
1struct FlashcardsView: View {
2 @State private var cards = [
3 Flashcard(front: "Capital of Japan", back: "Tokyo"),
4 Flashcard(front: "Capital of Kenya", back: "Nairobi"),
5 Flashcard(front: "Capital of Peru", back: "Lima")
6 ]
7 @State private var showsAnswer = false
8 private let scheduler = FSRSScheduler.default
9 
10 var body: some View {
11 if let card = StudyQueue.cards(from: cards).first,
12 let index = cards.firstIndex(where: { $0.id == card.id }) {
13 VStack(spacing: 24) {
14 Text(card.front).font(.title)
15 if showsAnswer {
16 Text(card.back).font(.title2).bold()
17 HStack {
18 ForEach(Rating.allCases, id: \.self) { rating in
19 Button(String(describing: rating).capitalized) {
20 if let outcome = try? scheduler.review(card.review, rating: rating) {
21 cards[index].review = outcome.state
22 }
23 showsAnswer = false
24 }
25 .buttonStyle(.bordered)
26 }
27 }
28 } else {
29 Button("Show Answer") { showsAnswer = true }
30 .buttonStyle(.borderedProminent)
31 }
32 }
33 .padding()
34 } else {
35 Text("All done for now")
36 }
37 }
38}

Installation

Xcode (File › Add Package Dependencies…)

text
1https://github.com/muhittincamdali/educationai.git

Swift Package Manager (Package.swift)

swift
1dependencies: [
2 .package(url: "https://github.com/muhittincamdali/educationai.git", from: "2.0.0")
3],
4targets: [
5 .target(name: "YourApp", dependencies: [
6 .product(name: "EducationAI", package: "educationai")
7 ])
8]

Screenshots

The review screen of the example app: the card Capital of Vietnam with its answer Hanoi, memory at 90 %, and four rating buttons labeled 10m Again, 1mo Hard, 2mo Good and 3mo Easy
A typed-answer quiz question, Capital of Morocco, answered Raba: the feedback says Almost, it is spelled Rabat with one typo, and the card is scheduled as Hard
The progress screen: a 21-day streak, best streak 21, retention 91 %, 84 reviews, and a bar chart of the cards due on each of the next 14 days
The deck list: each capital with its country, when it is due and how well it is remembered now, such as Hanoi due now at 90 %

Timeline

  1. Repository opened; 1.0.0 tagged on 7 August: an EducationAI class with learning models, depending on Alamofire, RxSwift, SnapKit and SDWebImage

  2. Rewritten without dependencies as SM-2 scheduler, quiz, progress, recommendation and gamification engines

  3. A dependency on a local folder (../SwiftAI) and placeholder "neural tutor" and "enterprise" types were added; the package no longer resolved for anyone else

  4. 2.0.0: rebuilt around an FSRS-6 scheduler that matches py-fsrs 6.3.2; the June code and every 1.x type removed

Links

Related Article

Read the article