Advance | Topcoder Skill Builder Competition | Go | Space traffic control

Key Information

Register
Submit
The challenge is finished.

Challenge Overview

This is the 1500 Points Advanced level problem of Topcoder Skill Builder Competition for Golang. We are currently running a Skill builder series of contests that you can find here. This contest is NOT part of that series. Instead, it is meant for members who are comfortable working with Golang. The payment for this contest is independent of the Golang Skill Builder series of contests. The review and payments will be purely based on your solution for this contest alone.

More Skill Builder challenges in progress. Read more on our blog.

Problem Statement

The MCRN wants to build and deploy new software to all their space stations spread throughout the Solar System. With the exponential increase of trade between the OPA and the Earth the legacy systems running on Martian space stations have been having difficulty directing and optimizing traffic. As the hero of Tycho station, they’ve enlisted your help for building a system for their space stations.

MCRN has a number of space stations spread throughout the solar system. Each station has a number of docking stations. Each docking station can dock upto a maximum number of space ships. And finally the entire station has a maximum capacity where capacity is defined as the combined weight of all the space ships docked at that station. The MCRN has one centralized control center from where they maintain a registry of their space ships and the space stations. When a new shipstation is built it must register itself with the control center and publish it’s docking station details and capacity to the control center. A ship approaching a station needs to identify itself, its weight and the duration it wishes to stay at that station. The station can either ask the ship to hold for a certain amount of time if there’s no room for the ship or direct it to approach a particular docking station.

Technology Stack

What you need to do?

You need to build the following four microservices:

  • Authentication Service
  • Database Service
  • Central Command Service
  • Shipping Station Service

And write the necessary docker scripts to containerize this microservice application.

Authorization Service

This service will authenticate the user according to its specific role and return HTTP status code 200 whent he user is authorized and a JWT token with a configurable validity. It should return 401 for unauthorized users.

APIs

POST /user/signup

Header

Authorization: Bearer {JWT Token}

Body

{
	username: 'string',
	password: 'string',
	role: 'Ship' | 'Station' | 'Command',
}

This Api should create a user with the specified role. A user with role Station or Command may only be created if the requesting user has the role Command. Creating a user with role Ship does not require authentication.

POST /auth/login

Body

{
	username: 'string',
	password: 'string',
}

This Api should authenticate the user and return a JWT token - the token should have the username, userid (from database) and the user role.

Note that you'll need to provide a way to create an initial seed user with role Command

Database Service

The system will require databases to store users, stations, command center details, etc. None of the other three microservice should communicate directly with the database, but use this service to talk to the database instead. It is left up to you to decide what the Api for this service will look like and whether to use a single database per service, or a single database altogether. Please see the Grading section for how this impacts the overall score.

Central Command Service

All shipping stations and spaceships must register themselves with the central command. An unregistered shipping station can not accept spaceships, and an unregistered spaceship can not land on a shipping station. The central command has services to find out the current status of shipping stations and spaceships.

APIs

POST /centcom/station/register

Header

Authorization: Bearer {JWT Token}

Body

{
	capacity: "Float",
	docks: [{
		numDockingPorts: "Integer"
	}],
}

This Api should be called only once by a newly created shipping station. A second call to this Api should return 400: Bad Request. A valid call should return 200 with the following response

{
	id: "string - id of the shipping station",
	docks: [{
		id: "string - id of the newly created dock",
		numDockingPorts: "Integer",
	}]
}

Only users with role Ship may call this Api. Any other role should result in 400: Bad Request.

GET /centcom/station/all

Header

Authorization: Bearer {JWT Token}

This Api should return all the registered shipping stations and their current state

Sample Response

[{
	id: “string - id of the shipping station”,
	capacity: “float - total capacity”,
	usedCapacity: “float - total combined weight of all docked spaceships”,
	docks: [{
		id: “string - id of the dock”,
		numDockingPorts: “Integer - total number of available ports”
		occupied: “Integer - number of docked spaceships on this docking station”,
		weight: “float - combined weight of all docked spaceships on this docking station”
	}],
}]

Only users with role Command and Ship may access this Api. Any other role should result in 400: Bad Request.

If the requesting user's role is Ship, the response should only include shipping stations with at least one free docking port and with enough room to be able to accept the requesting ship - i.e., stations capacity - usedCapacity >= ships weight.

POST /centcom/ship/register

Header

Authorization: Bearer {JWT Token}

Body

{
	weight: "Float",
}

This Api should be called only once by each newly created ship. A second call by the same ship should return 400: Bad Request. A valid call should return 200 with an empty body.

Only users with role Ship may call this Api, any other role should result in 400: Bad Request.

GET /centcom/ship/all

Header

Authorization: Bearer {JWT Token}

Sample Response:

[{
	id: string,
	status: 'docked' | 'in-flight',
	weight: 'Float - weight of the spaceship'
}]

the role Command is required to call this Api.

Shipping Station Service

Spaceships need to communicate with this Api to land on the shipping station.

APIs

POST /shipping-station/request-landing

Header

Authorization: Bearer {JWT Token}

Body

	time: 'Integer - duration which the spaceship wishes to stay at the shipping station',

Only users with role Ship may use this Api. The response should be

{
	command: 'land',
	dockingStation: 'string - id of the docking station',
}

If the required conditions for landing are satisfied - there's at least one available docking station with an empty port and the stations capacity - usedCapacity <= ships weight. If the conditions aren't satisfied the response should be

{
	command: "wait",
	duration: "Integer - duration ship must wait before it can land on this station",
}

POST /shipping-station/land

Header

Authorization: Bearer {JWT Token}

Body

{
	time: "Integer - duration which the spaceship wishes to stay at the shipping station",
}

A ship may use this Api to land on a shipping station. If the request in invalid (See the previous Api) the response should be 400: Bad request. Otherwise the response should be 200: Ok. If this request time is T, at T + time, the port at which this ship landed will be considered empty again.

Grading

The submission will be graded based on the following criteria

  • Docker scripts to containerize the microservice application: 200 points
  • Database service design: 300 points
  • Proper use of HTTP and Protobuf (gRPC) as the transport mechanisms: 200 points
  • Authorization Service: 100 points
  • Shipping Station Service: 200 points
  • Central Command Service: 400 points
  • Code quality & docs: 100 points

Submission Deliverables

Submit a zip which should include your entire solution - docker scripts & codebase and a deployment guide.

ELIGIBLE EVENTS:

2022 Topcoder(R) Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30203818