- Project Overview
- Architecture
- Machine Learning Component
- Database Schema
- User Flow
- Installation & Setup
- Code Structure
- Future Enhancements
StudyBlank is an Android flashcard application designed for Biology and Anatomy memorization, featuring an intelligent Spaced Repetition Algorithm (SM-2) that adapts to each user's learning patterns.
- π§ ML-Powered Spaced Repetition: Intelligent scheduling based on user performance
- π Pre-loaded Content: Gray's Anatomy flashcards (35+ cards across 3 decks)
- π Progress Tracking: Accuracy metrics and performance analytics
- π Firebase Authentication: Secure user accounts
- πΎ Room Database: Local data persistence
- π― Adaptive Learning: Difficulty adjusts based on your answers
- Language: Java
- Database: Room (SQLite)
- Authentication: Firebase Auth
- UI: Material Design with CardView/RecyclerView
- Architecture: MVVM-inspired with AsyncTask
- Min SDK: 15 (Android 4.0.3)
- Target SDK: 26 (Android 8.0)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PRESENTATION LAYER β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β home β β createAccountβ β MainActivityβ β
β β (Login) βββΆβ (Register) βββΆβ (Dashboard) β β
β ββββββββββββββββ ββββββββββββββββ ββββββββ¬ββββββββ β
β β β
β ββββββββββββββββββββββΌββββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββββββ βββββββββββββββββββ [...] β
β β StudyActivity β β DeckListActivityβ β
β β (Flashcard Quiz) β β (Browse Decks) β β
β βββββββββββ¬βββββββββ βββββββββββββββββββ β
β β β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ
β β BUSINESS LOGIC LAYER β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β βΌ β
β ββββββββββββββββββββββββββββββββ β
β β SpacedRepetitionAlgorithm ββββ ML COMPONENT β
β β (SM-2 Algorithm) β β
β ββββββββββββββββββββββββββββββββ β
β β β
β β Updates progress based on performance β
β βΌ β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ
β β DATA LAYER β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β βΌ β
β ββββββββββββββββββββ β
β β AppDatabase β β
β β (Room/SQLite) β β
β ββββββββββ¬ββββββββββ β
β β β
β ββββββββββββββββΌβββββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β βββββββββββ ββββββββββββββ ββββββββββββββββ β
β β DeckDao β βFlashcardDaoβ βStudyProgress β β
β β β β β β Dao β β
β ββββββ¬βββββ βββββββ¬βββββββ ββββββββ¬ββββββββ β
β β β β β
β βΌ βΌ βΌ β
β βββββββββββ ββββββββββββββ ββββββββββββββββ β
β β Deck β β Flashcard β βStudyProgress β β
β β Entity β β Entity β β Entity β β
β βββββββββββ ββββββββββββββ ββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ
β Firebase Auth β β Local SQLite DB β
β (User Accounts) β β (Flashcard Data) β
ββββββββββββββββββββ ββββββββββββββββββββ
- home.java: Login screen with Firebase authentication
- createAccount.java: User registration with email verification
- MainActivity.java: Dashboard showing stats and navigation
- StudyActivity.java: Flashcard study session with rating buttons
- DeckListActivity.java: Browse available flashcard decks
- SpacedRepetitionAlgorithm.java: The ML component that calculates optimal review intervals
- AppDatabase.java: Room database singleton
- DAOs: Data access objects for CRUD operations
- Entities: Deck, Flashcard, StudyProgress
The app uses the SuperMemo 2 (SM-2) algorithm, a scientifically-proven method for optimizing memory retention through intelligent scheduling.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER STUDIES A FLASHCARD β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β User Rates Answer Quality β
β (0 = Wrong, 5 = Perfect) β
ββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββ΄ββββββββββββββ
β β
βΌ βΌ
Quality < 3 Quality β₯ 3
(Incorrect) (Correct)
β β
βΌ βΌ
βββββββββββββββββββββββ ββββββββββββββββββββββββ
β RESET LEARNING β β ADVANCE LEARNING β
βββββββββββββββββββββββ€ ββββββββββββββββββββββββ€
β β’ Repetitions = 0 β β β’ Repetitions += 1 β
β β’ Interval = 0 β β β’ Calculate new β
β β’ Next review: β β interval based on β
β 10 minutes β β ease factor β
βββββββββββββββββββββββ ββββββββββββββββββββββββ
β β
βββββββββββββ¬ββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββ
β UPDATE EASE FACTOR β
β (How "easy" is this card) β
β β
β EF_new = EF_old + β
β (0.1 - (5-q)*(0.08+(5-q)*0.02))β
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββ
β UPDATE STUDY PROGRESS β
β β’ Next review date β
β β’ Accuracy percentage β
β β’ Correct/incorrect count β
ββββββββββββββββββββββββββββββββ
IF quality < 3 (incorrect answer):
ββ repetitions = 0
ββ interval = 0
ββ next_review = now + 10 minutes
ELSE IF quality β₯ 3 (correct answer):
ββ repetitions += 1
β
ββ IF repetitions == 1:
β interval = 1 day
β
ββ ELSE IF repetitions == 2:
β interval = 6 days
β
ββ ELSE (repetitions > 2):
interval = previous_interval Γ ease_factor
next_review = now + (interval Γ 24 hours)
The Ease Factor (EF) represents how "easy" a card is for the user. It starts at 2.5 and adjusts based on performance:
EF_new = EF_old + (0.1 - (5 - quality) Γ (0.08 + (5 - quality) Γ 0.02))
EF_new = max(EF_new, 1.3) // Minimum ease factor is 1.3
Example Calculations:
| Quality | Description | EF Change | Example EF (from 2.5) |
|---|---|---|---|
| 5 | Perfect recall | +0.10 | 2.60 (easier) |
| 4 | Correct after hesitation | +0.00 | 2.50 (unchanged) |
| 3 | Correct with difficulty | -0.14 | 2.36 (harder) |
| 2 | Incorrect but familiar | -0.32 | 2.18 (much harder) |
| 1 | Incorrect, slight memory | -0.54 | 1.96 (very hard) |
| 0 | Complete blackout | -0.80 | 1.70 (extremely hard) |
When multiple cards are due, the algorithm calculates a priority score to determine which cards need review most urgently:
priority_score = (days_overdue Γ 10)
+ ((100 - accuracy) Γ 0.5)
+ ((3.0 - ease_factor) Γ 20)
Higher scores = higher priority
- Cards overdue by many days get higher priority
- Cards with low accuracy (struggling cards) get higher priority
- Cards with low ease factor (difficult cards) get higher priority
This algorithm provides several intelligent adaptive learning features:
- Personalized Scheduling: Each card's review interval adapts to YOUR performance
- Forgetting Curve Optimization: Reviews happen just before you're likely to forget
- Efficient Learning: Focus time on difficult cards, less time on easy ones
- Long-term Retention: Gradually spaces out reviews as mastery increases
- Performance Tracking: Accuracy metrics show your progress over time
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATABASE SCHEMA β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββ
β DECKS β
ββββββββββββββββββββββββ€
β id (PK) β
β name β
β description β
β category β
β createdAt β
β cardCount β
ββββββββββββ¬ββββββββββββ
β
β 1:N
β
βΌ
ββββββββββββββββββββββββ
β FLASHCARDS β
ββββββββββββββββββββββββ€
β id (PK) β
β deckId (FK) βββββββββΌββββββΆ Deck.id
β question β
β answer β
β imageUrl β
β createdAt β
ββββββββββββ¬ββββββββββββ
β
β 1:N
β
βΌ
ββββββββββββββββββββββββ
β STUDY_PROGRESS β ββββ ML ALGORITHM USES THIS
ββββββββββββββββββββββββ€
β id (PK) β
β flashcardId (FK) ββββΌββββββΆ Flashcard.id
β userId β
β easeFactor β ββββ SM-2 Algorithm parameter
β repetitions β ββββ SM-2 Algorithm parameter
β interval β ββββ SM-2 Algorithm parameter
β nextReviewDate β ββββ When to show card next
β lastReviewDate β
β correctCount β
β incorrectCount β
β accuracy β
ββββββββββββββββββββββββ
Represents a collection of flashcards (e.g., "Gray's Anatomy - Skeletal System")
Fields:
id: Primary key (auto-generated)name: Deck namedescription: Brief descriptioncategory: Category (e.g., "Anatomy", "Biology")createdAt: Timestamp of creationcardCount: Number of flashcards in this deck
Individual question/answer pairs
Fields:
id: Primary key (auto-generated)deckId: Foreign key to Deckquestion: Front of the flashcardanswer: Back of the flashcardimageUrl: Optional path to anatomy diagramcreatedAt: Timestamp of creation
Critical for ML algorithm - tracks user's learning progress per card
Fields:
id: Primary key (auto-generated)flashcardId: Foreign key to FlashcarduserId: Firebase user IDeaseFactor: SM-2 ease factor (default 2.5)repetitions: Number of successful reviewsinterval: Days until next reviewnextReviewDate: Timestamp of next scheduled reviewlastReviewDate: Timestamp of last reviewcorrectCount: Total correct answersincorrectCount: Total incorrect answersaccuracy: Percentage correct (calculated)
START
β
βΌ
βββββββββββββββββββ
β Login Screen β
β (home.java) β
ββββββββββ¬βββββββββ
β
βββββββ΄ββββββ
β β
βΌ βΌ
[Login] [Create Account]
β β
β βΌ
β ββββββββββββββββββββ
β β createAccount. β
β β - Enter email β
β β - Enter passwordβ
β β - Verify email β
β ββββββββββ¬ββββββββββ
β β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββββ
β Firebase Auth β
β Authentication β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β MainActivity β
β Dashboard β
β β
β Shows: β
β β’ Cards due: X β
β β’ Total cards: Yβ
β β’ Features list β
ββββββββββ¬ββββββββββ
β
βββββββ΄ββββββ¬ββββββββββ¬βββββββββ
β β β β
βΌ βΌ βΌ βΌ
ββββββββββ βββββββββββ [Stats] [Settings]
β Study β β Decks β
β β β List β
βββββ¬βββββ ββββββ¬βββββ
β β
β βΌ
β ββββββββββββββββββββ
β β DeckListActivity β
β β β’ Skeletal Sys β
β β β’ Muscular Sys β
β β β’ Nervous Sys β
β ββββββββββ¬ββββββββββ
β β
β [Select Deck]
β β
ββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β StudyActivity β
β β
β 1. Show Question β
β 2. User clicks β
β "Show Answer" β
β 3. Display Answer β
β 4. Rating Buttons: β
β ββββββββββββββββ β
β β Easy β Goodβ β
β β Hard βAgainβ β
β ββββββββββββββββ β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β ML ALGORITHM β
β SpacedRepetition β
β - Calculate EF β
β - Update interval β
β - Schedule next β
β review β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Update Database β
β StudyProgress β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Next Card or β
β Session Complete β
ββββββββββββββββββββββββ
STUDY SESSION STARTS
β
βΌ
βββββββββββββββββββββββββββ
β Load Due Cards β
β (Query StudyProgress β
β where nextReviewDate β
β <= current time) β
ββββββββββ¬βββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Sort by Priority β
β (Most urgent first) β
ββββββββββ¬βββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Display Card #1 β
β βββββββββββββββββββββββ β
β β What is the β β
β β largest bone in β β
β β the human body? β β
β βββββββββββββββββββββββ β
β [Show Answer Button] β
ββββββββββ¬βββββββββββββββββ
β
[User clicks]
β
βΌ
βββββββββββββββββββββββββββ
β Show Answer β
β βββββββββββββββββββββββ β
β β The femur β β
β β (thigh bone) β β
β βββββββββββββββββββββββ β
β β
β How well did you know? β
β ββββββββββ¬βββββββββ β
β β Easy β Good β β
β β(5 days)β(2 days)β β
β ββββββββββΌβββββββββ€ β
β β Hard β Again β β
β β(10 min)β(1 min) β β
β ββββββββββ΄βββββββββ β
ββββββββββ¬βββββββββββββββββ
β
[User selects rating]
β
βΌ
βββββββββββββββββββββββββββ
β ML ALGORITHM PROCESSES β
β β
β If rating β₯ 3 (Good): β
β β Increase interval β
β β Update ease factor β
β β Schedule future β
β β
β If rating < 3 (Hard): β
β β Reset interval β
β β Review soon β
ββββββββββ¬βββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Show Toast Notification β
β "Next review: in 2 days"β
ββββββββββ¬βββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Move to Next Card β
β OR β
β "Session Complete!" β
βββββββββββββββββββββββββββ
- Android Studio Arctic Fox or later
- JDK 8 or higher
- Android SDK (API 26)
- Firebase account (for authentication)
git clone https://github.com/yourusername/studyblank.git
cd studyblank- Go to Firebase Console
- Create a new project or use existing
- Add an Android app:
- Package name:
com.example.bao48.studyblank - Download
google-services.json
- Package name:
- Place
google-services.jsonin/app/directory - Enable Email/Password authentication in Firebase Console
# Open in Android Studio
# Build > Make Project
# Run > Run 'app'Or via command line:
./gradlew assembleDebug
./gradlew installDebug- Launch app on emulator or device
- Create an account with email/password
- Login
- View dashboard showing 35 pre-loaded cards
- Start a study session
- Rate cards and observe ML scheduling
studyblank/
βββ app/
β βββ src/
β β βββ main/
β β β βββ java/com/example/bao48/studyblank/
β β β β βββ algorithm/
β β β β β βββ SpacedRepetitionAlgorithm.java βββ ML CORE
β β β β βββ database/
β β β β β βββ AppDatabase.java
β β β β β βββ DatabaseInitializer.java
β β β β β βββ DeckDao.java
β β β β β βββ FlashcardDao.java
β β β β β βββ StudyProgressDao.java
β β β β βββ models/
β β β β β βββ Deck.java
β β β β β βββ Flashcard.java
β β β β β βββ StudyProgress.java βββ ML STATE
β β β β βββ home.java (Login)
β β β β βββ createAccount.java (Register)
β β β β βββ MainActivity.java (Dashboard)
β β β β βββ StudyActivity.java (Study Session)
β β β β βββ DeckListActivity.java (Browse Decks)
β β β βββ res/
β β β β βββ layout/
β β β β β βββ activity_study.xml
β β β β β βββ activity_deck_list.xml
β β β β β βββ content_main.xml
β β β β β βββ ...
β β β β βββ values/
β β β β βββ strings.xml
β β β β βββ colors.xml
β β β β βββ styles.xml
β β β βββ AndroidManifest.xml
β βββ build.gradle βββ Dependencies
β βββ google-services.json βββ Firebase config (NOT in repo)
βββ build.gradle
βββ settings.gradle
βββ README.md
βββ DOCUMENTATION.md βββ This file
Location: algorithm/SpacedRepetitionAlgorithm.java
Purpose: The ML core of the application
Key Methods:
updateProgress(StudyProgress, int quality): Updates learning progress based on user ratingisDueForReview(StudyProgress): Checks if card is due for reviewcalculatePriority(StudyProgress): Calculates urgency scoregetNextReviewDescription(StudyProgress): Human-readable next review time
Location: StudyActivity.java
Purpose: Main study session interface
Features:
- Displays flashcards one at a time
- Shows question, then reveals answer
- Four rating buttons (Easy, Good, Hard, Again)
- Integrates with ML algorithm
- Updates database asynchronously
Location: database/AppDatabase.java
Purpose: Room database singleton
Features:
- Manages SQLite database
- Provides DAO instances
- Thread-safe singleton pattern
Location: database/DatabaseInitializer.java
Purpose: Populates sample data
Content:
- 3 Gray's Anatomy decks
- 35 flashcards total
- Covers Skeletal, Muscular, and Nervous systems
-
Statistics Dashboard
- Daily/weekly/monthly study charts
- Accuracy trends over time
- Most difficult cards report
- Study streak tracking
-
Deck Management
- Create custom decks
- Edit flashcards
- Import/export functionality (JSON, CSV)
- Share decks with other users
-
Enhanced ML Features
- Multiple algorithm options (Leitner, FSRS)
- ML-based difficulty prediction
- Optimal study time suggestions
- Learning pattern analysis
-
UI/UX Improvements
- Dark mode
- Card flip animations
- Gesture-based navigation (swipe for ratings)
- Voice input for answers
-
Content Enhancements
- Image occlusion for anatomy diagrams
- Audio pronunciation support
- Video explanations
- Interactive 3D models
-
Social Features
- Share progress with friends
- Leaderboards
- Study groups
- Collaborative decks
-
Cloud Sync
- Firebase Firestore integration
- Multi-device sync
- Backup and restore
- Offline-first architecture
-
Gamification
- Achievement badges
- XP and levels
- Daily challenges
- Rewards system
- Indexed foreign keys for fast queries
- Cascade deletes to maintain referential integrity
- Singleton pattern prevents multiple DB instances
- AsyncTask for background operations
- Lazy loading of flashcard images
- Efficient RecyclerView for large lists
- O(1) time complexity for priority calculation
- O(log n) sorting for due cards
- Minimal database queries per session
// Test SM-2 algorithm calculations
@Test
public void testEaseFactorCalculation() {
StudyProgress progress = new StudyProgress(1, "user123");
progress = SpacedRepetitionAlgorithm.updateProgress(progress, 5);
assertEquals(2.6, progress.getEaseFactor(), 0.01);
}
// Test interval scheduling
@Test
public void testIntervalProgression() {
StudyProgress progress = new StudyProgress(1, "user123");
progress = SpacedRepetitionAlgorithm.updateProgress(progress, 3);
assertEquals(1, progress.getInterval()); // First correct = 1 day
progress = SpacedRepetitionAlgorithm.updateProgress(progress, 4);
assertEquals(6, progress.getInterval()); // Second correct = 6 days
}- User registration works
- Login/logout functionality
- Dashboard displays correct stats
- Flashcards display properly
- Rating buttons update progress
- ML algorithm calculates correct intervals
- Database persists data
- Navigation drawer works
- Deck list shows all decks
Issue: App crashes on login
Solution: Ensure google-services.json is in /app/ directory
Issue: No cards due for review
Solution: Cards start with nextReviewDate = now, so they should appear immediately. Check database initialization.
Issue: Database not populating
Solution: Clear app data and restart. Check DatabaseInitializer.initializeIfEmpty()
Issue: Firebase authentication fails Solution: Enable Email/Password authentication in Firebase Console
This project is for educational purposes. Gray's Anatomy content is used for demonstration.
- Algorithm: SuperMemo 2 (SM-2) by Piotr Wozniak
- Content: Gray's Anatomy
- Framework: Android SDK, Firebase, Room
For questions or contributions, please open an issue on GitHub.
Last Updated: November 2025 Version: 1.0.0