Skip to content

API-only Rails 7 app manging game, player, and stat data for Brain Defrost trivia game

Notifications You must be signed in to change notification settings

Brain-Defrost/Brain-Defrost_BE

Repository files navigation

Brain Defrost

Table of Contents

Summary

This API-only Rails app manages game, player, and stat data for Brain Defrost. Trivia questions for a game are received from an external API via a POST request to this repository. The questions are processed as plain old ruby objects (POROs), stored with Redis caching before being attached to a trivia game and sent to the frontend, and available through all game endpoints. Multiplayer funcionality was implemented using ActionCable for WebSockets.

Game Overview

Brain Defrost is a web application designed to help people become more connected and engaged virtually via a trivia game. Generative AI is used to create custom trivia questions based on the topic and desired question count provided.

To play, a user inputs a topic, number of questions, number of players, a time limit to answer questions, and what they'd like their display name to be. The user is then taken to the game's lobby and provided with a shareable link other players may use to join. Once everyone joins, players may start the game and enjoy answering trivia questions. The correct answer and a list of players who answered correctly is displayed after each question. At the end, players may request the game's final stats via email.

Project Background

This project was completed for Turing's Capstone Project for Mod 4. Part 1 of the project pertained planning and completing our app's minimum viable product (MVP). Part 2 focused on adding additional features: caching a game's questions with Redis, implementing multiplayer with WebSockets, and allowing users to receive an email of the game results using Sidekiq for the background job.

Project Links

Repo Deployment Description
FE Repo FE Netlify Play a game of trivia
BE Repo 1 (you're here) BE Heroku Game, player, stats API
BE Repo 2 BE Render Questions API

Schema

schema diagram

Instructions

Basic Setup

  1. Fork and/or clone this repo from GitHub
  2. In terminal, run git clone <ssh or https path>
  3. Navigate into the cloned project by running cd Brain-Defrost_BE
  4. Run bundle install to install gems used for this project
  5. Setup the database by running rails db:{drop,create,migrate}

Running a Local Server

This app uses http://localhost:3000.

To start the local server run rails server in the terminal while in the app's base directory (Brain-Defrost_BE-Questions folder).

To stop the local rails server use Ctrl + C in the open terminal.

Testing

Rspec was used for testing. This project currently uses rspec-rails v6.1 and rspec-core v3.13.

Terminal commands

To run the entire test suite
bundle exec rspec spec
To run a test folder
bundle exec rspec spec/folder_name
# ex: bundle exec rspec spec/models
To run just one file
bundle exec rspec <path/to/test/file>
# ex: bundle exec rspec spec/requests/api/v1/games_spec.rb
To run just one test
bundle exec rspec <path/to/test/file>:test_line
# ex: bundle exec spec/requests/api/v1/players_spec.rb:76

Endpoints

API documentation may be accessed here. Documentation was setup using the rswag gem and SwaggerUI.

To access the API documentation on the local server. Start the server and navigate to http://localhost:3000/api-docs/index.html in a browser.

If preferred, you can also use Postman to run endpoints, but you will still need to startup the local server using the rails server command.

Contributors

Backend Team

Martin Chavez - Github | LinkedIn
Jessica Kohl - Github | LinkedIn
Laura Vega - Github | LinkedIn

Frontend Team

Ethan Duvall - Github | LinkedIn
Tayla Phillips - Github | LinkedIn

About

API-only Rails 7 app manging game, player, and stat data for Brain Defrost trivia game

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages