Skip to content

Latest commit

Β 

History

History
823 lines (701 loc) Β· 32.4 KB

File metadata and controls

823 lines (701 loc) Β· 32.4 KB

StudyBlank - Complete Technical Documentation

Table of Contents

  1. Project Overview
  2. Architecture
  3. Machine Learning Component
  4. Database Schema
  5. User Flow
  6. Installation & Setup
  7. Code Structure
  8. Future Enhancements

Project Overview

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.

Key Features

  • 🧠 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

Technology Stack

  • 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)

Architecture

High-Level Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        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) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Component Descriptions

Presentation Layer

  • 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

Business Logic Layer

  • SpacedRepetitionAlgorithm.java: The ML component that calculates optimal review intervals

Data Layer

  • AppDatabase.java: Room database singleton
  • DAOs: Data access objects for CRUD operations
  • Entities: Deck, Flashcard, StudyProgress

Machine Learning Component

Spaced Repetition Algorithm (SM-2)

The app uses the SuperMemo 2 (SM-2) algorithm, a scientifically-proven method for optimizing memory retention through intelligent scheduling.

Algorithm Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              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   β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Interval Calculation Logic

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)

Ease Factor Formula

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)

Priority Scoring

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

ML Benefits

This algorithm provides several intelligent adaptive learning features:

  1. Personalized Scheduling: Each card's review interval adapts to YOUR performance
  2. Forgetting Curve Optimization: Reviews happen just before you're likely to forget
  3. Efficient Learning: Focus time on difficult cards, less time on easy ones
  4. Long-term Retention: Gradually spaces out reviews as mastery increases
  5. Performance Tracking: Accuracy metrics show your progress over time

Database Schema

Entity Relationship Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          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             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Entity Descriptions

Deck Entity

Represents a collection of flashcards (e.g., "Gray's Anatomy - Skeletal System")

Fields:

  • id: Primary key (auto-generated)
  • name: Deck name
  • description: Brief description
  • category: Category (e.g., "Anatomy", "Biology")
  • createdAt: Timestamp of creation
  • cardCount: Number of flashcards in this deck

Flashcard Entity

Individual question/answer pairs

Fields:

  • id: Primary key (auto-generated)
  • deckId: Foreign key to Deck
  • question: Front of the flashcard
  • answer: Back of the flashcard
  • imageUrl: Optional path to anatomy diagram
  • createdAt: Timestamp of creation

StudyProgress Entity

Critical for ML algorithm - tracks user's learning progress per card

Fields:

  • id: Primary key (auto-generated)
  • flashcardId: Foreign key to Flashcard
  • userId: Firebase user ID
  • easeFactor: SM-2 ease factor (default 2.5)
  • repetitions: Number of successful reviews
  • interval: Days until next review
  • nextReviewDate: Timestamp of next scheduled review
  • lastReviewDate: Timestamp of last review
  • correctCount: Total correct answers
  • incorrectCount: Total incorrect answers
  • accuracy: Percentage correct (calculated)

User Flow

Complete User Journey

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 Flow (Detailed)

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!"     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Installation & Setup

Prerequisites

  • Android Studio Arctic Fox or later
  • JDK 8 or higher
  • Android SDK (API 26)
  • Firebase account (for authentication)

Step 1: Clone the Repository

git clone https://github.com/yourusername/studyblank.git
cd studyblank

Step 2: Firebase Setup

  1. Go to Firebase Console
  2. Create a new project or use existing
  3. Add an Android app:
    • Package name: com.example.bao48.studyblank
    • Download google-services.json
  4. Place google-services.json in /app/ directory
  5. Enable Email/Password authentication in Firebase Console

Step 3: Build and Run

# Open in Android Studio
# Build > Make Project
# Run > Run 'app'

Or via command line:

./gradlew assembleDebug
./gradlew installDebug

Step 4: Test the App

  1. Launch app on emulator or device
  2. Create an account with email/password
  3. Login
  4. View dashboard showing 35 pre-loaded cards
  5. Start a study session
  6. Rate cards and observe ML scheduling

Code Structure

Directory Layout

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

Key Files

SpacedRepetitionAlgorithm.java

Location: algorithm/SpacedRepetitionAlgorithm.java Purpose: The ML core of the application

Key Methods:

  • updateProgress(StudyProgress, int quality): Updates learning progress based on user rating
  • isDueForReview(StudyProgress): Checks if card is due for review
  • calculatePriority(StudyProgress): Calculates urgency score
  • getNextReviewDescription(StudyProgress): Human-readable next review time

StudyActivity.java

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

AppDatabase.java

Location: database/AppDatabase.java Purpose: Room database singleton

Features:

  • Manages SQLite database
  • Provides DAO instances
  • Thread-safe singleton pattern

DatabaseInitializer.java

Location: database/DatabaseInitializer.java Purpose: Populates sample data

Content:

  • 3 Gray's Anatomy decks
  • 35 flashcards total
  • Covers Skeletal, Muscular, and Nervous systems

Future Enhancements

Planned Features

  1. Statistics Dashboard

    • Daily/weekly/monthly study charts
    • Accuracy trends over time
    • Most difficult cards report
    • Study streak tracking
  2. Deck Management

    • Create custom decks
    • Edit flashcards
    • Import/export functionality (JSON, CSV)
    • Share decks with other users
  3. Enhanced ML Features

    • Multiple algorithm options (Leitner, FSRS)
    • ML-based difficulty prediction
    • Optimal study time suggestions
    • Learning pattern analysis
  4. UI/UX Improvements

    • Dark mode
    • Card flip animations
    • Gesture-based navigation (swipe for ratings)
    • Voice input for answers
  5. Content Enhancements

    • Image occlusion for anatomy diagrams
    • Audio pronunciation support
    • Video explanations
    • Interactive 3D models
  6. Social Features

    • Share progress with friends
    • Leaderboards
    • Study groups
    • Collaborative decks
  7. Cloud Sync

    • Firebase Firestore integration
    • Multi-device sync
    • Backup and restore
    • Offline-first architecture
  8. Gamification

    • Achievement badges
    • XP and levels
    • Daily challenges
    • Rewards system

Performance Considerations

Database Optimization

  • Indexed foreign keys for fast queries
  • Cascade deletes to maintain referential integrity
  • Singleton pattern prevents multiple DB instances

Memory Management

  • AsyncTask for background operations
  • Lazy loading of flashcard images
  • Efficient RecyclerView for large lists

Algorithm Efficiency

  • O(1) time complexity for priority calculation
  • O(log n) sorting for due cards
  • Minimal database queries per session

Testing

Unit Tests (Recommended)

// 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
}

Manual Testing Checklist

  • 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

Troubleshooting

Common Issues

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


License

This project is for educational purposes. Gray's Anatomy content is used for demonstration.


Credits

  • Algorithm: SuperMemo 2 (SM-2) by Piotr Wozniak
  • Content: Gray's Anatomy
  • Framework: Android SDK, Firebase, Room

Contact

For questions or contributions, please open an issue on GitHub.


Last Updated: November 2025 Version: 1.0.0