Skip to content

Rust SurrealDB example hosted with fly.io (FlashCard CLI app)

License

Notifications You must be signed in to change notification settings

Alfex4936/FlashCard-SurrealDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flashcard Master

Clap-rs + SurrealDB-rs + tokio's async

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

Project Structure

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)

Installation

  1. Clone the repository:
git clone https://github.com/Alfex4936/FlashCard-SurrealDB
  1. Change to the project directory:
cd FlashCard-SurrealDB
  1. Install the dependencies:
cargo build
  1. 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
  1. Run the application:
cargo run

Docker

Can run it in Docker ~100MB image.

docker build -t flashcard-master --no-cache .

docker run -it --rm --env-file .env flashcard-master list

Usage

  1. Add a flashcard:

from terminal or comma seperated file (Q,A) like test.txt.

add

add_from_file

cargo run -- add

or

cargo run -- add test.txt
  1. Edit a flashcard:

edit

cargo run -- edit [card_id]
  1. Delete a flashcard:
cargo run -- delete [card_id]
  1. List all flashcards:

list

cargo run -- list
  1. Start a quiz:

quiz

cargo run -- quiz
  1. Play all flashcards (shuffled):

play

cargo run -- quiz

License

This project is licensed under the MIT License.

About

Rust SurrealDB example hosted with fly.io (FlashCard CLI app)

Topics

Resources

License

Stars

Watchers

Forks