AI Flashcard System
Card Generation and Spaced Repetition
Design a flashcard app that turns a student's notes and PDFs into cards with a language model, then schedules each card for review just before it would be forgotten, on and offline.
Overview
A flashcard app shows a question, the student tries to recall the answer, then rates how well they did. Spaced repetition uses those ratings to schedule each card: a card you know well comes back in weeks, one you missed comes back tomorrow. Anki and SuperMemo are built on this; SuperMemo's SM-2 algorithm dates from its first program in December 1987.
The AI part removes the slowest step for students: writing cards. The student uploads lecture notes or a textbook chapter, and a language model drafts question and answer pairs. Drafts need care. A model can write a card whose answer is not in the source, or ten cards that ask the same thing, so every card is checked against its source text and the student approves the deck before studying it.
Questions to ask first
Before drawing anything, settle the scale, the inputs and where review happens. Each question comes with the answer this design assumes.
- How many learners? 1 million a day, about 60 reviews each.
- What goes in? PDFs, pasted notes and web pages: 50,000 documents a day, about 30 pages each.
- Must review work offline? Yes, on phones, with a sync when they are back online.
- Which scheduler? FSRS by default, with SM-2 available. Both run on the device.
- Do AI cards go straight into the deck? No. The student approves the drafts first.
- Interoperability? Decks export as Anki packages.
The design at a glance
The student's app, which keeps a local database and runs the scheduler, sends an uploaded document to the API, which saves the file with the uploaded files and puts a job on the generation queue. The card generator takes the job, chunks the document, drafts cards with a language model, checks them and writes them to the store of decks, cards and review logs, sharded by user_id. Reviews happen on the device; the app's review events go through the sync service into the same store, and a nightly optimizer reads the logs to fit each student's FSRS weights. The Visual Explanation below draws this design, and the sections that follow start where a deck starts, with generating its cards.
What you will be able to do
- Build a pipeline that drafts cards from a long document and rejects ones its source does not support.
- Explain SM-2 step by step and trace a card through several reviews.
- Explain FSRS's forgetting curve and how desired retention sets the next interval.
- Design offline review so two devices never corrupt a card's schedule.
- Size the system and say which parts need a server at all.
Key concepts
- Spaced repetition
- Forgetting curve
- SM-2 ease factor
- FSRS and desired retention
- Chunked generation
- Grounding check
- Review log as events
- Offline-first sync
- Idempotent upload
Functional requirements
- Upload a PDF, notes or a web page and receive draft cards (question and answer, or cloze deletion)
- Review, edit, approve or discard drafts before they join a deck
- Show the cards due today and schedule each card from the student's rating
- Review offline and sync across phone, tablet and web
- Show progress: due counts, retention, a forecast of upcoming reviews
- Export a deck as an Anki package (.apkg)
Non-functional requirements
- Drafts for a 30-page document ready in under 3 minutes at p95 (a target we chose)
- The next card appears in under 100 ms, because it comes from the local database (a target we chose)
- No review is ever lost or counted twice, whatever the order devices sync in
- The same review history gives the same schedule on every device
- Generated cards cite the passage they came from
Interview questions
- Walk me through SM-2.
- What does FSRS do better than SM-2?
- How do you support offline review on several devices without conflicts?
- How do you keep AI-generated cards correct?
- How would you process a 500-page textbook?
- Where does the server matter, if scheduling is on the device?
Sign up free to read the full topic
More System Design topics
- AI Copilot System
- AI Data Quality and Monitoring System
- AI Delivery ETA Prediction System
- AI Driver-Rider Matching System
- AI Dynamic Pricing Engine
- AI E-commerce Search Ranking System
- AI Healthcare Chatbot
- AI Image Generation Service
- AI Job Matching System
- AI Product Recommendation System
- AI Resume Screening System
- AI Smart Pricing for Short-Term Rentals
Start free on Cariara · Coding problems · System design studio