Image Infection - Week #1: Middleware and Registartion Implementation

Due Date: Completed and turned in via git before November 29, 2023 at 11:59pm
Points: Week 1 is worth 40 points


The final project in CS 340 is all about creating something as a course, together, that all of our work contributes to the final deliverable and runs simultaneously at our final exam meeting time.

This semester, we will be working as a class to generate a single image. There’s just one problem- everyone uploaded their own image at the same time, resulting in a jumbled array of tiles!

To fix this issue, we will go through several rounds of voting to single out one image to be generated. Here is how our image webapp will work:

  • A user will register by uploading an image, while claiming a ClientID and a tile on the class grid.
  • During each voting round, every user will get one vote which they can give to someone other than themselves.
  • After all votes have been cast, the tiles with the most votes out of their neighbors (horizontally and vertically) will “infect” adjacent tiles, causing more of that user’s image to appear on the grid.
  • Users who are voted out, (i.e. their tiles have been completely taken over by a different image), are still eligible to vote for tiles on the board.
  • After enough rounds, one image will emerge victorious, being completely filled in.

There will be two check points for the project before the final presentation as a whole course.

Software Architechture

There are three major components in Image Infection.

  • A shared frontend to run the voting and show the state of the image (early work on this done will develop more later)
  • A user microservice that manages your interests in the Image process
  • A user frontend for you to manage your microservices

During the first week you will develop the portion of your backend that registers your interests with the shared frontend

Initial Files

Merge the initial starting files with the following commands:

git fetch release
git merge release/project-fa23 -m "Merging initial files"

This currently only contains a skeleton of the code. Durring the project updates will be posted with more code in the tile server to help your testing.


The goal of Week 1 is to provide you with as minimal requirements as possible for you to complete core of your microservice. This will include the following requirements.

  • Register your microservice with the shared frontend
  • Register your image with the shared frontend for aproval
  • Watch for approval of your image

Registering your Tile service to the Canvas server via PUT /registerClient/<clientID>

To register a tile to the canvas server, you must inform the canvas server that your tile has launched. This is done via a PUT /registerClient/<clientID> request sent to the canvas server. The clientID should be your netid.

This request must include a JSON with keys 'author', 'url', and 'token'. For example:

  "author": "Your Name",
  "url": "",
  "token": "a5630ec7-165f-4d0a-9f17-7da3cb5fcc50"
  • The url value will be used the URL to communciate with your tile sercice when sending a POST /registerClient request.

  • The author must be your name if you want to get credit for the MP! :)

  • the token should be a unique string that you generate to authorize the canvas service to update you with. You can generate this as you want.

  • The maze server /registerClient/<clientID> endpoint will respond with one of the following HTTP/400 if the JSON is malformed and HTTP/415 if the clientID is already registered.

The server will respond with a JSON on success with the the keys 'xdim', 'ydim', and 'tilesize'. For example:

  "xdim": 10,
  "ydim": 10,
  "tilesize": 5
  • The xdim and ydim are the number of tiles in the x and y dimensions of the canvas

  • The tilesize is the number of pixels in each square tile

This example would be a canvas that was 50 pixels by 50 pixels with 100 total tiles in it. You will need to resize your image to fit the size of the canvas the server specifies. Then you will need to post it to the canvas server for approval.

Registering your image to the Canvas server via POST /registerImage/<clientID>

You will need to post a png image of the size recived from the canvas server for approval. This post will reposnd with HTTP/500 if your image is not the correct dimension and HTTP/416 if you have not registered your clientID.

Once this is compleated your tile service needs to be listening for an aproval on the route PUT /registered .

Reciving your voting rightes from the Canvas server via PUT /registered

On your tile microservice you must handle the approval or rejection of your submitted image. This request will be a JSON with the fields 'authToken', 'approved', 'voteToken', 'xloc',and 'yloc'. For example:

  "authToken": "a5630ec7-165f-4d0a-9f17-7da3cb5fcc50",
  "approved": true,
  "voteToken": "45046605-4ef3-4dfc-84ed-cfafade8a2db",
  "xloc": 0,
  "yloc": 0
  • The authToken must be the token you provided to the canvas server

  • The approved this is true if you are approved and false if your image was rejected

  • The voteToken is a token as a string that you will need to provide to vote

  • The xloc and yloc provide the location on the canvas that is your tile. In this case the upper left hand corner of the canvas.

You will return HTTP/455 “Authorization token invalid” if the token does not match your token otherwise HTTP/200 for success.

IMPORTANT: failing to complete this part of the final project by the deadline will make it very hard to catch up, so we recommend that you start this assignment early!


You will be able to earn 40 points for completing all of this week’s deliverables (there will be no partial credit for this week, this is already partial credit as part of the final project). This week comprises only a portion of the 220 total points for the final project, since this project builds on itself each week. Failure to complete this week will make it more difficult to earn points in future weeks since you will need to complete this work to complete the next week’s work.


Once you have successfully completed this week’s deliverables, you will need to submit your code. Commit using the standard git commands:

git add -A
git commit -m "MP submission"
git push


The 40 points for this week are split in the following way:

Description CS 340 Course Points
Interface with connection to server 40 points