Skip to content

HR-ATX58-Team-Hyena/sdc-questions-and-answers

Repository files navigation

System Design Capstone

Questions and Answers API Service


Table of Contents
  1. Contributor
  2. Project Overview
  3. API Endpoints
  4. Acknowledgements

Contributor

Cory Ellerbroek - [email protected]

Cory Ellerbroek

linkedin-shield

github-shield


Project Overview

I was tasked to develop a RESTful API service for a mock online clothing store's "Questions and Answers" section. I was provided three csv files with millions of data points for consideration. The tech stack was completely up to me to decide and the biggest decision I had to make was which DBMS to use. I chose the PostgreSQL relational database because it would provide an ideal data structure for the imported data and I knew the queries could be tuned to respond quickly.

I encountered a challenge while importing the data into the database due to a 13 digit Unix timestamp, which Postgres did not natively accept. I solved this by transforming the Unix timestamp into a Postgres readable timestamp during the ETL process.

Server-side caching was implemented with Redis and brought the average response time from 50-80 ms down to 5-15 ms per request.

Once the server and database were fully functioning with the front end client, I deployed the server and database on separate AWS EC2 instances. Extensive integration, unit, and stress testing was developed locally and performed after deploying to ensure optimal functioning. The single server could handle over 1000 requests per second without error, but the response time began to significantly increase between 700 and 800 requests per second. This is where my time on this projected ended, but my next step would have been to implement multiple server instances and a load balancer.



Tech Stack

HTTP Server

Database Management System

Testing & Monitoring



API Endpoints

List Questions

GET Endpoint: /qa/:product_id

Retrieves a list of questions for a particular product. This list does not include any reported questions.


Parameters

Parameters Type Description
product_id integer Specifies the product for which to retrieve questions.

Query Parameters

Parameters Type Description
page integer Selects the page of results to return. Default 1.
count integer Specifies how many results per page to return. Default 5.

Response Status: 200 OK


Answers List

Returns answers for a given question. This list does not include any reported answers.

GET Endpoint: /qa/questions/:question_id/answers


Parameters

Parameters Type Description
question_id integer Required ID of the question for which answers are needed.

Query Parameters

Parameters Type Description
page integer Selects the page of results to return. Default 1.
count integer Specifies how many results per page to return. Default 5.

Response Status: 200 OK


Add a Question

Adds a question for the given product.

POST Endpoint: /qa


Body Parameters

Parameters Type Description
body text Text of question being asked.
name text Username for question asker.
email text Email address for question asker.
product_id integer Required ID of the Product for which the question is posted.

Response Status: 201 CREATED


Add an Answer

Adds an answer for the given question.

POST Endpoint: /qa/:question_id/answers


Parameters

Parameters Type Description
question_id integer Required ID of the question being answered.

Body Parameters

Parameters Type Description
body text Text of answer.
name text Username for answerer.
email text Email address for answerer.
photos [text] An array of urls corresponding to images to display.

Response Status: 201 CREATED


Mark Question as Helpful

Updates a question to show it was found helpful.

PUT Endpoint: /qa/questions/:question_id/helpful


Parameters

Parameters Type Description
question_id integer Required ID of the question to update.

Response Status: 204 NO CONTENT


Report Question

Updates a question to show it was reported. Note, this action does not delete the question, but the question will not be returned in the above GET request.

PUT Endpoint: /qa/questions/:question_id/report


Parameters

Parameters Type Description
question_id integer Required ID of the question to update.

Response Status: 204 NO CONTENT


Mark Answer as Helpful

Updates an answer to show it was found helpful.

PUT Endpoint: /qa/answers/:answer_id/helpful


Parameters

Parameters Type Description
answer_id integer Required ID of the answer to update.

Response Status: 204 NO CONTENT


Report Answer

Updates an answer to show it has been reported. Note, this action does not delete the answer, but the answer will not be returned in the above GET request.

PUT Endpoint: /qa/answers/:answer_id/report


Parameters

Parameters Type Description
answer_id integer Required ID of the answer to update.

Response Status: 204 NO CONTENT



Acknowledgements

About

Questions and Answers service for Project Catwalk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published