Skip to content

Latest commit

 

History

History
102 lines (89 loc) · 4.12 KB

REQUIREMENTS.md

File metadata and controls

102 lines (89 loc) · 4.12 KB

Storefront Backend

API Requirements

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.

API Endpoints

Products

  • Index
  • Show
  • Create [token required]
  • [OPTIONAL] Top 5 most popular products
  • [OPTIONAL] Products by category (args: product category)

Users

  • Index [token required]
  • Show [token required]
  • Create N[token required]

Orders

  • Current Order by user (args: user id)[token required]
  • [OPTIONAL] Completed Orders by user (args: user id)[token required]

Data Shapes

Product

  • id
  • name
  • price
  • [OPTIONAL] category

User

  • id
  • firstName
  • lastName
  • password

Orders

  • id
  • id of each product in the order
  • quantity of each product in the order
  • user_id
  • status of order (active or complete)

order_products

  • id
  • quantity
  • order_id
  • product_id

Users

                                 Table "public.users"

Column | Type | Collation | Nullable | Default
-----------+------------------------+-----------+----------+----------------------------------- firstname | character varying(100) | | | lastname | character varying(100) | | | password | text | | | id | integer | | not null | nextval('users_id_seq'::regclass) Indexes: "users_pkey" PRIMARY KEY, btree (id) Referenced by: TABLE "orders" CONSTRAINT "orders_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id)

Products

                                Table "public.products"

Column | Type | Collation | Nullable | Default
--------+------------------------+-----------+----------+-------------------------------------- id | integer | | not null | nextval('products_id_seq'::regclass) name | character varying(100) | | | price | integer | | not null | Indexes: "products_pkey" PRIMARY KEY, btree (id) Referenced by: TABLE "order_products" CONSTRAINT "order_products_product_id_fkey" FOREIGN KEY (product_id) REFERENCES products(id)

Orders

                                Table "public.orders"

Column | Type | Collation | Nullable | Default
---------+-----------------------+-----------+----------+------------------------------------ id | integer | | not null | nextval('orders_id_seq'::regclass) status | character varying(64) | | | user_id | bigint | | | Indexes: "orders_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: "orders_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) Referenced by: TABLE "order_products" CONSTRAINT "order_products_order_id_fkey" FOREIGN KEY (order_id) REFERENCES orders(id)

Order_products

                         Table "public.order_products"

Column | Type | Collation | Nullable | Default
------------+---------+-----------+----------+-------------------------------------------- id | integer | | not null | nextval('order_products_id_seq'::regclass) quantity | integer | | | order_id | bigint | | | product_id | bigint | | | Indexes: "order_products_pkey" PRIMARY KEY, btree (id) Foreign-key constraints: "order_products_order_id_fkey" FOREIGN KEY (order_id) REFERENCES orders(id) "order_products_product_id_fkey" FOREIGN KEY (product_id) REFERENCES products(id)