Ostaa (Part I)

Assignment 9 for CS 337

This is part one of a two-part assignment for 337. In both parts, you will be working on an online-marketplace app called Ostaa (Finnish for “buy” or “purchase”), along the lines of web applications such as OfferUp and Mercari. In part 1, the main emphasis will be on the server-side; getting the database schema set up, responding to various types of queries, adding new users and items, etc. You also have to write a very simple client (mostly for testing purposes). In part 2, you’ll build a more usable and complex client-side, and perhaps also make a few changes to the server code.

The Database

The ultimate purpose of the Ostaa website will be for users to be able to have an account, log in, and then post, view, and purchase items for sale. You will need to have a database schema set up to store the necessary information the server. A real online marketplace would probably have a more complex database, but for this assignment, you will only need two document types: Item and User. The schema should look like this, though you are welcome to make additions if you’d like:

// Items
{ title: String,
  description: String,
  image: String,
  price: Number,
  stat: String }

// User
{ username: String,
  password: String,
  listings: [...list of item ids...],
  purchases: [...list of item ids...] }

Notice how each user should have a list of listings and purchases. The listings are the ids of the items that this user has listed (posted) to the site for sale. The purchases are the list of the ids of items that this user has purchased.

For the purposes of this assignment, you’ll be required to have this server live via digital ocean, and you should include at least 4 items and at least 2 users populated already.

The Server

The server should support a number of different kind of requests (including static file requests). These request paths are:

When working on these features, it should be fairly easy for you to test out the GET features (you can just type the URLs into the browser). However, it might not be quite as straightforward to test the functionality to add users and items. Thus, you’ll also be required to implement a very simple client, which can be used for adding these…

The Client

You should create a very simple, single-page client for this application. In part 2 of the assignment, you will create a more involved client. For now, the client it just going to be used as a page to test adding new users and new items (for particular users) to the database. You are welcome to get creative with the styling, but simple is acceptable also. See below for an example of adding a user and an item for that user.

client client

File Structure

As you are probably familiar with by now, this is what the apps file structure should look like:

/ostaa
    > server.js
    > live.txt
    /public_html
        > index.html
        > ?.js
        > ?.css

Going Live

As with PA 8, for this project, you are required to get this application set up live on the internet, using digital ocean, as I have shown in the past. You should include a file named live.txt in the same directory as server.js. This file should have just one line in it, representing the address that your web app is running on, so that we can go and test it. You are required to leave it up-and-running for at least 3 (72 hours) days after the assignment due date so that we can check.

Examples

Here are some other examples of various requests / searches using this ostaa api/server.

client client

Other Rules

Make sure that you take a look at the style guide on the class site before turning in your project. You are required to use the express module to handle requests, and the mongoose module for database interactions. You may use jQuery or fetch, XHR for AJAX.

Due Date and Submission

For this assignment, you should creat a zip file of the entire ostaa directory and submit that to gradescope. The project is due by 7pm on March 27th.