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
The Project is divided into several packages, important ones are:-
- Database :- Has basic CRUD operations, uses Sqllite under the hood
- API :- All three APIs reside in this folder
- Utils:- Functions which are used across different files
- Types:- All the types/structs and functions which are dependent on those types
- There are also some test cases which have been added, and can be run by the
go test
command
- Clone the repo, and install the go dependencies. You could either do
go mod download
orgo 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.
- More extensive test cases, currently just covering basic test cases.
- Creating a docker file so that it becomes easier to test and deploy.