Skip to content

feat(study): replace mock data with real backend service#51

Draft
MuenYu wants to merge 2 commits into
mainfrom
opencode/glowing-tiger
Draft

feat(study): replace mock data with real backend service#51
MuenYu wants to merge 2 commits into
mainfrom
opencode/glowing-tiger

Conversation

@MuenYu

@MuenYu MuenYu commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replaced the hardcoded mock vocabulary list in StudyView.tsx with a real backend service that fetches flashcards from the database and persists review results with spaced repetition scheduling.

Changes

New Files

  • lib/study/service.ts: Backend service with:

    • getStudyQueueForUser() - Fetches "pending + due" flashcards (state != suspended)
    • submitReviewForUser() - Records reviews and applies SM-2 scheduling logic
    • getStudyStatsForUser() - Helper for due count/today's reviews
  • app/api/study/queue/route.ts: API endpoint to fetch study cards

  • app/api/study/review/route.ts: API endpoint to submit review results

Modified Files

  • app/(dashboard)/study/StudyView.tsx:
    • Removed MOCK_VOCAB_LIST hardcoded data
    • Added API integration for fetching cards on mount
    • Implemented infinite queue behavior (auto-refills when remaining <= 5)
    • Added empty state UI when no cards are due
    • Persists all review data to the database

Behavior

Feature Implementation
Session content "Pending + due" cards (state != suspended)
Validation Kept local heuristic (10+ chars = pass)
Session length Infinite queue (fetches more as you complete)
SRS Proper DB writes to flashcards (dueAt, state, easeFactor, streak, etc.)

Testing

bun db:seed   # if DB not seeded
bun dev       # starts dev server at localhost:3000
# Visit /study to see real cards from database

Type Checking

✅ Passes TypeScript: npx tsc --noEmit

- Add lib/study/service.ts with getStudyQueueForUser and submitReviewForUser
- Implement SM-2 scheduling logic for spaced repetition
- Create /api/study/queue and /api/study/review API endpoints
- Refactor StudyView to fetch real cards from database
- Implement infinite queue behavior with automatic refilling
- Add empty state UI when no cards are due
@MuenYu MuenYu force-pushed the opencode/glowing-tiger branch from 32298f8 to a511357 Compare January 22, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant