Assignment 2 |
Thinks you will learn In this assignment, you will learn the following: Save your data persistently in MongoDB
Perform DB different operations Push to GitLab Repository Work in teams |
Assignment 2 Theme Due to a large number of events and categories, Monash's IT department started to think of the need to store their data persistently. Two more issues have emerged: the IT department cannot host the application locally on-premise. Instead, it prefers to deploy it to a cloud provider that charges per usage. Secondly, Monash mobile (Android and IOS) and desktop applications have requested access to the EMA data. |
Assignment 2 Specifications ⚙
As mentioned in the Assignment 2 Theme section, this assignment is about:
1. SaveEMAdatapersistentlyinMongoDB.Inotherwords,youmustremovethearrayofobjects you have used in assignment-1 and replace it with MongoDB
2. ServeclientswithJSONdata
3. DeployyourEMAapptoacloudprovider
Assignment 2 Structure
In the figure above, you will notice the following: 1. TheEMAprojectisservingtwotypesofURLs
1. http://fit2095.a2.au/events/543210/list
This is developed in assignment 1, where the server responds with HTML �les
Assignment 2 is due on Friday of Week 8, Septermber 15, at 11:55 pm.
2. http://fit2095.a2.au/api/v1/events/543210/list where 543210 is the student id,
and fit2095.a2.au is the server address
In the second type, the server responds with JSON data. This type of REST API is
designed for other devices, such as mobile phones, TVs, and cars.
There is no direct access to the data. In other words, clients can access the data through the server only.
Teamwork
Produce together the overall app design/development plan
Produce together the team tasks
Agree on who does which set of individual tasks
Check-in regularly with one another
Anything else about how you'd like them to work together [e.g. git commit authorship, branches, notes from meetings, Trello boards, etc.]
Individual work: You should produce the individual tasks yourself but should discuss ideas with your team
Team Tasks
1. Designtheendpointsroutingtable.Inthistable,youmustlistalltheendpointsyourprojectwill listen to, their methods, and their description. It's your task to name the pathnames, endpoints, and query string parameters.
2. Theteamisresponsibleforaddingthefollowingfeaturestotheindex.html�le
-
Twolabelsthatshowthecurrentnumberofeventsandcategories
-
ThreelabelsshowthenumberofAdd,Update,andDeleteoperationsinvokedonthe database.
(HINT: This can be implemented by adding a new collection (table) with three counters that are incremented when their operations are invoked.)
Individual-Work Tasks
Each student in the team must pick one group of individual tasks to implement. However, cooperation between the team members is crucial for all the specs and features to work seamlessly.
Tasks Group 1 (student #1)
You MUST use your Monash ID as a segment in the pathname of all the endpoints of this group of tasks. For example, if your Monash ID is 543210, the endpoint could be
http://localhost:8080/category/543210/add
1. DevelopaMongooseSchemaforCategoryclass
-
Apply 'Required' for mandatory fields
-
Addavalidatortothefield'Name'toacceptalphanumericvaluesonly
-
Thecategoryschemamustcontainafieldnamed'eventsList',whichisanarrayof events' references. It lists all the events in this category. (HINT: You will use it with the function 'populate')
2. AddnewRESTfulAPIendpointsthatareresponsibleforthefollowing:
-
Insertnewcategory.ThedatainaJSONformatmustbesentthroughthebodyofthe HTTP request. An example of the endpoint URL could be http://localhost:8080/api/v1/category/543210/add
{
"name":"Cat3","description":"Desc" }
The endpoint must respond with a JSON object containing the category ID of the newly added category
For example:{
"id": "CTE-4899"}
-
Listallcategories.AnexampleoftheendpointURLcouldbe http://localhost:8080/api/v1/category/543210/list
This endpoint must return the list of all categories and the details for their events in a JSON format (see the populate method)
3. AddnewRESTfulAPIendpointsthatareresponsibleforthefollowing:
1. DeletecategorybyID.ThisendpointdeletesacategorybyitsIDandalltheeventsthatare
listed in the 'eventList' �eld (see point 1.3). NO further delete cascade is required.
The ID must be sent through the body of the request in a JSON object. For example
{
"categoryId": "CCA-4960"
}
The endpoint must return a JSON object containing the number of deleted documents. (Remember to use the correct HTTP method.)
Example of the return object:
{
"acknowledged": true,
"deletedCount": 1
}
-
UpdatecategorynameanddescriptionbyID:TheID,newnameanddescriptionaresentasa JSON object through the request body. For example:
{
"categoryId": "CCA-3001", "name": "new Name", "description": "new description"}
The endpoint must return an object with a message to con�rm the update or if the ID is not found (HINT: check the return of the update statement). For example:
{
"status": "ID not found"}
-
Updatealltheassignment-1endpointstouseretrieve,insert,anddeleteSQLoperationsfrom MongoDB using Mongoose
-
DeployyourprojecttoavirtualmachineonyourGCPaccount.TheUIandtheAPIendpoints must be accessible through your public IP address.
Tasks Group 2 (student #2)
You MUST use your name as a segment in the pathname of all the endpoints of this group of tasks. For example, if your name is David, the endpoint could be
http://localhost:8080/event/david/add.
1. DevelopaMongooseSchemafortheEventclass
-
Apply 'Required' for mandatory �elds
-
addavalidatortothe�eld'Capacity'toacceptnumbersbetween10and2000(inclusive) only
-
Theeventschemamustcontaina�eldnamed'categoryList',whichisanarrayof categories' references. It lists all the categories in this event. (HINT: You will use it with the function 'populate')
2. AddnewRESTfulAPIendpointsthatareresponsibleforthefollowing:
-
Insertnewevent.ThedatainaJSONformatmustbesentthroughthebodyoftheHTTP request. An example of the endpoint URL and its request could be: http://localhost:8080/studentName/api/v1/add-event
{
"name": "Event6",
"description": "Desc ", "startDateTime": "2023-08-01", "durationInMinutes": 100, "capacity": 100,
"categories": "CCA-3001,CCA-7895"}
The ID of the new event must be added to the 'events' array �eld in all the categories under this event.
The endpoint must return an object containing the event ID of the new event. For example:{
"eventId": "EKU-1429"}
-
Listallevents:Thisendpointmustreturnthelistofalleventsandthedetailsfortheir categories in a JSON format (see the populate method)
An example of the endpoint URL could be: http://localhost:8080/studentName/api/v1/events
3. AddnewRESTfulAPIendpointsthatareresponsibleforthefollowing:
1. DeleteeventsbyID.TheIDissentasaJSONobjectthroughthebodyoftherequest.For example:
http://localhost:8080/studentName/api/v1/delete-event
{
"eventId":"EPP-5901"
}
The ID of the deleted event must be removed from the 'eventsList' array in all the categories that are listed in the 'categoryList'. No further delete cascade is required. Example of the return object:
{
"acknowledged": true,
"deletedCount": 1
}
4. UpdateeventnameandcapacitybyID.TheID,newnameandcapacityaresentasaJSON
object through the request body. For example: http://localhost:8080/studentName/api/v1/update-event
{
"eventId":"EKU-1429",
"name":"new event",
"capacity":300
}
The endpoint must return an object with a message to con�rm the update or if the ID is not found (HINT: check the return of the update statement). For example:
{
"status": "updated successfully"
}
-
Updatealltheassignment-1endpointstouseretrieve,insert,anddeleteSQLoperationsfrom MongoDB using Mongoose. Don't forget, events now can be under multiple categories, not one. You can input the IDs of the categories separate by a comma ','.
-
DeployyourprojecttoavirtualmachineonyourGCPaccount.TheUIandtheAPIendpoints must be accessible through your public IP address.
Source Code Quality
Two standards will be used to de�ne and measure the quality of your source code.
-
SourceCodedocumentation.YoumustusetheJSDoclibrarytodocumentyoursourcecodefor this assignment. (See Assignment Control Panel-->Code Documentation and lab week 4 for help.)
You are required to provide documentation for your:1. classes
2. globalvariablesandconstants 3. methods -
NamingConvention.Thenamesofyour�les,classes,packages,modules,methodsand variables must be descriptive and follow the Google naming style. ( See Assignment Control Panel-->Code Style for more help.)
Marking Rubric No marks will be given to any point you could not explain during the interview Summary Rubric Breakdown |
What to submit?
Where?
Every student must submit assignment-2 to two places: Moodle and Gitlab.
For Moodle, you must ZIP your �les into a single �le and upload it to the assignment-2 submission link that can be found on Moodle-->Assessment. There is a quick survey you must do to enable the submission link.
For GitLab, you will be provided with a group repository, and you should commit/push your project to it. We are expecting at least three non-trivial commits to your group repo. See the marking rubric for more details.
What??
1. AdocumentinPDF,DOCX,orMDformatthatcontains:
1. TheroutingtablethatisrequestedintheAssignment-1speci�cation
2. Stepstorunyourapplications
3. [Optional]unsolvedbugsandissues
4. thisdocumentmustbeplacedintherootfolderofyourproject
2. Thesourcecodeoftheproject
We will mark your assignment based on the latest commit in the main branch in your GitLab repository by the due date, not in the master branch.