/pacman-api-java

The Spring Boot API for Pac-Man

Primary LanguageJava

Pac-Man API

This repository is the Java backend server for my solo Pac-Man project. This API connects to both MongoDB and Redis databases to store and retrieve user account and score data respectively.

The JS Express version of this API (deployed version) can be found at https://github.com/jmcnally17/pacman-api-js

This API pairs with a client app that has multiple versions:
React (deployed version): https://github.com/jmcnally17/pacman-client-react
SolidJS (in progress): https://github.com/jmcnally17/pacman-client-solid

The original project monolith (with a full comprehensive commit history) can be found at https://github.com/jmcnally17/pacman-old

Technologies Used

Running Locally

This API can be run on your localhost. However, a number of frameworks need to be installed which requires some setup to do.

Getting Started

This webapp can be built and run using Gradle, a build automation tool for Java. However, you will need a JDK, which, like Gradle, can installed via Homebrew (which can be installed using the instructions here):

brew install openjdk
brew install gradle

MongoDB and Redis will need to be installed as they are the databases that store user data and scores:

brew tap mongodb/brew
brew install mongodb-community@5.0
brew install redis

Then, start MongoDB by using:

brew services start mongodb-community@5.0

How To Use

Now, you can clone this repository:

git clone https://github.com/jmcnally17/pacman-api-java.git

You can then build the app by entering gradle build while in the main directory.

Your local Redis server may need to be running for the backend to connect to it. Enter

redis-server

into a separate terminal to do this.

Now you can run the server by entering gradle bootRun while in the main directory and the API will be ready to receive requests.

In order to play the game, you must also be running the client application alongside this server (link to that repo found at the top of this README).

You can also run this API using Intellij IDEA by simply running the App.java file (although you may need to take care with compatible JDK versions).

Testing

Tests can be run while in the main directory by running gradle test. Code coverage statistics are generated in a build/coverage folder using the Jacoco plugin. Tests were written first in order to adhere to the test-driven development (TDD) process by following the red-green-refactor cycle.