Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/m4tx/chombo-gen

Web service generating images of Japanese (Riichi) Mahjong hands.
https://github.com/m4tx/chombo-gen

mahjong riichi rust webapp

Last synced: about 2 months ago
JSON representation

Web service generating images of Japanese (Riichi) Mahjong hands.

Awesome Lists containing this project

README

        

chombo-gen
==========

[![Rust Build Status](https://github.com/m4tx/chombo-gen/workflows/Rust%20CI/badge.svg)](https://github.com/m4tx/chombo-gen/actions/workflows/rust.yml)
[![Docker Build Status](https://github.com/m4tx/chombo-gen/workflows/Docker/badge.svg)](https://github.com/m4tx/chombo-gen/actions/workflows/docker-publish.yml)
[![GNU AGPL v3 licensed](https://img.shields.io/github/license/m4tx/chombo-gen)](https://github.com/m4tx/chombo-gen/blob/master/LICENSE)

ChomboGen is a web service that allows to generate images of Japanese (Riichi) Mahjong hands. The hands are provided in a text format and are generated in PNG format.

**See it in action on [hand.chombo.club](https://hand.chombo.club).**

![Riichi Hand Generator screenshot](docs/screenshot1.png)

## Development

The project is written purely in [Rust](https://www.rust-lang.org/), both its backend and frontend.

### Backend

To run the development server, execute:

```shell
cd chombo-gen-backend
cargo run
```

This will start the server at [localhost:8000](http://localhost:8000).

To build a release version, execute:

```shell
cargo build --release
```

The target binary will be put at `target/release/chombo-gen-backend`.

### Frontend

Frontend uses the [yew](https://yew.rs/docs/getting-started/build-a-sample-app) framework. The code is compiled into a WebAssembly binary and then statically served.

First, install the [Trunk](https://trunkrs.dev/) bundler and add wasm32 target support to your Rust toolchain.

```shell
rustup target add wasm32-unknown-unknown
cargo install trunk
```

Then, you can use:

```shell
cd chombo-gen-frontend
trunk serve
```

to start local server at [localhost:8080](http://localhost:8080). It assumes that the backend is running at [localhost:8000](http://localhost:8000).

To build a distributable version of the frontend, execute:

```shell
trunk build --release
```

This will build a website in `frontend/dist/` directory that can be statically served by a server such as nginx. You can override th backend URL by providing it as the `CHOMBO_GEN_API_URL` environment variable, like so:

```sh
export CHOMBO_GEN_API_URL=http://api.hand.example.com
trunk build --release
```

#### `pre-commit`
We encourage contributors to use predefined [`pre-commit`](https://pre-commit.com/) hooks — to install them in your local repo, make sure you have `pre-commit` installed and run:

```shell
pre-commit install
```

## Deployment

The easiest way to try locally or deploy _chombo-gen_ is to use auto-generated Docker images. There is a separate image for backend, frontend, and a reverse proxy (that exposes both the backend and frontend under the same server), all of which are published on [the GitHub Container Registry](https://github.com/m4tx?tab=packages&repo_name=chombo-gen). There is an example `docker-compose.yml` file provided in the repository root.

In the project root directory, execute:

```shell
docker compose up -d
```

After that, the website will be available on at [localhost:8000](http://localhost:8000).

## Attribution

This project uses [riichi-hand-rs](https://github.com/m4tx/riichi-hand-rs) library, which uses:

* modified [riichi-mahjong-tiles](https://github.com/FluffyStuff/riichi-mahjong-tiles) by [FluffyStuff](https://github.com/FluffyStuff) in [public domain/CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/),
* mahjong tiles by [Martin Persson](https://www.martinpersson.org/) which are free for personal and commercial use under the condition that a link to the author's page is provided.