Skip to content

hel-b/deckWiz

Repository files navigation

🎴 DeckWiz πŸ§™β€β™‚οΈ

Master any subject with intelligent spaced repetition

DeckWiz is a modern, clean flashcard application that helps you learn and retain information through adaptive spaced repetition. Built with cutting-edge web technologies, it provides a seamless learning experience that's completely free.

🌐 Production Deployment

It's live! Check it out at:

πŸͺ„ deckwiz.cyberalcove.com

Sign up for a free account and start mastering your flashcards today!

✨ Features

  • 🧠 Spaced Repetition Algorithm - Smart learning system that adapts to your pace
  • πŸ“š Custom Deck Management - Create and organize multiple flashcard decks
  • πŸ” Secure Authentication - Email/password and GitHub OAuth support
  • πŸ“Š Progress Tracking - Monitor your learning statistics and achievements
  • 🎨 Modern UI - Clean, responsive interface with dark mode support
  • πŸ“§ Email Verification - Secure account management with email workflows
  • πŸ”’ Encrypted Database - Your data is protected with SQLite encryption

πŸ› οΈ Technology Stack

Frontend

  • Astro - High-performance web framework
  • Tailwind CSS - Utility-first CSS framework
  • DaisyUI - Tailwind component library with retro and dim themes
  • Astro Icon - Iconify integration with Font Awesome 6

Backend & Authentication

  • Better Auth - Modern authentication library
  • Email & Password - Traditional authentication with verification
  • GitHub OAuth - Social authentication provider
  • Google OAuth - Social authentication provider
  • Password Reset - Secure password recovery flow
  • Email Change - Verified email update workflow

Database

Email & Notifications

  • AWS SES - Amazon Simple Email Service integration
  • Resend - Modern email API alternative

Development Tools

πŸ“ Project Structure

/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ pages/              # Astro pages (file-based routing)
β”‚   β”‚   β”œβ”€β”€ index.astro     # Landing page
β”‚   β”‚   β”œβ”€β”€ login.astro     # Authentication
β”‚   β”‚   β”œβ”€β”€ signup.astro    # Registration
β”‚   β”‚   β”œβ”€β”€ dashboard.astro # Main app interface
β”‚   β”‚   β”œβ”€β”€ study/          # Study session pages
β”‚   β”‚   β”œβ”€β”€ configure/      # Deck configuration
β”‚   β”‚   └── api/            # API endpoints
β”‚   β”‚       └── auth/       # Better Auth API routes
β”‚   β”œβ”€β”€ components/         # Reusable Astro components
β”‚   β”‚   β”œβ”€β”€ FlashCard.astro
β”‚   β”‚   β”œβ”€β”€ DeckTable.astro
β”‚   β”‚   β”œβ”€β”€ ConfigTable.astro
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ layouts/            # Page layouts
β”‚   β”‚   β”œβ”€β”€ Layout.astro    # Main layout wrapper
β”‚   β”‚   β”œβ”€β”€ Header.astro
β”‚   β”‚   └── Footer.astro
β”‚   β”œβ”€β”€ actions/            # Server actions
β”‚   β”œβ”€β”€ auth-client.ts      # Client-side auth utilities
β”‚   β”œβ”€β”€ middleware.ts       # Astro middleware
β”‚   └── main.css            # Global styles
β”œβ”€β”€ db/                     # Database directory
β”‚   └── db_connection.ts    # SQLite connection
β”œβ”€β”€ db_migration/           # Database migration scripts
β”œβ”€β”€ better-auth_migrations/ # Better Auth schema migrations
β”œβ”€β”€ auth.ts                 # Server-side auth configuration
β”œβ”€β”€ email.ts                # Email service configuration
β”œβ”€β”€ astro.config.mjs        # Astro configuration
β”œβ”€β”€ tailwind.config.mjs     # Tailwind CSS configuration
β”œβ”€β”€ Dockerfile              # Production container
β”œβ”€β”€ compose.yml             # Production deployment
└── package.json

πŸš€ Getting Started

Prerequisites

  • Node.js
  • npm
  • Docker (for containerized deployment)

Installation

  1. Clone the repository

    git clone https://github.com/hel-b/astro-flash.git
    cd astro-flash
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env file in the root directory:

    # Database
    DB_FILE_PATH=/app/db/app.db
    DB_ENCRYPT_KEY=your-encryption-key-here
    
    # Better Auth
    BETTER_AUTH_SECRET=your-auth-secret-here
    BETTER_AUTH_URL=http://localhost:4327 # Adjust for production
    
    # GitHub OAuth (optional)
    GITHUB_CLIENT_ID=your-github-client-id
    GITHUB_CLIENT_SECRET=your-github-client-secret
    
    # Google OAuth (optional)
    GOOGLE_CLIENT_ID=your-google-client-id
    GOOGLE_CLIENT_SECRET=your-google-client-secret
    
    # Email Configuration
    NOREPLY_EMAIL=[email protected]
    ADMIN_EMAIL=[email protected]
    
    # AWS SES (if using AWS)
    AWS_REGION=us-west-1 # Adjust as needed
    AWS_ACCESS_KEY_ID=your-access-key
    AWS_SECRET_ACCESS_KEY=your-secret-key
    
    # Resend (if using Resend)
    RESEND_API_KEY=your-resend-api-key
  4. Create the database

     # Step 1: Run Better Auth migrations
     npx @better-auth/cli@latest migrate
     # Step 2: Migrate application tables
     node ./db_migration/migrate-tables.js
     # OR copy fresh pre-seeded database
     cp ./db/app-fresh.db ./db/app.db
  5. Start the development server

    npm start

    The application will be available at http://localhost:4327

🧞 Commands

All commands are run from the root of the project:

Command Action
npm install Install dependencies
npm start Start dev server at localhost:4327
npm run build Build production site to ./dist/
npm run preview Preview build locally before deploying
npm run lint Run ESLint on source files
npm run astro Run Astro CLI commands

🐳 Docker Deployment

Repo contains a base Dockerfile ready for production deployment.

πŸ”’ Security Features

  • Encrypted SQLite Database - All data encrypted at rest
  • Email Verification - Required for new accounts
  • Password Reset Flow - Secure token-based reset with expiration
  • HTTPS Ready - Let's Encrypt SSL support via Docker labels
  • Environment Isolation - Secrets managed via environment variables
  • OAuth Integration - Secure third-party authentication

🎨 Theming

DeckWiz includes two beautiful themes powered by DaisyUI:

  • Retro - Light mode with vintage aesthetics
  • Dim - Dark mode for comfortable night-time studying

Users can toggle between themes using the theme controller component.

πŸ“Š Learning Algorithm

DeckWiz implements a modified version of the SM-2 (SuperMemo 2) algorithm, a proven spaced repetition system that optimizes long-term memory retention.

How It Works

The algorithm tracks three key metrics for each flashcard:

  • Streak (n) - Number of consecutive correct responses
  • Easiness Factor (EF) - Difficulty multiplier (minimum 1.3)
  • Interval (I) - Days until next review

Scheduling Logic

  • First correct answer: Review again in 1 day
  • Second correct answer: Review again in 6 days
  • Subsequent correct answers: Interval multiplied by the Easiness Factor
  • Incorrect answer: Reset streak and interval to 0

The Easiness Factor adjusts based on your performance, making difficult cards appear more frequently while easy cards have longer intervals between reviews.

Current Implementation

Our implementation (sm2Alg in src/helpers.ts) adapts the SM-2 algorithm with a binary pass/fail system instead of the original 0-5 quality rating scale.

Algorithm Details

Input Parameters:

  • pass (boolean) - Whether the card was answered correctly
  • streak (number) - Current consecutive correct answers
  • EF (number) - Easiness Factor for the card
  • interval (number) - Current interval in days

Output:

  • Updated streak, EF, and interval values

Current Implementation (TypeScript):

/**
 * SM-2 Spaced Repetition Algorithm (Modified for DeckWiz)
 * @param params - Algorithm input
 * @param params.pass - Whether the card was answered correctly
 * @param params.streak - Current consecutive correct answers
 * @param params.EF - Easiness Factor for the card
 * @param params.interval - Current interval in days
 * @returns Updated streak, EF, and interval values
 */
export const sm2Alg = ({
  pass,
  streak,
  EF,
  interval,
}: {
  pass: boolean
  streak: number
  EF: number
  interval: number
}): { streak: number; EF: number; interval: number } => {
  if (pass) {
    if (streak === 0) {
      interval = 1 // First correct: review in 1 day
    } else if (streak === 1) {
      interval = 6 // Second correct: review in 6 days
    } else {
      interval = Math.round(interval * EF) // Subsequent: multiply by EF
    }
    streak += 1
  } else {
    streak = 0 // Reset streak on failure
    interval = 0 // Review again immediately
  }
  // Adjust Easiness Factor
  EF +=
    0.1 - 4.2 * (1 - Number(pass)) * (0.08 + 4.2 * (1 - Number(pass)) * 0.02)
  if (EF < 1.3) {
    EF = 1.3 // Minimum EF
  }
  return { streak, EF, interval }
}

The EF formula is adapted from the original SM-2 quality-based calculation:

  • Correct answer (pass=true): EF increases by 0.1, making future intervals longer
  • Incorrect answer (pass=false): EF decreases by ~0.8, making future intervals shorter

This simplified binary approach makes reviews faster while preserving the core benefits of spaced repetitionβ€”cards you struggle with appear more frequently, while mastered cards are shown less often.

Reference

Based on the SuperMemo SM-2 algorithm developed by Piotr WoΕΊniak. Learn more:

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ”— Links


Built with ❀️ using Astro, Tailwind CSS, and Better Auth

About

A modern, clean flashcard application utilizing adaptive spaced repetition.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published