You are contracted to refactor Professor Farnsworth's legacy client/server code, and you decide to spice weasel (BAM!) things up with K8s, gRPC, and GraphQL. The professor wants to run a gateway service at the Planet Express headquarters that can communicate with Planet Express ship via gRPC. Furthermore, he wants a nice React UI to show data about the ship, deliveries, crew members, etc that will communicate with the gateway service via GraphQL.
When you are done shopping for lightspeed briefs you decide to setup the new project. You realize that some of it is already set up for you. The ./headquarters
directory contains the gateway/client code and the
./ship
directory contains the server code.
- Create a gitlab repo called
planet-express
- Setup Your Dev Environment
- Install go (https://golang.org/doc/install)
- Install protoc (https://grpc.io/docs/protoc-installation/)
- Follow the getting started guide to install the protoc go plugin (https://grpc.io/docs/languages/go/quickstart/)
go get google.golang.org/grpc
go get github.com/golang/protobuf
- Copy the files in this repo over to your new repo
- Run
go mod init gitlab.com/<gitlab-username>/planet-express
- Your go mod should look something like the included
_go.mod
file (delete this file when done) - Fix the import statements in
./ship/main.go
and./headquarters/main.go
(the lines commented like so// pb "gitlab.com/<gitlab-username>/planet-express/ship/pkg/planetexpress"
) - Validate that you can build and genarate go code by running
make
- Validate you have the executables
./ship/ship
and./headquarters/headquarters
- Run the server
./ship/ship
and the client./headquarters/headquarters
in separate terminal windows and confirm the output.
The protoc compiler with the go plugin will autogenerate client and server grpc stubs for you. Make sure this runs successfully with make
You should try changing the protobuf files in ./proto
and re-run make
. The generated files are put in ./ship/pkg/planetexpress
and ./headquarters/pkg/planetexpress
A makefile has been provided for you that will generate go code with the protoc compiler and build the executables. Run make
and validate that you have executables at ./ship/ship
and ./headquarters/headquarters
To run the server (./ship
) using Docker, run make docker
and the server will start on port 10000.
Time Estimate: 3 hours
The basic client and server code has been provided for you. Your job is to do the following:
- Implement
crew.proto
anddelivery.proto
and the functions listed inplanet_express_service.proto
- You should experiment with different protobuf types for the crew and delivery resources. Each resource should demonstrate an understanding of protobuf.
- Refactor
ship.proto
to use thecrew
anddelivery
resources. - Implement the rpc functions (defined in
planet_express_service.proto
) in both the client (./headquarters
) and server (./ship
), following theGetShip
example. You do not need to add a database. Experiment with using data contained in the gRPC request. - Output data about the planet express ship, deliveries, and crew members to a json file called
planet_express.json
. Feel free to get creative with your data and protobuf resources. - Add a dockerfile to
./ship
so that we can run the server with docker.
Time Estimate: 4 hours
- Provide a basic helm template for the
./ship
server. This should contain a kubernetes deployment and service. We should be able to port-forward your service to call the./ship
rpc functions. - Add additional protobuf resources like
ShipEngine
. You can get creative with this. - Add GraphQL support to the gateway (headquarters client). A good library for this is https://github.com/graph-gophers/graphql-go
- Map a graphql resource and endpoint to a gRPC call such that you can use a GraphQL client to get data from the ship backend.
Time Estimate: 4 hours
- Add a simple React SPA that displays data about the ship using GraphQL to communicate with the gateway (headquarters service). You can put this in the
./dashboard
directory. - Add some go unit tests to the ship server.
** These would really impress us here at Planet Express! **
Make your repository public and share the repo url with Divvy's recruiter.
- https://grpc.io/docs/languages/go/quickstart/
- https://grpc.io/docs/languages/go/basics/
- https://cloud.google.com/apis/design
- https://github.com/graph-gophers/graphql-go
- https://reactjs.org/docs/create-a-new-react-app.html
If you find errors or otherwise need clarification on anything in the excercise, please reach out to Justin Sharp [email protected].
- Implemented
crew.proto
anddelivery.proto
and the functions listed inplanet_express_service.proto
. - Added
crew
anddelivery
resources toship.proto
- Implemented rpc functions in client and server
- Outputted data to
planet_express.json
- Added Dockerfile to
./ship
- Updated
README.md
with details on how to run./ship
in a container --> Using Docker
- SKIPPED help template
- Added
ship_engine
andweapon
resources and added them toship.proto
- Added GraphQL support to client (
./headquarters
) - Mapped multiple resources and endpoints to gRPC calls
- Created React UI for backend services that displays ship, crew, and delivery information
- Added a few unit tests to server (
./ship
)
After going through Setup, follow these steps to bootstrap the entire project.
- navigate to the root directory
make
- navigate to the UI directory (
./dashboard
) npm install
npm start
- Open a new terminal window to the root directory and run
./ship/ship
- Open a new terminal window to the root directory and run
./headquarters/headquarters