Board Game and Match Management System
To get started with the project, follow these steps:
git clone https://github.com/xebia-functional/board-game-training.git
Create or modify the src/main/resources/application.properties
file with the following example configuration:
spring.application.name=boardGameTraining
# Server Configuration
server.port=8080
# JPA properties
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
spring.jpa.show-sql=true
# PostgreSQL configuration
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.driver-class-name=org.postgresql.Driver
#Database properties
spring.datasource.url=jdbc:postgresql://localhost:5432/yourDatabaseName
spring.datasource.username=postgres
spring.datasource.password=postgres
# Kotlin Parser Info
external.service.host=localhost
external.service.port=8081
external.service.scheme=http
# Flyway
spring.flyway.enabled=true
spring.flyway.locations=classpath:db/migration
spring.flyway.baseline-on-migrate=true
mvn clean install
mvn spring-boot:run
- Open IntelliJ IDEA.
- Select "Open" and navigate to the folder where you cloned the project.
- Once the project is opened, IntelliJ should automatically detect the
pom.xml
file and configure it as a Maven project. - If it is not detected automatically, right-click the
pom.xml
file and select Add as Maven Project.
- Go to the
BoardGameTrainingApplication
class located in the packagecom.es.boardGameTraining
. - Inside the class, click the Play (Run) button at the top right of IntelliJ to run the project.
-
Make sure you have Docker and Docker Compose installed on your machine.
-
Run the following command to start the PostgreSQL database container:
docker-compose up -d
-
Access the postgreSQL database using:
- Database URL:
jbdc:postgresql://localhost:5490/board-game-training-bd
- Username:
postgres
- Password:
postgres
- Database URL:
- The PostgreSQL service in Docker will be exposed on port
5490
The project uses Docker Compose to spin up a PostgreSQL container, please check the file to see the details: docker-compose.yml.
- If you wish to modify the database name, username, or password, you can do so by changing the values in the
docker-compose.yml
and theapplication.properties
file. - The PostgreSQL service in Docker will be exposed on port
5490
GET /
: Retrieves information about all players.- Input: N/A.
- Output: List of all PlayerDTO objects.
- Exceptions:
- Internal Server Error (Error 500): Internal database error.
GET /{nickname}
: Retrieves player information by nickname.- Input:
nickname
parameter. - Output: PlayerDTO object.
- Exceptions:
- Bad Request Exception (Error 400): The nickname field cannot be empty.
- Player not found (Error 404): No player is associated with that nickname.
- Internal Server Error (Error 500): Internal database error.
- Input:
POST /
: Creates a new player.- Input: JSON containing
name
andnickname
. - Output: PlayerDTO object.
- Exceptions:
- Bad Request Exception (Error 400): The name and nickname fields cannot be empty.
- Internal Server Error (Error 500): Internal database error.
- Input: JSON containing
GET /
: Retrieves information about all games.- Input: N/A.
- Output: List of all GameDTO objects.
- Exceptions:
- Internal Server Error (Error 500): Internal database error.
GET /{id}
: Retrieves game information by id.- Input:
id
parameter. - Output: GameDTO object.
- Exceptions:
- Bad Request Exception (Error 400): The id field cannot be empty.
- Game not found (Error 404): No game matches the given id.
- Internal Server Error (Error 500): Internal database error.
- Input:
GET /search/{parameter}
: Retrieves game information by title, author, or artist.- Input:
parameter
. - Output: List of GameDTO objects.
- Exceptions:
- Bad Request Exception (Error 400): The parameter field cannot be empty.
- Game not found (Error 404): No game matches the given parameters.
- Internal Server Error (Error 500): Internal database error.
- Input:
GET /search/bgg/{name)
: Retrieves game information by name from the BGG API.- Input:
name
. - Output: List of games results from the BGG API.
- Exceptions:
- Bad Request Exception (Error 400): The name field cannot be empty.
- Internal Server Error (Error 500): Internal database error.
- Input:
POST /{id}
: Creates a game using the "id" parameter from the public BGG API.- Input:
id
parameter. - Output: GameDTO object.
- Exceptions:
- Bad Request Exception (Error 400): The id field cannot be empty.
- Game not found (Error 404): No game matches the given id.
- Internal Server Error (Error 500): Internal database error.
- Input:
GET /
: Retrieves information about all matches.- Input: N/A.
- Output: List of all PlayDTO objects.
- Exceptions:
- Internal Server Error (Error 500): Internal database error.
POST /
: Creates a new match.- Input: JSON containing
location
,winner
,players
andgame
. - Output: PlayDTO object.
- Exceptions:
- Bad Request Exception (Error 400): The location, winner, and players fields cannot be empty.
- Internal Server Error (Error 500): Internal database error.
- Input: JSON containing