FlashcardMaster is a command-line application built with Rust
that allows users to create, edit, delete, list, and quiz themselves on flashcards.
It uses SurrealDB as a backend to store flashcards for quick retrieval and modification.
Hosted SurrelDB server with fly.io
FlashcardMaster
├── Cargo.toml (dependencies and metadata for the Rust project)
├── .env (stores necessary environment variables such as SurrealDB credentials)
├── src
│ ├── main.rs (main CLI entry point, command handling, and app logic)
│ ├── commands
│ │ ├── add.rs (handles the 'add' command for creating new flashcards)
│ │ ├── edit.rs (handles the 'edit' command for updating existing flashcards)
│ │ ├── delete.rs (handles the 'delete' command for removing flashcards)
│ │ ├── list.rs (handles the 'list' command for displaying all flashcards)
│ │ ├── play.rs (handles the 'play' command for displaying all flashcards in console)
│ │ └── quiz.rs (handles the 'quiz' command for quizzing users with flashcards)
│ ├── model
│ │ ├── card.rs (defines the Card struct and its associated methods, used with SurrealDB)
│ │ └── db.rs (provides database connection and CRUD operations for flashcards)
│ └── utils
│ ├── input.rs (provides input handling and validation functions)
│ └── output.rs (provides formatting and printing functions for console output)
└── tests
└── integration_tests.rs (tests for the main app logic)
- Clone the repository:
git clone https://github.com/Alfex4936/FlashCard-SurrealDB
- Change to the project directory:
cd FlashCard-SurrealDB
- Install the dependencies:
cargo build
- Create a
.env
file in the project root with your SurrealDB credentials:
SURREALDB_DB_NS=namespace
SURREALDB_DB_DB=db_name
SURREALDB_DB_USER=username
SURREALDB_DB_PW=password
FLYIO_HOST=your.fly.dev
- Run the application:
cargo run
Can run it in Docker ~100MB image.
docker build -t flashcard-master --no-cache .
docker run -it --rm --env-file .env flashcard-master list
- Add a flashcard:
from terminal or comma seperated file (Q,A) like test.txt
.
cargo run -- add
or
cargo run -- add test.txt
- Edit a flashcard:
cargo run -- edit [card_id]
- Delete a flashcard:
cargo run -- delete [card_id]
- List all flashcards:
cargo run -- list
- Start a quiz:
cargo run -- quiz
- Play all flashcards (shuffled):
cargo run -- quiz
This project is licensed under the MIT License.