Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/petarvujovic98/rust-graphql-sonic

An example search application with Sonic and async-graphql written in Rust
https://github.com/petarvujovic98/rust-graphql-sonic

Last synced: about 1 month ago
JSON representation

An example search application with Sonic and async-graphql written in Rust

Awesome Lists containing this project

README

        

# Rust Graphql Sonic

## Intro

This is an example project made for demonstrating the use of a search as a service engine
(such as [Elasticsearch](https://github.com/elastic/elasticsearch),
or in this case [Sonic](https://github.com/valeriansaliou/sonic)) in a web application
backend written in [Rust](https://github.com/rust-lang/rust) using the
[actix-web](https://actix.rs) web framework and [async-graphql](https://github.com/async-graphql/async-graphql).

## Data

The project uses the free dataset of [tennis_atp](https://github.com/JeffSackmann/tennis_atp)
tennis matches and players.

Only the singles matches are processed by this project.

### Matches files columns

The columns in the matches files are as follows:

1. turney_id
2. tourney_name
3. surface
4. draw_size
5. tourney_level
6. tourney_date
7. match_num
8. winner_id

16. loser_id

24. score
25. best_of
26. round
27. minutes

### Data representation

Each match is represented by a match id which is a combination of the tourney id at which
the match was played and the match number,
and the textual description of the match in the following format:

```rust
format!(
"{} beat {} at {} in a {}",
winner_info,
loser_info,
tourney_info,
match_info
);
```

## Setup

In order to run this project you will need to provide PostgreSQL and Sonic server URLs or run this project using `docker-compose`.

Before running the web server you need to fill the database and Sonic instance with the data which you can do by running the `filler`
binary crate or by running the `filler` service with docker-compose. This service requires you to download the tennis_atp repository
files which you can do by running [`setup_project.sh`](https://github.com/petarvujovic98/rust-graphql-sonic/blob/master/setup_project.sh)
script.

## Running the project

### Fill database and sonic

```shell
cargo run --bin filler ./tennis_atp
```

or with docker-compose:

```shell
docker-compose up filler
```

### Run server

```shell
cargo run --bin server
```

or with docker-compose:

```shell
docker-compose up server
```