Project #3

Pet Rescue Federation

For Milestone due dates see schedule below.

See Addendum for updates.

Continuation: A Pet Rescue site.

This is a Paired Programming Project. It is the final in a three part semester project working toward a class federation of pet rescue websites. New Teams will be assigned through Canvas by Tuesday 4/18. You'll build upon what you developed for Project 1 & 2. As mentioned in prior Projects, both of the team partners first need to review, discuss and agree upon what parts of their Project could be carried forward to this phase. In Project 3, you will be enhancing the functionality of your Pet Rescue website. The objective of this project is to have the class as whole create a federation of Rescue sites. Each site will share the information about it's list of pets with others on request. Most of this new functionality will be developed in JavaScript and utilizing JSON and jQuery.

Master List API

CT310 account will provide a master list of all sites in the Federation in JSON (Array) format. Three attributes form a JSON object - site name, site awake URL and site AJAX endpoint URL for pets list. The master list URL is accessible at https://www.cs.colostate.edu/~ct310/yr2016sp/more_assignments/project03masterlist.php. The json response would be in the following format.
[{"siteName":"My Pets",
"awakeURL":"https://www.cs.colostate.edu/~dasriniv/areyouawake.php",
"petsListURL":"https://www.cs.colostate.edu/~dasriniv/petslist.php"}].

Status page

Create a new page called status.php that displays the federation sites information obtained from the master list. You'd trigger an AJAX call to the master list everytime a user visits this page. You could display this data in the form of a table.

You'd need also to show the actual status (Red or yellow or Green) of each of those sites in another column of the table depending on whther the site is up for responding or not. You should perform an AJAX call to each one of those awakeURLs, which return a JSON object indicating the site awake status. The json response would be in the following format.
{"status":"up / down"}. If you get an error response - show a Red status, down response - show a Yellow status and up response - Green status.

Modification to Pets Listing page

This page will be a growing list of pets. Along with the list of pets retrieved from your AJAX API call, you'll need to obtain the list from every other site in the master list. You could obtain the master list in this page as well or have the master list information globally be accessed across the site (when you obtain in the Status page). You'll perform an AJAX call to ecah one of them to retrieve list of pets and add to your list. You should consider refreshing this list to update UI every 3 seconds, but not each and every time a site gets data back to you. You'd display all the information retrieved except the description and image. The json response would be in the following format.
[{"petName":"nameOfThePet",
"petKind":"kindOfThePet",
"breed":"breedOfThePet",
"datePosted":"mm/dd/yyyy",
imageURL:"https://www.cs.colostate.edu/~dasriniv/getImage.php?petId=uniqueIdOfThePet",
petId:"uniqueIdOfThePet",
descURL:"https://www.cs.colostate.edu/~dasriniv/getDesc.php?petId=uniqueIdOfThePet"}].

Modification to Pet details page

In this page, you'd display all the information of a pet that you displayed on the list page, alongwith description and image of the pet. An AJAX call to imageURL should return the base 64 encoded string of the content of the pet, which you'll do only once the user enters the pet detail page. Size of the images should be 320x240. See addendum for assignment 7 getRandomImage.php's code to send image content as response to an AJAX call and you should make use of that here. An AJAX call to getDescriptionURL should return a JSON response of the description of the pet in the folloing format. {"description":"Description of pet with id=uniqueIdOfThePet"}.

From standpoint of supporting the APIs for these features, each site must: respond to ‘are you awake’, respond to ‘list available pets’, respond to ‘stream me an image of a pet id foo’

API guidelines

  • You must follow the JSON APIs response structure as defined above
  • Failing to adhere to the format makes your data inconsumable by others and would attract deductions in scores
  • Please add header('Content-Type: text/json'); as the first line in the php tags of pages that you're responding. This makes sure that the returned object is in text/json format instead of text/html format.
  • Some teams may implemente the JSON response pages to return just a json object. Some other teams may return an array with one json object as an element. You should handle both cases. This can be done by using is_array( ) method of php after you decode the json object to check whether the returned json object is an array.
  • Please adhere to the timelines as mentioned below as others are dependent on your data

Schedule

Because Project 3 has teams utilizing functionality being implemented by other teams a staggered set of deadlines/milestones is being established. These are summarized next.

The following schedule will drive the project and constrains when teams need to be ready to share information with the larger development community.

April 27th
Groups submit siteName, awakeURL and petsListURL to be registered in the federation. The link to awakeURL and petsListURL should return JSON responses as defined above with actual data. Please test it by consuming the data on your site as to check the functionality before emailing this to GTA by close of Wednesday.
May 2nd
Dry run testing of federation sites working together. Initial review by the GTA.
May 6th
Code development freezes. The Projects are due and will be graded. Grading will be through live sites, although project teams will be asked to submit tar files of their site code as well. Please host it on your CS account and provide the URL to your website as a comment during the submission.

The GTA will maintain a URL as part of the CT310 Website that will deliver the master list. This will play a critical role in the functioning of all sites because it will define the Federation of sites at any moment in time. Keep an eye on the Addendum for timely updates.

Project Teams

As with the previous projects, project teams are assigned at random. Every effort will be made to avoid pair students who have not previously worked together on a project.

Addendum (last updated 4/26/2016, Darshan)

To clarify, the services such as awakeURL, petsListURL, getImage, getDescription will not be shown as a page on your website. They just reside in your website folder and return the response if someone makes an AJAX call to it.

Here's the Source code for streaming the image to the clients that access the image URLs that you host (It is the same URL that you send as part of pet list JSON response). You should make use of this code so that everybody gets the image response in a single format. You'll use your assignment 7 code to download the image and show it in your pet details page.


Here are excerpts of responses for the email queries from the class

Search Functionality: It is not part of the grading for Project 3. However, it’s good have the site working with all accumulated functionality. You could use the array where you store all the pets from the federation of sites, to search and filter.

Comments: You should allow the users to comment on the pets if logged in. However, you don’t need to store the comments, as the pets you downloaded may have redundant ids and it’ll be hard to reproduce the comments when pets are downloaded the next time.

Grading:

Please, and this is important, in the comments field on Canvas give us atleast one existing account's username and password.

The following are the guidelines that will be observed when grading this project.

Submit site name and URLs that actually respond with data to requests, by April 27th 20 Points
We will grade the remaining API calls generating detailed pet specific informatio on May 2nd 20 Points
Display all the sites in the Federation on Status page with correct statuses 20 Points
Perform AJAX calls to all other sites for pets list and error cases handled 20 Points
Update the user interface every threee seconds until data obtained from all other sites 20 Points