- Background & Motivation
- The Task
- Getting Started
- Constraints & Assumptions
- Marking Criteria
- Originality of Work
- Submission
- Late Submission Policy
13/03/2023 - Updated the description of the '/job/feed' endpoint in Swagger docs from 'all jobs' -> 'next 5 jobs'.
Web-based applications are becoming the most common way to build a digital capability accessible to a mass audience. While there are modern tools that help us build these rapidly, it's important to understand the fundamental JavaScript-based technology and architectures that exist, both to gain a deeper understanding for when these skills may be needed, but also to simply understand the mechanics of fundamental JS. Even when working with a high level framework like ReactJS, understanding (in-concept) the code that it is transpiled to will ensure you're a more well rounded web-based engineer.
This assignment consists of building a frontend website in Vanilla JS (no ReactJS or other frameworks). This frontend will interact with a RESTful API HTTP backend that is built in JavaScript (NodeJS express server) and provided to you.
A theoretical background on how to interface with this API can be found the "promises & fetch" lecture.
The web-based application you build is required to be a single page app (SPA). Single page apps give websites an "app-like feeling", and are characterised by their use of a single full load of an initial HTML page, and then using AJAX/fetch to dynamically manipulate the DOM without ever requiring a full page reload. In this way, SPAs are generated, rendered, and updated using JavaScript. Because SPAs don’t require a user to navigate away from a page to do anything, they retain a degree of user and application state. In short, this means you will only ever have index.html as your HTML page, and that any sense of "moving between pages" will just be modifications of the DOM.
Your task is to build a frontend for a UNSW rip-off version of the popular professional social networking tool LinkedIn. If you haven't used this application before, we would recommend creating your own LinkedIn profile - it's probably good for your career anyway!
UNSW's rip-off of LinkedIn is called "LurkForWork". However, you don't have to build the entire application. You only have to build the frontend. The backend is already built for you as an express server built in NodeJS (see section 3.2).
Instead of providing visuals of what the frontend (your task) should look like, we instead are providing you with a number of clear and short requirements about expected features and behaviours.
The requirements describe a series of screens. Screens can be popups/modals, or entire pages. The use of that language is so that you can choose how you want it to be displayed. A screen is essentially a certain state of your web-based application.
This focuses on the basic user interface to register and log in to the site.
- When the user isn't logged in, the site shall present a login form that contains:
- an email field (text)
- a password field (password)
- submit button to login
- When the submit button is pressed, the form data should be sent to
POST /auth/loginto verify the credentials. If there is an error during login an appropriate error should appear on the screen.
- When the user isn't logged in, the login form shall provide a link/button that opens the register form. The register form will contain:
- an email field (text)
- a name field (text)
- a password field (password)
- a confirm password field (password) - not passed to the backend, but an error should be thrown on submit if it doesn't match the other password
- submit button to register
- When the submit button is pressed, if the two passwords don't match the user should receive an error popup. If they do match, the form data should be sent to
POST /auth/registerto verify the credentials. If there is an error during registration an appropriate error should appear on the screen.
- Whenever the frontend or backend produces an error, there shall be an error popup on the screen with a message (either a message derived from the backend error response, or one meaningfully created on the frontend).
- This popup can be closed/removed/deleted by pressing an "x" or "close" button.
Milestone 2 focuses on fetching feed data from the API. A feed and it's associated content should only be accessible to logged in users.
The application should present a "feed" of user content on the home page derived GET /job/feed. Note that the feed will only return information from people that the logged in user is watching.
The jobs should be displayed in reverse chronological order (most recent jobs first).
Each job should display:
- Who the job post was made by
- When it was posted
- If the job was posted today (in the last 24 hours), it should display how many hours and minutes ago it was posted
- If the job was posted more than 24 hours ago, it should just display the date DD/MM/YYYY that it was posted
- The job content itself. The job content includes the following:
- An image to describe the job (jpg in base64 format)
- A title for the new job (just as a string)
- A starting date for the job (just as a string)
- How many likes it has (or none)
- The job description text
- How many comments the job post has
Milestone 3 focuses on a richer UX and will require some backend interaction.
- Allow a user to see a list of all users who have liked a job. In terms of how it is displayed, consider your preferred user experience approach out of the following 3 options:
- The list of names is visible on each job in the feed by default
- The list of names is visible on a job in the feed if a show/hide toggle is clicked (hidden by default).
- The list of names is visible in a popup, modal, or new screen, when a button/link is clicked on the feed.
- Allow a user to see a list of all the comments on the job. Each comment should contain at minimum the user's name and their comment. In terms of how it is displayed, consider your preferred user experience approach out of the following 3 options:
- The list of names and comments are visible on each job in the feed by default
- The list of names and comments are visible on a job in the feed if a show/hide toggle is clicked (hidden by default).
- The list of names and comments are visible in a popup, modal, or new screen, when a button/link is clicked on the feed.
- A user can like a job on their feed and trigger a api request (
PUT /job/like) - For this milestone, it's OK if the like doesn't appear/update until the page is refreshed.
- Users can page between sets of results in the feed using the position token with (
GET /job/feed). - Note: You will automatically receive marks for this section if you end up implementing the infinite scroll alternative in a later milestone.
Milestone 4 focuses predominately on user profiles and how users interact with them.
- Let a user click on a user's name from a job, like, or comment, and be taken to a profile screen for that user.
- The profile screen should contain any information the backend provides for that particular user ID via (
GET /user). - The profile should also display all jobs made by that person. You are not required to show likes and/or comments for each job here.
- The profile should also display somewhere all other users this profile is watched by (information via
GET /user). This should consist of a list of names (which for each name links to another profile), as well as a count somewhere on the page that shows the total number of users they are watched by.
- Users can view their own profile as if they would any other user's profile
- A link to the users profile (via text or small icon) should be visible somewhere common on most screens (at the very least on the feed screen) when logged in.
- Users can update their own personal profile via (
PUT /user). This allows them to update their:- Email address
- Password
- Name
- Image
- Watching on user profiles:
- When a logged in user is visiting another user's profile page, a button should exist that allows them to "watch" the other user (via
PUT user/watch). - If the logged in user already watches this person, an unwatch button should exist.
- When a logged in user is visiting another user's profile page, a button should exist that allows them to "watch" the other user (via
- Somewhere on the feed screen a button should also exist that prompts the enter to enter an email address in a popup. When entered, the email address is sent to
PUT /user/watchto watch that particular user.
Milestone 5 focuses on addition and removing both content and comments.
- Users can upload and job new content from a modal, component, or seperate screen via (
POST /job) - How users open this component, modal, or separate screen can be found in a single or multiple places, and should be easily and clearly accessible.
- Let a user update a job they made or delete it via (
DELETE /job) or (PUT /job).
- Users can write comments on "jobs" via (
POST /job/comment)
- Instead of pagination, users an infinitely scroll through results. For infinite scroll to be properly implemented you need to progressively load jobs as you scroll.
- If a user likes a job or comments on a job, the job's likes and comments should update without requiring a page reload/refresh. This should be done with some kind of polling.
Polling is very inefficient for browsers, but can often be used as it simplifies the technical needs on the server.
- Users can receive push notifications when a user they watch posts a job. To know whether someone or not has posted a job, you must "poll" the server (i.e. intermittent requests, maybe every second, that check the state). You can implement this either via browser's built in notification APIs or through your own custom built notifications/popups. The notifications are not required to exist outside of the webpage.
No course assistance in lectures will be provided for this component, you should do your own research as to how to implement this. There are extensive resources online.
- Users can access the most recent feed they've loaded even without an internet connection.
- Cache information from the latest feed in local storage in case of outages.
- When the user tries to interact with the website at all in offline mode (e.g. comment, like) they should receive errors
No course assistance will be provided for this component, you should do your own research as to how to implement this.
Users can access different pages using URL fragments:
/#profile=1
/#feed
/#profile=4
No course assistance in lectures or on the forum will be provided for this component, you should do your own research as to how to implement this.
An extra 5% of the assignment can be attained via bonus marks, meaning a maximum mark of 105/100. Any bonus marks that extend your ass2 mark above 100% will bleed into other assignment marks, but cannot contribute outside of the 75% of the course that is allocated for assignment marks
Your bonus feature(s) can be anything. You just have to think of something that could make your web app stand out in some minor or major way. Simple examples would include just making sure that your user interface and user experience stands out amongst other students, maybe through some user testing.
You could also add extra features, such as some additional frontend form validations - the possibilities are limitless.
If you do implement a bonus feature, describe the feature and its details in bonus.md in the root directory of this repository.
Stub code has been provided to help you get started in:
frontend/index.htmlfrontend/styles/global.cssfrontend/src/helpers.jsfrontend/src/main.js
You can modify or delete this stub code if you choose. It's simply here to potentially provide some help.
To work with your frontend code locally with the web server, you may have to run another web server to serve the frontend's static files.
To do this, run the following command once on your machine:
$ npm install --global http-server
Then whenever you want to start your server, run the following in your project's root folder:
$ npx http-server frontend -c 1 -p [port]
Where [port] is the port you want to run the server on (e.g. 8080). Any number is fine.
This will start up a second HTTP server where if you navigate to http://localhost:8000 (or whatever URL/port it provides) it will run your index.html without any CORs issues.
You are prohibited from modifying the backend. No work needs to be done on the backend. It's provided to you simply to power your frontend.
The backend server exists in your individual repository. After you clone this repo, you must run yarn install in backend directory once.
To run the backend server, simply run yarn start in the backend directory. This will start the backend.
To view the API interface for the backend you can navigate to the base URL of the backend (e.g. http://lukforwork.onrender.com). This will list all of the HTTP routes that you can interact with.
We have provided you with a very basic starting database containing two users and one public channel with messages. You can look in backend/database.json to see the contents.
Your backend is persistent in terms of data storage. That means the data will remain even after your express server process stops running. If you want to reset the data in the backend to the original starting state, you can run yarn reset in the backend directory. If you want to make a copy of the backend data (e.g. for a backup) then simply copy database.json. If you want to start with an empty database, you can run yarn clear in the backend directory.
Once the backend has started, you can view the API documentation by navigating to http://localhost:[port] in a web browser.
The port that the backend runs on (and that the frontend can use) is specified in frontend/src/config.js. You can change the port in this file. This file exists so that your frontend knows what port to use when talking to the backend.
Please note: If you manually update database.json you will need to restart your server.
Please note: You CANNOT modify the backend source code for bonus marks.
This is how we recommend you start the assignment:
- Read the entire spec, including a thorough read of section 2 so you know what is ahead of you!
- Try to load up the
index.htmlon your browser with a simple "Hello world" text just to sanity check you know what page you're trying to load. - Plan out your UI by thinking about all of the key screens and what information they rely on
- Try to load up the backend and verify you've got it working by making a simple API call to
/feed(which should return you an empty list) - Good luck!
- You must implement this assignment in ES6-compliant Vanilla JavaScript. You cannot use ReactJS, JQuery, or other abstract frameworks. You can not, for example, use a popular Javascript framework such as Angular or React.
- You may NOT directly use external JavaScript. Do not use NPM except to install any other development libraries without prior approval from course authority.
- You may use small amounts (< 10 lines) of general purpose code (not specific to the assignment) obtained from a site such as Stack Overflow or other publically available resources. You should clearly attribute the source of this code in a comment with it. You can not otherwise use code written by another person.
- You may include external CSS libraries in this assignment (with the
<link />tag). You must attribute these sources (i.e. provide the URL/author in source code comments). For example, you are permitted to use the popular Bootstrap CSS framework. Some Bootstrap functionality relies on accompanying Javascript. You are permitted to include this Javascript. The Javascript accompanying Bootstrap requires the popular general purpose Javascrpt library jQuery. You are permitted to include jQuery so bootstrap can use it. However you are not permitted to use jQuery in the code you write for the assignment.
You should ensure that your programs have been tested on one of the following two browsers:
- Locally, Google Chrome (various operating systems)
- On CSE machines, Chromium
- The specification is intentionally vague to allow you to build frontend components however you think are visually appropriate. Their size, positioning, colour, layout, is in virtually all cases completely up to you. We require some basic criteria, but it's mainly dictating elements and behaviour.
- This is not a design assignment. You are expected to show common sense and critical thinking when it comes to basic user experience and visual layout, but you are not required to be creative to achieve full marks.
- Your web app must be a single page app. This means that there is only one initial browser load of content on one html page, and all subsequent dynamic changes to the page are based on Javascript DOM manipulation. If you do not build a single page app (e.g. using links to multiple HTML pages), you will receive a 50% penalty of your mark.
In this assignment, you are:
- Allowed to add static HTML/CSS to the stub website provided (i.e. you can put raw HTML/CSS as if it's a static page, even if you then later manipulate it with JavaScript).
- Allowed to build HTML elements and add CSS properties to the DOM via JavaScript. We expect this to be the most common way students build these pages.
- Are strictly not allowed to use the
innerHTMLproperty of nodes/tags to set the inner HTML of an element. This has security vulnerabilities and is in general not best practice. Either statically add the HTML/CSS and manipulate it with JavaScript, or generate and build nodes/elements in JavaScript (just like in lectures/tutes/labs), or both. But don't set inner HTML. The use of anyinnerHTMLwill result in a 50% penalty of your mark.
You are strictly not allowed to use the async and await syntax in this assignment. You must use ES6 Promises. The use of any async or await will result in a 50% penalty of your mark.