/memory-backend

Backend for the memory minigame

Primary LanguageJavaOtherNOASSERTION

Memory-backend

This repository contains the backend for the Memory minigame.

It persists the game data (configurations, game results, etc.) in a database and communicates with other backend services.

Table of contents

Links

  • User documentation for the minigame can be found here.
  • For the frontend, see the Gamify-IT/memory repository.
  • The installation manual and setup instructions can be found here.

Getting started

Make sure you have the following installed:

First you have to change the spring.datasource.username and the spring.datasource.password in the application.properties file. If you changed the properties of the postgres db, you also have to change spring.datasource.url.

Run

Docker-compose

Start all dependencies with our docker-compose files. Check the manual for starting the dependencies with docker-compose .

Project build

mvn install

in the folder of the project. Go to the target folder and run

java -jar memory-service-0.0.1-SNAPSHOT.jar

With Docker

Build the Docker container with

docker build  -t memory-backend-dev .

And run it at port 8000 with

docker run -d -p 8000:80 -e POSTGRES_URL="postgresql://host.docker.internal:5432/postgres" -e POSTGRES_USER="postgres" -e POSTGRES_PASSWORD="postgres" --name memory-backend-dev memory-backend-dev

To monitor, stop and remove the container you can use the following commands:

docker ps -a -f name=memory-backend-dev
docker stop memory-backend-dev
docker rm memory-backend-dev

To run the prebuild container use

docker run -d -p 8000:80 -e POSTGRES_URL="postgresql://host.docker.internal:5432/postgres" -e POSTGRES_USER="postgres" -e POSTGRES_PASSWORD="postgres" --name memory-backend ghcr.io/gamify-it/memory-backend:latest

Testing Database

to setup a database with docker for testing you can use

docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres  --rm --name memory-database postgres

To stop and remove it simply type

docker stop memory-database

Rest API

Rest mappings are defined in

Swagger-Ui

When the service is started (see Getting started), you can access the API documentation:

Open http://localhost/minigames/memory/api/v1/swagger-ui/index.html#/ and fill http://localhost/minigames/memory/api/v1/v3/api-docs into the input field in the navbar.