The Questions application

In this next assignment you will be building a web application that talks to a back end server that I have set up.

The application you will be building implements a question and answer site. On this site users can post questions on a wide variety of topics and other users can provide answers for those questions.

The base URL for the back end application is

https://cmsc106.net/questions

once again I have set up the back end application with a documentation page, which is available at

https://cmsc106.net/questions/swagger-ui/index.html

What your application should do

There are two main activities that your application will support: allowing users to read questions and answers that other users have posted, and allowing users to post new questions and answers to existing questions. Users will need to be logged in to post questions or answers, but they do not need to log in to browse questions and read answers.

Since I anticipate that users will eventually use this site to ask questions on a wide variety of topics I am going to institute a special rule that will prevent users from being overwhelmed by a large volume of questions. When a user posts a question they will have to tag that question with one or more tags. The purpose of these tags is to assign questions to different topics. When a user comes to the site to look up questions they will start by picking the topic they are interested in. They can then download a list of only those questions that have been tagged with that particular topic. This arrangement will allow the site to handle a very large number of questions spread across many different topics.

Getting information from the server

When a user arrives at the site the first thing your application should offer them is the ability to browse questions. To do this, your application should start by sending a request to

/tags

to fetch a list of all of the topic tags that are currently available. You should display those tags in a select element and allow the user to pick the topic they are interested in. After selecting a topic the user will click a View button. That will cause your application to send a GET request to

/questions?tag=<selected tag>

to fetch the list of questions that have been tagged with <selected tag>.

Each question in the system will consist of a question, some additional details, the name of the user who posted the question, and a list of answers. To fetch more details for a particular question send a GET request to

/questions/<question id>

where <question id> gets replaced with the id of the question the user wants to see. To fetch the answers that have been posted for a particular question, send a GET request to

/answers?questionId=<question id>

We will also want to allow users to post replies to answers that other users have given. When you download the answers for a particular question, some of those answers may include replies that are connected to the answers. When you display the answers to the user the replies should appear along with the answers. If a particular answer has replies, they should appear right below that answer in the list of answers.

Posting information to the server

None of the interactions listed above will require users to be logged in. Users will need to log in if they want to post a new question, answer a question, or reply to an existing answer.

To create a new account and log a user into that account you will post an appropriate object to

/users

To log in to an existing account you will instead post that object to

/users/login

In both cases the system will respond by sending you back the user id for that user. Your application will need that user id to post questions, answers, or replies.

To post a question you will POST an appropriate object to

/questions

Note that when you post a question one of the required fields in the object you post is the tags field, which should contain an array of tags the user wants to assign to their question. Users will need to provide at least one tag for each question, and you also need to allow users to attach multiple tags to a question.

To post an answer you will POST an appropriate object to

/answers

To post a reply to an answer you POST an appropriate object to

/replies

Please refer to the official documention at

https://cmsc106.net/questions/swagger-ui/index.html

to see the full details of what properties the objects you post in each of these cases will need to have.

Final words

One design challenge you will have in setting up your site is that users should be able to perform a wide range of actions without having to log in. However, once a user wants to post some information to the site they will have to log in. I will allow you to exercise your own judgement in exactly how to handle this.

Also, note that I have not equipped the back end server with any way to delete things. That means that during testing you will need to exercise some caution to make sure that you don't post embarrassing or offensive material to the server.

Also, bear in mind that you will be using the back end server along with everyone else in the class. You can use the system of tags to help keep your questions distinct from everyone else's - when you post questions during testing try to assign tags to them that are unique to you so you can keep your questions separate from everyone else's.

Finally, for this assignment I strongly encourage you to use the AI tools that I introduced in the previous lecture. When using those tools you will probably find that the best approach is to build up your application one feature at a time. If you try to get the AI to write the application with one giant prompt you probably won't get as good a result.

Due date

This assignment is due by 5 PM on Monday, Oct. 26.