crossnokaye-interview-assignment
Go/Goa Design Homework Assignment Prerequisites
-
Basic familiarity with the Goa framework, including the following:
-
Introduction
-
Getting Started
-
Frequently Asked Questions
-
Design Overview
-
Examples
-
Assignment
Build a microservice application that stores characters and their item inventories for a multiplayer game. The application should be composed of the following microservices that communicate with each other:
- An HTTP/JSON front service which provides an API to manipulate the characters, their inventories, and the items that exist
- A GRPC back service that handles CRUD operations for the items that exist and their attributes
- A GRPC back service that handles CRUD operations for the characters and their attributes
- A GRPC back service that handles CRUD operations for the characters’ inventories.
The front service should not have any state of its own and should call the appropriate back services via GRPC to implement its operations. The back services may store their state in memory. CRUD operations mean create, read, update, and delete; however, read should include both listing and showing an individual record.
The microservices should be written in Go using the Goa framework and provided as a GitHub repository.
Items
Items should have the following attributes:
-
A unique name
-
A description
-
An amount of damage they can do
-
An amount of healing they can do
-
An amount of protection they can provide
Characters
Characters should have the following attributes:
- A unique name
- A description
- An amount of health
- An amount of experience
Inventories
Inventories should associate a set of items with a character.
Running the project
Install Dependencies
- Tmux is a terminal multiplexer which is used for running multiple services at once. TL;DR
brew install tmux
- Overmind is a process manager for Procfile-based applications and tmux. TL;DR
brew install overmind
- Install Goa with
go install goa.design/goa/v3/cmd/goa@v3
- Install the protoc protobuf compiler with
brew install protobuf
- Install protoc plugin for go
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
- Run
./gen
to generate boilerplate code for the project - Build the project with
./build
Note you may need to make
gen
,build
andserver
scripts executable withchmod u+x gen build server
Run
Finally, run the project with ./server
. A postman collection has been included with this project for easy testing
Future Improvements
- Add docker files for each service for easy deployment
- Unit test suites for each service
- Integration test suite for testing interactions between all services (I like to use Testcontainers for these types of tests)
- Implement pagination for all list endpoints
- Implement additional type validation
- Move front orchestrator logic separate files that encapsulate business rules