Skip to content

Commit

Permalink
πŸ“šdoc: add API server documentation and restructure content
Browse files Browse the repository at this point in the history
- add API server documentation including setup and usage instructions
- add environment variables section for API server configuration
- add installation and uninstallation guide for API server
- restructure document headers to improve readability
- update CLI section descriptions to be more concise
  • Loading branch information
yanosea committed Jan 25, 2025
1 parent fb90ac0 commit d0e2b5e
Showing 1 changed file with 117 additions and 24 deletions.
141 changes: 117 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@

## ℹ️ About

`jrp` is the CLI jokeey tool to generate Japanese random phrases.
You can save the generated phrases to the history and manage them.
Also, you can favorite the generated phrases and manage them.

`jrp` generates Japanese random phrases.
This tool uses [WordNet Japan sqlite database file](https://bond-lab.github.io/wnja/jpn/downloads.html).

## πŸ’» Usage
## πŸ“Ÿ CLI

You can generate and save the generated phrases to the history and manage them via the CLI.
Also, you can favorite the generated phrases and manage them.

### πŸ’» Usage

```
Available Subcommands:
Expand Down Expand Up @@ -57,7 +59,7 @@ Argument:
number πŸ”’ number of phrases to generate (e.g. : 10)
```

## πŸ’¬ Interactive mode
### πŸ’¬ Interactive mode

![demo_interactive](docs/demo_interactive.gif "demo_interactive")

Expand Down Expand Up @@ -93,44 +95,44 @@ Press either key below for your action.
- `other`
- Skip, exit.

## 🌍 Environments
### 🌍 Environments

### πŸ“ Connection string of WordNet Japan database
#### πŸ“ Connection string of WordNet Japan database

Default : `$XDG_DATA_HOME/jrp/wnjpn.db` or `$HOME/.local/share/jrp/wnjpn.db`

```sh
export JRP_WNJPN_DB=/path/to/your/directory/wnjpn.db
```

### πŸ“ Connection string of jrp database
#### πŸ“ Connection string of jrp database

Default : `$XDG_DATA_HOME/jrp/jrp.db` or `$HOME/.local/share/jrp/jrp.db`

```sh
export JRP_DB=/path/to/your/directory/jrp.db
```

## πŸ”§ Installation
### πŸ”§ Installation

### 🐭 Using go
#### 🐭 Using go

```sh
go install github.com/yanosea/jrp/v2/app/presentation/cli/jrp@latest
```

### 🍺 Using homebrew
#### 🍺 Using homebrew

```sh
brew tap yanosea/tap
brew install yanosea/tap/jrp
```

### πŸ“¦ Download from release
#### πŸ“¦ Download from release

Go to the [Releases](https://github.com/yanosea/jrp/releases) and download the latest binary for your platform.

## ✨ Update
### ✨ Update

### 🐭 Using go

Expand All @@ -140,57 +142,148 @@ Reinstall `jrp`!
go install github.com/yanosea/jrp/v2/app/presentation/cli/jrp@latest
```

### 🍺 Using homebrew
#### 🍺 Using homebrew

```sh
brew update
brew upgrade jrp
```

### πŸ“¦ Download from release
#### πŸ“¦ Download from release

Download the latest binary from the [Releases](https://github.com/yanosea/jrp/releases) page and replace the old binary in your `$PATH`.

## 🧹 Uninstallation
### 🧹 Uninstallation

### πŸ”§ Uninstall jrp
#### πŸ”§ Uninstall jrp

#### 🐭 Using go
##### 🐭 Using go

```sh
rm $GOPATH/bin/jrp
# maybe you have to execute with sudo
rm -fr $GOPATH/pkg/mod/github.com/yanosea/jrp*
```

#### 🍺 Using homebrew
##### 🍺 Using homebrew

```sh
brew uninstall jrp
brew untap yanosea/tap/jrp
```

#### πŸ“¦ Download from release
##### πŸ“¦ Download from release

Remove the binary you downloaded and placed in your `$PATH`.

### πŸ—‘οΈ Remove data files
#### πŸ—‘οΈ Remove data files

If you've set jrp envs, please replace `$HOME/.local/share/jrp` with envs you've set.
These below commands are in the case of default. Ofcourse you can remove whole the directory.

#### πŸ’Ύ Remove WordNet Japan sqlite database file
##### πŸ’Ύ Remove WordNet Japan sqlite database file

```sh
rm $HOME/.local/share/jrp/wnjpn.db
```

#### πŸ’Ύ Remove jrp sqlite database file
##### πŸ’Ύ Remove jrp sqlite database file

```sh
rm $HOME/.local/share/jrp/jrp.db
```

## 🌐 API Server

`jrp` also provides RESTful API server that you can use to get Japanese random phrases.

### πŸ’» Usage

```sh
# If you installed with go, you can run the server with the command below.
jrp-server
# If you cloned the repository, you can run the server with the command below.
go run app/presentation/api/jrp-server/main.go
```

```sh
# Then, you can access the API server with the URL below.
curl http://localhost:8080/api/jrp
```

### πŸ“š API Documentation

Swagger documentation is available at: `http://localhost:8080/swagger/index.html`

#### Available Endpoints

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/jrp` | Get a generated Japanese random phrase |

### ⚑ Caution

You have to download the WordNet Japan sqlite database file from [WordNet Japan](https://bond-lab.github.io/wnja/jpn/downloads.html) before running the server.

### 🌍 Environments

#### 🚒 Port number

Default : `8080`

```sh
export JRP_SERVER_PORT=8080
```

#### πŸ“ Connection string of WordNet Japan database

Default : `$XDG_DATA_HOME/jrp/wnjpn.db` or `$HOME/.local/share/jrp/wnjpn.db`

```sh
export JRP_SERVER_WNJPN_DB=/path/to/your/directory/wnjpn.db
```

### πŸ”§ Installation

#### 🐭 Using go

```sh
go install github.com/yanosea/jrp/v2/app/presentation/api/jrp-server@latest
```

#### πŸš€ With source code

```sh
git clone github.com/yanosea/jrp
cd jrp
go run app/presentation/api/jrp-server/main.go
```

### 🧹 Uninstallation

#### πŸ”§ Uninstall jrp-server

##### 🐭 Using go

```sh
rm $GOPATH/bin/jrp
# maybe you have to execute with sudo
rm -fr $GOPATH/pkg/mod/github.com/yanosea/jrp*
```

##### πŸš€ With source code

Remove the directory you cloned.

#### πŸ—‘οΈ Remove WordNet Japan sqlite database file

If you've set jrp-server envs, please replace `$HOME/.local/share/jrp` with envs you've set.
These below commands are in the case of default. Ofcourse you can remove whole the directory.

```sh
rm $HOME/.local/share/jrp/wnjpn.db
```

## πŸ“ƒ License

[πŸ”“MIT](./LICENSE)
Expand Down

0 comments on commit d0e2b5e

Please sign in to comment.