Skip to content

mohitk09/cards_game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cards Game

♠️♥️ ♣️♦️ This project creates card game APIs that could be used in Poker, Blackjack, or any other card game.

APIs

Three APIs have been written, which are scalable and could be used in any game.

GET  /                    # Health check
POST /deck                # This creates a new deck (optional params: cards, shuffle) -- cards
                            can also be passed as a query param, the API would then just
                            create a deck with those cards
GET  /deck/:id            # Retrieves a deck by id, all the cards should be returned
GET  /deck/:id/draw       # Draw cards from the deck (optional params: count) -- The count is
                            the number of cards that should be drawn, default value is 1.
                            It simulates a stack operation

Dependencies

  1. Fiber for setting up the routes
  2. Gorm for the ORM layer
  3. Sqllite3 as choice of the DB

Repository Structure

The Project is divided into several packages, important ones are:-

  1. Database :- Has basic CRUD operations, uses Sqllite under the hood
  2. API :- All three APIs reside in this folder
  3. Utils:- Functions which are used across different files
  4. Types:- All the types/structs and functions which are dependent on those types
  5. There are also some test cases which have been added, and can be run by the go test command

Run it locally

  • Clone the repo, and install the go dependencies. You could either do go mod download or go get ./....
  • Execute go run entry_point.go which starts the server by configuring DB and the routes.
  • Check if http://localhost:8080 shows the message Server running. If yes the project setup is done.
  • You can start by creating some decks and copying the UUIDs to later open the deck or draw cards.

Future scope

  1. More extensive test cases, currently just covering basic test cases.
  2. Creating a docker file so that it becomes easier to test and deploy.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages