From abce265ba5064ff8ef6a451699d29bf2ac4976ef Mon Sep 17 00:00:00 2001 From: Brandon Watson Date: Tue, 15 Aug 2023 14:45:58 -0500 Subject: [PATCH] Updating README with run instructions --- ...terview Assignment.postman_collection.json | 330 ++++++++++++++++++ README.md | 37 +- 2 files changed, 364 insertions(+), 3 deletions(-) create mode 100644 Crossnokaye Interview Assignment.postman_collection.json diff --git a/Crossnokaye Interview Assignment.postman_collection.json b/Crossnokaye Interview Assignment.postman_collection.json new file mode 100644 index 0000000..6365e06 --- /dev/null +++ b/Crossnokaye Interview Assignment.postman_collection.json @@ -0,0 +1,330 @@ +{ + "info": { + "_postman_id": "9392df0e-7e20-4c0b-9992-dc37893ba7e9", + "name": "Crossnokaye Interview Assignment", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "20397523" + }, + "item": [ + { + "name": "Item", + "item": [ + { + "name": "Create Item", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"item2\",\n \"description\": \"item description\",\n \"damage\": 1,\n \"healing\": 1,\n \"protection\": 1\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8000/item", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "item" + ] + } + }, + "response": [] + }, + { + "name": "Update Item", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"item\",\n \"description\": \"item description\",\n \"damage\": 1,\n \"healing\": 2,\n \"protection\": 1\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8000/item/item", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "item", + "item" + ] + } + }, + "response": [] + }, + { + "name": "Get Item", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8000/item/5", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "item", + "5" + ] + } + }, + "response": [] + }, + { + "name": "Delete Item", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8000/item/item", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "item", + "item" + ] + } + }, + "response": [] + }, + { + "name": "List Items", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8000/item", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "item" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Character", + "item": [ + { + "name": "Create Character", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": 1,\n \"name\": \"brandon\",\n \"description\": \"brandon's character\",\n \"health\": 100,\n \"experience\": 10\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8000/character", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "character" + ] + } + }, + "response": [] + }, + { + "name": "Update Character", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": 1,\n \"name\": \"brandon\",\n \"description\": \"brandon's character\",\n \"health\": 100,\n \"experience\": 100\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8000/character/brandon", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "character", + "brandon" + ] + } + }, + "response": [] + }, + { + "name": "Get Character", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8000/character/brandon", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "character", + "brandon" + ] + } + }, + "response": [] + }, + { + "name": "Delete Character", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8000/character/brandon", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "character", + "brandon" + ] + } + }, + "response": [] + }, + { + "name": "List Characters", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8000/character", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "character" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Inventory", + "item": [ + { + "name": "Add Item", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"itemName\": \"item3\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:8000/character/brandon/item", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "character", + "brandon", + "item" + ] + } + }, + "response": [] + }, + { + "name": "Remove Item", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "http://localhost:8000/character/brandon/item/item1", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "character", + "brandon", + "item", + "item1" + ] + } + }, + "response": [] + }, + { + "name": "List Inventory Items", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8000/character/brandon/item", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8000", + "path": [ + "character", + "brandon", + "item" + ] + } + }, + "response": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index ea2137d..0142340 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ The front service should not have any state of its own and should call the appro The microservices should be written in Go using the Goa framework and provided as a GitHub repository. -## Items +### Items Items should have the following attributes: @@ -41,7 +41,7 @@ Items should have the following attributes: - An amount of protection they can provide -## Characters +### Characters Characters should have the following attributes: @@ -50,6 +50,37 @@ Characters should have the following attributes: - An amount of health - An amount of experience -## Inventories +### Inventories Inventories should associate a set of items with a character. + +## Running the project + +### Install Dependencies + +1. [Tmux](https://github.com/tmux/tmux/wiki/Installing) is a terminal multiplexer which is used for running multiple services at once. TL;DR `brew install tmux` +2. [Overmind](https://github.com/DarthSim/overmind) is a process manager for Procfile-based applications and tmux. TL;DR `brew install overmind` +3. Install Goa with `go install goa.design/goa/v3/cmd/goa@v3` +4. Install the protoc protobuf compiler with `brew install protobuf` +5. Install protoc plugin for go +```text +go install google.golang.org/protobuf/cmd/protoc-gen-go@latest +go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest +``` +6. Run `./gen` to generate boilerplate code for the project +7. Build the project with `./build` + +> Note you may need to make `gen`, `build` and `server` scripts executable with `chmod 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](https://testcontainers.com) 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