flashcards-rs

Crates.ioflashcards-rs
lib.rsflashcards-rs
version0.1.2
created_at2025-10-19 04:46:46.606334+00
updated_at2025-10-19 05:05:40.797741+00
descriptionA terminal-based flashcard app written in Rust using ratatui.
homepage
repositoryhttps://github.com/fibnas/flashcards-rs
max_upload_size
id1889941
size69,005
frankstallionjr (fibnas)

documentation

README

Flashcards · Rust Edition

A fast, fully terminal-based flashcard application written in Rust using ratatui and crossterm. Create topics, edit cards, and study directly from your terminal — with progress tracking, randomization, and persistent storage.


Crates.io

Features

  • Topic-based organization
    • Each topic lives in /topics/<topic_name>/
    • Each topic contains questions.txt and answers.txt
  • Study mode
    • Sequential or randomized question order
    • Input answers interactively
    • Review your responses at the end
  • Edit mode
  • Add, remove, or edit flashcards from inside the TUI
  • Changes persist automatically to disk
  • Progress tracking
    • Visual progress gauge
    • Saves your session with timestamps (flashcard_responses_YYYYMMDD-HHMMSS.txt)
  • Atomic file writes
    • Safe saving through temporary files to prevent corruption

Folder Structure

flashcards-rs/
├── Cargo.toml
├── src/
│   └── main.rs
└── topics/
    ├── AI/
    │   ├── questions.txt
    │   └── answers.txt
    └── Earth/
        ├── questions.txt
        └── answers.txt

Each topic folder must contain:

  • questions.txt — one question per line
  • answers.txt — one answer per line, in the same order as the questions

Keyboard Shortcuts

Global

Key Action
Ctrl+Q Quit
Ctrl+R Review responses
Ctrl+S Save edits to file

Topic Select

Key Action
↑ / ↓ Move between topics
Enter Open selected topic
C Create a new topic

Main Menu

Key Action
S Start quiz mode
E Edit cards
B Back to topic select

Study Mode

Key Action
Y / N Choose random order or sequential
Enter Submit answer or continue
N Next card
Ctrl+R Review all responses

Edit Mode

Key Action
↑ / ↓ Move between cards
E Edit question
A Edit answer
N Add new card
D Delete selected card
S Save
B Back to menu

Running the App

1. Clone and build

git clone https://github.com/fibnas/flashcards-rs.git
cd flashcards-rs
cargo run

OR

gh repo clone fibnas/flashcards-rs
cargo run

OR

cargo install flashcards-rs

Crates.io

2. Add Topics

The app automatically scans /topics/ for folders. To create new topics manually:

mkdir -p topics/Space
echo "What is a black hole?" > topics/Space/questions.txt
echo "A region of spacetime with gravity so strong nothing can escape it." > topics/Space/answers.txt

Or create them directly inside the app with C.


Saved Sessions

When you finish a quiz, your results are saved automatically:

flashcard_responses_20251019-225918.txt

Each session log includes:

  • Question number and text
  • Your answer
  • The correct answer

Dependencies

  • ratatui — Terminal UI library
  • crossterm — Terminal event handling
  • anyhow — Simple error management
  • chrono — Timestamps
  • rand — Randomized order support

Example Study Session

Topic: AI
Q1: What does AI stand for?
> Artificial Intelligence
Correct!

Progress bar updates live as you advance through cards.


Development Notes

Screen State Machine

The app operates as a finite state machine with distinct UI screens managed by the Screen enum. Each state defines a unique interaction context. Transitions are event-driven (keyboard input).

State Description Key Transitions
TopicSelect Browse or create topics. EnterMainMenu, CTopicCreate
TopicCreate Input new topic name. EnterMainMenu, EscTopicSelect
MainMenu Choose between study or edit modes. SMode, ECardList
CardList Edit existing cards. EEditQuestion, AEditAnswer, N → add new
Mode Select random or sequential order. Y/NAsk
Ask Display current question and take input. EnterReveal, Ctrl+RReview
Reveal Show correct answer and next-step options. N → next, Ctrl+E/A → edit, Ctrl+R → review
EditQuestion / EditAnswer Edit text of a card. Enter → save and return
Review Scrollable list of all responses. Esc / Ctrl+B → return
Done Quiz finished summary screen. R → review
ConfirmQuit Exit confirmation modal. Y → exit, N → return

This modular architecture simplifies adding new screens or features (e.g., timed quizzes or import/export support).


License

MIT License. Built with curiosity, caffeine, and the occasional panic over unwrap().


Author

Frank Stallion Fedora 42

Commit count: 0

cargo fmt