Reel games
Backend (complete)
- Express-based server, supporting the following endpoints:
/login
[POST]: sign-up, expectingusername
andpassword
both mandatory/user
[POST]:username
,password
,country
fields are mandatory,firstName
andlastName
nullable, but not undefined Afterlogin
Bearer JWT-token will be issued, and required for endpoints:/allGames
[GET]: to fetch list of games in JSON format/deposit
[POST]: insert "coin" into slot machine, default value: 20/spin
[POST]: spin the reels, returning reward as described below/favoriteGames
[POST]: to get eliguble set of users as per instruction, a junction tableUser_Game
is used with additonal boolean columnFavorite
to mark the preference relationship for a user-game pair
Instructions for reel machine reward
# slot machines only consider pairs a match if they are in order from left to right:
● Apple, Cherry, Apple - no win
● Apple, Apple, Cherry - win
Rewards
● 3 cherries in a row: 50 coins, 2 cherries in a row: 40 coins
● 3 Apples in a row: 20 coins, 2 Apples in a row: 10 coins
● 3 Bananas in a row: 15 coins, 2 Bananas in a row: 5 coins
● 3 lemons in a row: 3 coins
Database
- using
migrations
would be a best approach, both for initiating and seeding database, but given custom files, setup withsql-native
files would be a work in itself, so instead the following is implemented: sequlize
is used to create (initiate) tables, schema is left as defaultpublic
- For seeding data with
games.json
and inserting custom users,db/seed/index.ts
is used - when the server is started, all necessary tables are generated with
sequelize
, then all you need to do is to make a post request to/seedGames
with null body, but JWT-token is required - For deployment,
fly.io
service is used, as it has free support forpostgres
database
Use the following commands to run and deploy:
cd server
npm install
# local development with docker-hosted postgres
docker-compose run --build
#deploy
fly auth signup
fly launch
# provided with following url: https://reels.fly.dev
To check the work of backend from POSTMAN, consult postman
with json-file of a collection with requests
Front-end
The web app was built with Vue.js SPA
- On the front-end,
/login-register
are available to register and get JWT-token, and stored in-memory - On the protected page,
/dashboard
, a user can:- see a list of games from backend as per
games.json
file - With
deposit
button, a user can20
coins to his balance - While
spin
button, wheels the reels on the backend, returing reward outcome & debiting balance by1
coin search
for a game with dynamic list - not implemented
- see a list of games from backend as per
To deploy, netlify
service was used as follows:
cd client
npm install
# development
npm run serve
npm run build
# deploy
netlify login
netlify init
netlify deploy --build
# provided with following link: https://reels-game.netlify.app/