Skip to content

dandrok/terminal-anki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Terminal Anki

A modern, intelligent terminal-based flashcard application with spaced repetition learning

TypeScript Node.js License

Learn efficiently with the proven SM-2 spaced repetition algorithm - the same algorithm used by Anki!

๐ŸŽ‰ Version 1.2.0 is here! Major update with custom study sessions, achievements, learning streaks, and comprehensive analytics!


โœจ Features

๐ŸŽฏ Smart Learning Algorithm

  • SM-2 Spaced Repetition - Scientifically proven to optimize memory retention
  • Adaptive Scheduling - Cards appear less frequently as you master them
  • Performance Tracking - Algorithm learns from your answers

๐ŸŽฎ Professional Session Control

  • Flexible Session Lengths - Quick (10), Standard (25), Intensive (50), or Custom
  • Intuitive Arrow Navigation - Easy selection with arrow keys and Enter
  • Smart Back Navigation - Go back to previous menus at any step
  • Graceful Exit Options - Quit anytime without killing the terminal
  • Skip Functionality - Skip difficult cards and return later
  • Session Summaries - Track progress and see what's remaining
  • Progress Saving - Automatic saving at every step

๐ŸŽฏ Custom Study Sessions (v1.2.0!)

  • Tag-Based Filtering - Study specific topics or categories
  • Difficulty-Based Filtering - Focus on new, learning, young, or mature cards
  • Flexible Limits - Set custom card counts per session
  • Random Order Option - Shuffle cards for varied practice
  • Mixed Filtering - Combine tags and difficulty filters

๐Ÿ“š Enhanced Card Management

  • Tag System - Organize cards with multiple tags per card
  • Add/Edit/Delete cards with intuitive CLI interface
  • Quick List View - See all cards at a glance with tags and status
  • Interactive Card Browser - Browse cards one by one with full content
  • Search through your flashcard collection
  • Tag Management - Edit card tags with ease
  • Local JSON Storage ready for backend integration

๐Ÿ”ฅ Learning Streaks & Gamification (v1.2.0!)

  • Daily Streak Tracking - Track consecutive study days
  • Achievement System - Unlock achievements for various milestones
  • Progress Visualization - See your learning journey over time
  • Motivation Features - Stay engaged with goals and rewards
  • 8 Different Achievements - Cards, sessions, streaks, and mastery milestones

๐Ÿ“Š Enhanced Analytics Dashboard (v1.2.0!)

  • Study Session History - Complete record of all study sessions
  • Weekly Progress Tracking - See your learning patterns over weeks
  • Tag Distribution Analysis - Understand which topics you study most
  • Performance Metrics - Track accuracy, study time, and session data
  • Learning Statistics - Comprehensive view of your progress
  • Session Analytics - Detailed breakdown of study habits

๐ŸŽจ Modern Terminal Experience

  • Anki-Style UX - Familiar difficulty rating system (0-4)
  • Consistent @clack/prompts Interface - Beautiful, modern design throughout
  • Colorful Interface - Clean, modern terminal design
  • Keyboard-First - Optimized for terminal power users
  • Progress Bars - Visual representation of achievement progress

๐Ÿš€ Developer-Friendly

  • TypeScript with strict type safety
  • Modular Architecture - Easy to extend and maintain
  • Backend-Ready - Prepared for Node.js API integration
  • Well-Documented - Comprehensive code documentation

๐Ÿ“‹ Table of Contents

๐Ÿš€ Quick Start

Installation

# Install globally via npm
npm install -g terminal-anki

# That's it! The `anki` command is now available globally.

๐ŸŽฎ Using the CLI

Global Commands (After npm link)

# Start interactive mode
anki

# Jump directly into studying due cards
anki --study

# Show help message
anki --help

Local Development Commands

# Start interactive mode (local)
npm start

# Run with TypeScript in development
npm run dev

# Build for production
npm run build

# Watch for changes during development
npm run watch

CLI Options

Command Description
anki Start interactive mode with main menu
anki --study Jump directly into studying due cards
anki --help Show help message and available options

First Run

After installation, the application automatically creates 5 sample flashcards to get you started!

The anki command is now available from any directory in your terminal! ๐Ÿš€

Quick Study Mode

# Jump directly into studying due cards
anki --study

# Or use local development
npm start -- --study

๐Ÿ“– How It Works

๐Ÿง  The Science Behind It

Terminal Anki uses the SM-2 (SuperMemo 2) algorithm, the gold standard for spaced repetition learning:

๐Ÿ“Š Learning Progression:
New Card โ†’ 1 Day โ†’ 6 Days โ†’ 15 Days โ†’ 37 Days โ†’ 91 Days...

๐ŸŽฏ Session Control System

Flexible Study Sessions:

๐Ÿ“š 15 cards due today

Study options:
๐ŸŽฏ Study all due cards (15)
๐Ÿ“Š Study limited session
โŒ Cancel

Choose Session Length:

โ— Quick session (10 cards)
โ—ˆ Standard session (25 cards)
โ—† Intensive session (50 cards)
โ—‰ Custom number
โ—€ Back to study options

In-Session Controls:

๐Ÿ“ Card 3/10
Question: Python

Choose your action:
โฏ ๐Ÿ“– Show Answer
  โญ๏ธ Skip Card
  โŒ Quit Session

Step 1: Choose Action

Choose your action:
โฏ ๐Ÿ“– Show Answer
  โญ๏ธ Skip Card
  โŒ Quit Session

Step 2: Rate Difficulty (After Seeing Answer)

How well did you know this?
โฏ โŒ Again (0) - Show card soon
  ๐Ÿค” Hard (1)
  โœ… Good (3)
  ๐ŸŽ‰ Easy (4)
  โŒ Quit Session

Difficulty Rating Effects:

Rating Description Effect on Schedule
0 Again Reset to 10 minutes
1 Hard Slightly increase interval
3 Good Normal interval increase
4 Easy Large interval increase

๐Ÿ“ˆ Smart Scheduling

  • Easy cards (high ratings) appear less frequently
  • Difficult cards (low ratings) appear more often
  • Algorithm adapts to your personal learning pace

๐ŸŽฎ User Interface

Main Menu Options

๐Ÿง  TERMINAL ANKI - Flashcard Learning System
๐Ÿ“š Total cards: 5 | โฐ Due today: 3 | ๐Ÿ”ฅ Streak: 2 days

? What would you like to do?
โฏ Study due cards         # Start learning session
  ๐ŸŽฏ Custom study session  # Filtered study by tags/difficulty
  Add new card            # Create new flashcard
  List all cards          # View all flashcards
  Search cards            # Find specific cards
  Delete card             # Remove flashcards
  ๐Ÿ† Achievements         # View unlocked achievements
  ๐Ÿ“Š Analytics & History  # Detailed progress dashboard
  Statistics              # Quick stats overview
  Exit                   # Quit application

Study Session Flow

  1. Choose session length โ†’ Quick (10), Standard (25), Intensive (50), or Custom
  2. Question appears โ†’ Read the front of the card
  3. Choose action โ†’ Use arrow keys: Show Answer, Skip Card, or Quit Session
  4. Rate difficulty โ†’ Use arrow keys: Again (0), Hard (1), Good (3), or Easy (4)
  5. Session summary โ†’ See progress and remaining cards

Card List Flow

Choose viewing mode:

๐Ÿ“‹ 6 cards available

How would you like to view your cards?
โฏ โ–ก Quick List View
  โ—‰ Browse Cards One by One
  โ—€ Back to Main Menu

Quick List View:

  • Shows all cards with status (due/upcoming)
  • Truncated text for overview
  • Simple "๐Ÿ”™ Back to main menu" button

Interactive Browser:

  • Full card content without truncation
  • Navigate previous/next through cards
  • Show/hide answers for each card
  • Return to main menu anytime

Statistics Dashboard

๐Ÿ“Š Learning Statistics
----------------------------------------
๐Ÿ“š Total cards: 25
โฐ Due today: 8
๐Ÿ”„ Total reviews: 142
๐Ÿ“ˆ Average easiness: 2.67

๐Ÿ“Š Card Distribution:
  New (1 day): 3 cards
  Learning (2-7 days): 7 cards
  Young (1-4 weeks): 10 cards
  Mature (1+ month): 5 cards

๐Ÿ’พ Data Management

Enhanced Local Storage (v1.2.0!)

Your data is stored in flashcards.json with comprehensive tracking:

{
  "cards": [
    {
      "id": "1",
      "front": "TypeScript",
      "back": "A typed superset of JavaScript",
      "tags": ["programming", "typescript"],
      "easiness": 2.5,
      "interval": 6,
      "repetitions": 2,
      "nextReview": "2025-10-31T15:44:47.610Z",
      "lastReview": "2025-10-25T15:44:47.610Z",
      "createdAt": "2025-10-25T15:44:47.610Z"
    }
  ],
  "sessionHistory": [
    {
      "id": "1698224547123",
      "startTime": "2025-10-25T15:55:47.123Z",
      "endTime": "2025-10-25T16:25:47.456Z",
      "cardsStudied": 15,
      "correctAnswers": 12,
      "incorrectAnswers": 3,
      "averageDifficulty": 1.8,
      "sessionType": "due",
      "quitEarly": false
    }
  ],
  "learningStreak": {
    "currentStreak": 3,
    "longestStreak": 7,
    "lastStudyDate": "2025-10-25T00:00:00.000Z",
    "studyDates": ["2025-10-23", "2025-10-24", "2025-10-25"]
  },
  "achievements": [
    {
      "id": "first_session",
      "name": "Study Beginner",
      "description": "Complete your first study session",
      "icon": "๐Ÿ“š",
      "category": "sessions",
      "progress": {
        "current": 1,
        "required": 1,
        "description": "sessions completed"
      },
      "unlockedAt": "2025-10-25T15:55:47.123Z"
    }
  ]
}

Ready for Backend Integration

The codebase is structured to easily connect to a Node.js backend:

// Future API integration example
async function syncWithBackend(cards: Flashcard[]) {
  const response = await fetch('/api/cards/sync', {
    method: 'POST',
    body: JSON.stringify(cards)
  });
  return response.json();
}

๐Ÿ› ๏ธ Development

Development Setup

# Clone the repository
git clone https://github.com/dandrok/terminal-anki.git
cd terminal-anki

# Install dependencies
npm install

# Build the application
npm run build

# Run in development mode
npm run dev

# Install globally for testing
npm link

Project Structure

terminal-anki/
โ”œโ”€โ”€ src/                    # TypeScript source code
โ”‚   โ”œโ”€โ”€ index.ts           # Main CLI application
โ”‚   โ”œโ”€โ”€ types.ts           # Type definitions
โ”‚   โ”œโ”€โ”€ flashcard.ts       # Card management & SM-2 algorithm
โ”‚   โ””โ”€โ”€ ui.ts              # User interface layer
โ”œโ”€โ”€ .claude/               # Claude documentation
โ”‚   โ””โ”€โ”€ CLAUDE.md         # Detailed project docs
โ”œโ”€โ”€ dist/                  # Compiled JavaScript
โ”œโ”€โ”€ flashcards.json       # Local data storage
โ”œโ”€โ”€ package.json          # Dependencies & scripts
โ”œโ”€โ”€ tsconfig.json         # TypeScript configuration
โ””โ”€โ”€ README.md             # This file

Development Commands

# Development mode with TypeScript
npm run dev

# Build for production
npm run build

# Watch for changes during development
npm run watch

# Clean build artifacts
npm run clean

# Code Quality & Linting
npm run lint          # Run ESLint
npm run lint:fix       # Auto-fix linting issues
npm run format         # Format code with Prettier
npm run format:check   # Check code formatting
npm run type-check     # TypeScript type checking
npm run check          # Run all checks (lint + type-check + format)

Code Quality & Git Hooks

This project uses automated code quality checks with pre-commit and pre-push git hooks:

# Pre-commit hook (runs automatically before each commit)
- ESLint linting with auto-fix
- TypeScript type checking
- Prettier code formatting verification

# Pre-push hook (runs automatically before each push)
- Full project build verification
- Ensures no compilation errors

Manual Testing:

# Test what pre-commit checks
npm run check

# Test what pre-push checks
npm run build

CLI Options

anki              # Interactive mode
anki --study      # Direct study mode
anki --help       # Show help message

๐ŸŽจ Technologies Used

Core Dependencies

  • TypeScript - Type-safe development with strict mode
  • @clack/prompts - Modern, beautiful CLI prompts for navigation
  • prompts - Interactive quiz interface with better control
  • chalk - Terminal colors and styling
  • ora - Loading spinners and animations

Development Tools

  • ESLint - Code linting with TypeScript support
  • Prettier - Code formatting and style consistency
  • simple-git-hooks - Modern git hooks for pre-commit/pre-push automation
  • typescript-eslint - TypeScript-specific ESLint rules

Algorithm

  • SM-2 Spaced Repetition - Proven learning algorithm since 1985
  • Easiness Factor - Personalized difficulty adjustment
  • Interval Calculation - Optimal review timing

๐Ÿ”ฎ Future Roadmap

Version 1.2 โœ… COMPLETED

  • Tag system for organizing flashcards by topics
  • Custom study sessions (by tags, difficulty, limits)
  • Learning streaks and achievements
  • Study session history and analytics
  • Enhanced analytics dashboard
  • Progress tracking and gamification

Version 1.3 (Short Term)

  • Card import/export (CSV, JSON)
  • Bulk operations on cards
  • Card decks and categories
  • Review time statistics
  • Study reminders and notifications

Version 1.4 (Medium Term)

  • Web interface for browser access
  • Basic REST API backend
  • Multi-device synchronization
  • Media-rich cards (images, audio)
  • Advanced search and filtering

Version 2.0 (Long Term)

  • Mobile companion app
  • Cloud-based backup and sync
  • Collaborative learning features
  • Advanced analytics dashboard
  • AI-powered card suggestions

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • SuperMemo - For the SM-2 spaced repetition algorithm
  • Anki - For inspiration and algorithm refinement
  • Vercel - For the amazing @clack/prompts library
  • Node.js Community - For the fantastic CLI ecosystem

Happy Learning! ๐ŸŽ“

Built with โค๏ธ and TypeScript

About

A modern, intelligent terminal-based flashcard application with spaced repetition learning.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published