https://github.com/alfex4936/flashcard-surrealdb
Rust SurrealDB example hosted with fly.io (FlashCard CLI app)
https://github.com/alfex4936/flashcard-surrealdb
cli rust surrealdb
Last synced: about 1 month ago
JSON representation
Rust SurrealDB example hosted with fly.io (FlashCard CLI app)
- Host: GitHub
- URL: https://github.com/alfex4936/flashcard-surrealdb
- Owner: Alfex4936
- License: mit
- Created: 2023-04-25T08:59:48.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-25T10:14:53.000Z (almost 2 years ago)
- Last Synced: 2025-01-27T07:41:48.354Z (3 months ago)
- Topics: cli, rust, surrealdb
- Language: Rust
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://surrealdb.com/docs/deployment/fly)
## Project Structure
```yaml
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:
```bash
git clone https://github.com/Alfex4936/FlashCard-SurrealDB
```2. Change to the project directory:
```bash
cd FlashCard-SurrealDB
```3. Install the dependencies:
```bash
cargo build
```4. Create a `.env` file in the project root with your SurrealDB credentials:
```bash
SURREALDB_DB_NS=namespace
SURREALDB_DB_DB=db_name
SURREALDB_DB_USER=username
SURREALDB_DB_PW=password
FLYIO_HOST=your.fly.dev
```5. Run the application:
```bash
cargo run
```## Docker
Can run it in Docker ~100MB image.
```bash
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`.


```bash
cargo run -- addor
cargo run -- add test.txt
```2. Edit a flashcard:

```bash
cargo run -- edit [card_id]
```3. Delete a flashcard:
```bash
cargo run -- delete [card_id]
```4. List all flashcards:

```bash
cargo run -- list
```5. Start a quiz:

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

```bash
cargo run -- quiz
```## License
This project is licensed under the MIT License.