The company stakeholders want to create an online storefront to showcase their great product ideas. Users need to be able to browse an index of all products, see the specifics of a single product, and add products to an order that they can view in a cart page. You have been tasked with building the API that will support this application, and your coworker is building the frontend.
These are the notes from a meeting with the frontend developer that describe what endpoints the API needs to supply, as well as data shapes the frontend and backend have agreed meet the requirements of the application.
- Index '/products' [GET]
- Show '/products/:id' [GET]
- Create [token required] '/products' [POST]
- Products by category (args: product category) '/products/category/:category' [GET]
- Delete product (args: product id) '/products/:id' [DELETE]
- Index [token required] '/users' [GET]
- Show [token required] '/users/:id' [GET]
- Create N[token required] '/users' [POST]
- Delete User '/users/:id' [DELETE]
- Current Order by user (args: user id)[token required] 'orders/latest/:user_id' [GET]
- Create New Order (args: user id) '/orders' [POST]
- Delete order (args: order id) '/orders/:id' [DELETE]
- id
- name
- price
- category
TABLE dental_products ( id SERIAL PRIMARY KEY, name VARCHAR(200), price integer, category VARCHAR(200) )
- id
- firstName
- lastName
- password
TABLE users ( id SERIAL PRIMARY KEY, firstname VARCHAR(150), lastname VARCHAR(200), password VARCHAR(100) )
- id
- id of each product in the order
- quantity of each product in the order
- user_id
- status of order (active or complete)
TABLE orders ( id SERIAL PRIMARY KEY, user_id integer foreign key to users table, status VARCHAR(10) )
TABLE product_order ( id SERIAL PRIMARY KEY, quantity integer NOT NULL, order_id integer foreign key to orders table, product_id integer foreign key to dental_products table )