Skip to content

danielkurniadi/Boggle-Game-API

Repository files navigation

Boggle Game API

Boggle Game API is a solution engineered for hosting simple Boggle Game. The REST API is written in Python3 using Flask webframework and has testing suite available both in Python (unit-tests and integration tests) and Ruby (end-to-end tests).

Boggle Game

Boggle is a word game that is played on a 4x4 board with 16 letter tiles. The goal is to find as many words as possible given a time constraint.

Now it is possible for one or more of the letter tiles to be blank (denoted by *). When a tile is blank, it can be treated as any other letter. Example board:

A C E D
L U G *
E * H T
G A F K

Some sample words from this board are ace, dot, dug, eight, hole, huge, hug, tide.

Installation & Setup

This project requires Python 3 and Ruby, followed by some libraries.

Requirements

This application mainly run and tested for Ubuntu 18.04.

  • python >= 3.6
  • MongoDB
  • python3-venv
  • ruby >= 2.5
  • git

Python3 and Python3-venv

Install Python3

You can directly download the binary source from

If you're using linux/ubuntu (12.0 - 18.04) you can install python3 by using apt-get as follows:

$ sudo apt-get update
$ sudo apt-get install python3.6
$ python3 --version  # check installation successful
$ which python3  # check software bash directory

Install & Setup Venv

Then install virtualenv manager. There are many python virtualenv manager but here we choose to pick venv. To install, run apt-get command:

$ sudo apt-get install python3-venv  # install venv
$ python3 -m venv .venv  # create virtual environment called .venv

Install Python Packages

$ source .venv/bin/activate  # activate virtual environment (.venv)
(.venv) $ pip3 install -r requirements.txt # ensure you are using .venv and python 3.6

Ruby

First, install Ruby. Then run the following commands under the project directory.

$ruby -v # confirm Ruby present
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

$ gem install bundler # install bundler to manage dependencies
$ bundle install  # install dependencies using Gemfile
...
...
Bundle complete! 3 Gemfile dependencies, 8 gems now installed.

Mongo DB Setup

You need to install Mongo DB in your machine.

$ sudo apt install -y mongodb
$ sudo systemctl status mongodb  # check mongodb status
$ sudo systemctl start mongodb   # if mongodb not active/running, start db using systemctl

Runing Server

Manual using Command Line

The entry points for running Flask application is the run.py script. There are several environment variables that you need to provide:

$ export DATABASE_URI=mongodb://localhost:27017/testdb  # get your db url
$ export HOST=127.0.0.1
$ export PORT=5001
$ export ENV=testing  # testing mode
$ export DEBUG=1  # debug mode
$ export UNIT_TEST_MODE=1  # disable logging for unit testing

$ python3 run.py # available at 127.0.0.1:5001

Using Docker Container

Running with docker container is easy. First make sure you have docker ready and setup in your machine.

$ sudo bash deploy/build_app.sh  # build image
$ sudo bash deploy/run_mongo.sh  # mongo server running on container
$ sudo bash deploy/run_app.sh  # application running on localhost:5001

Run Testing

Execute the script below to run all tests in pytest.

(.venv)$ python3 run_pytest.py

Tests Results

  • Commit : 148139a Pytest

  • Commit: 148139a

Ruby