Welcome to the Senior Backend Coding Challenge! This challenge is designed to assess your skills in Node.js, GraphQL, MQTT, and Redis. You'll be working with two services: the "Hub Manager" and the "Box Driver."
This service exposes a GraphQL API and is responsible for managing the state and actions of the "Box Driver"
This service simulates a remote hardware component with multiple compartments that can be opened and closed.
Both services communicate with each other using MQTT, and Redis is used for storing state and Pub/Sub functionalities.
sequenceDiagram
participant c as Client
participant h as Hub Manager
participant m as MQTT Broker
participant b as Box Driver
b ->> m: Subscribe Message:<br>hub open
c ->> h: Mutation<br>open
activate h
h ->> m: Publish Message<br>hub open
h ->> m: Subcribe Message<br>hub opened
m ->> b: Message<br>hub open
b ->> b: Open Box
b ->> m: Publish Message:<br>hub opened
m ->> h: Message<br>hub opened
h ->> c: True
deactivate h
Your first task is to create a GraphQL resolver that can determine whether the Box Driver is online or not. This will be crucial for monitoring the health of the system.
Implement the functionality to open and close the compartments in the Box Driver through the Hub Manager's GraphQL API. Make sure that the state is accurately reflected and stored.
Enable a "Failure Mode" in the system (see .env
in box-driver
). In this mode, the Box Driver simulates a network disconnect in a regular interval
How would you ensure that interactions that occurred when the Box Driver was offline are still processed once it comes back online?
- Clone the boilerplate repository.
- Run
pnpm install
to install all required dependencies - Navigate to the
Hub Manager
andBox Driver
directories to understand the existing codebase. - Start implementing the tasks.
The servers are started via:
pnpm nx serve hub-manager # Starts the hub-manager
pnpm nx serve box-driver # Starts the box-driver
docker-compose up # Starts the MQTT broker and a Redis instance
Good luck!