{"id":16058819,"url":"https://github.com/andyatkinson/my-retail","last_synced_at":"2026-04-30T10:31:36.365Z","repository":{"id":66952273,"uuid":"121675434","full_name":"andyatkinson/my-retail","owner":"andyatkinson","description":"Ruby on Rails web app","archived":false,"fork":false,"pushed_at":"2018-02-22T17:53:16.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T15:50:48.070Z","etag":null,"topics":["ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andyatkinson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-15T19:54:33.000Z","updated_at":"2019-07-09T15:51:44.000Z","dependencies_parsed_at":"2023-05-15T18:15:24.066Z","dependency_job_id":null,"html_url":"https://github.com/andyatkinson/my-retail","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyatkinson%2Fmy-retail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyatkinson%2Fmy-retail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyatkinson%2Fmy-retail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyatkinson%2Fmy-retail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andyatkinson","download_url":"https://codeload.github.com/andyatkinson/my-retail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305946,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","ruby-on-rails"],"created_at":"2024-10-09T03:40:44.639Z","updated_at":"2026-04-30T10:31:36.326Z","avatar_url":"https://github.com/andyatkinson.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# My Retail\n\n## Installation instructions\n\nNotes: Tested on OS X with Ruby, managed by rbenv. Homebrew installed native dependencies, e.g. readline, postgres (tested with 9.5.4)\n\n`brew install readline`\n\nInstall ruby. Tested with 2.4.1. rbenv used to manage Ruby versions. Install bundler gem, which will manage all other gems installed.\n\n`bundle`\n\nOnce the application gems are installed, running `rake` will run the build, and should be an additional verification point that everything is set up.\n\n\n#### Create databases\n\nThere are a number of ways to do this, one way is from a `psql` prompt, run:\n\n```sql\ncreate database my_retail_dev;\ncreate database my_retail_test;\n```\n\nTo create the database schema:\n\n`rake db:migrate`\n\nTo load data into the database using the Rails seeds functionality:\n\n`rake db:seed`\n\nConfirm data is loaded (example, may change):\n\n```\n# \\c my_retail_dev\nYou are now connected to database \"my_retail_dev\" as user \"andy\".\nandy@[local]:5432 my_retail_dev# select * from products;\n id | external_id | price_details |         created_at         |         updated_at\n----+-------------+---------------+----------------------------+----------------------------\n  1 |    15117729 |               | 2018-02-15 18:19:19.761739 | 2018-02-15 18:19:19.761739\n  2 |    16483589 |               | 2018-02-15 18:19:19.765197 | 2018-02-15 18:19:19.765197\n  3 |    16696652 |               | 2018-02-15 18:19:19.767898 | 2018-02-15 18:19:19.767898\n  4 |    16752456 |               | 2018-02-15 18:19:19.770103 | 2018-02-15 18:19:19.770103\n  5 |    15643793 |               | 2018-02-15 18:19:19.772462 | 2018-02-15 18:19:19.772462\n(5 rows)\n```\n\ne.g.\n\n```sql\n select price_details-\u003e'current_price'-\u003e'value' as value, price_details-\u003e'current_price'-\u003e'currency_code' as currency from products where external_id = 13860428;\n value | currency\n-------+----------\n 13.49 | \"USD\"\n```\n\n## Overview\n\nThe Product resource has an ID and price details, stored as JSON data, using the jsonb column type.\n\n## API Testing\n\n### Fetch product details\n\nUsing Postman or curl, make the following HTTP requests.\n\n`GET http://localhost:5000/products/{id}`\n\ne.g. 15117729\n\n`GET http://localhost:5000/products/13860428`\n\nResponse (e.g.):\n\n```\n{\n    \"id\": 13860428,\n    \"name\": \"The Big Lebowski (Blu-ray)\",\n    \"current_price\": {\n        \"value\": 13.49,\n        \"currency_code\": \"USD\"\n    }\n}\n```\n\n##### Curl request\n\n```\ncurl -X GET http://localhost:5000/products/13860428\n```\n\n### Updating product price\n\nMake a put request to the following URL with the following JSON body as the payload.\n\nSet the body to application/json.\n\nPUT http://localhost:5000/products/13860428\n\n```\n{\n    \"product\": {\n      \"id\": 13860428,\n      value\": 17.50\n    }\n}\n```\n\n#### Curl request\n\n```\ncurl -X PUT \\\n  http://localhost:5000/products/13860428 \\\n  -H 'content-type: application/json' \\\n  -d '{\n    \"product\": {\n    \t\"id\": 13860428,\n    \t\"value\": 17.50\n    }\n}\n'\n```\n\n#### Production Curl Request examples\n\n```\ncurl -X PUT \\\n  https://limitless-oasis-33699.herokuapp.com/products/13860428 \\\n  -H 'content-type: application/json' \\\n  -d '{\n    \"product\": {\n    \t\"id\": 13860428,\n    \t\"value\": 17.29\n    }\n}\n'\n```\n\n\n```\ncurl -X GET https://limitless-oasis-33699.herokuapp.com/products/13860428\n```\n\n422 Response example\n\n```\ncurl -X GET https://limitless-oasis-33699.herokuapp.com/products/123\n```\n\n\n### Running the Application\n\nTo boot up the application on port 5000:\n\n`rails s -p 5000`\n\nOr:\n\n`foreman start`\n\n## Benchmarking\n\nBenchmarking with wrk tool\nhttps://github.com/wg/wrk\n\n```\n$ wrk -t1 -c10 -d10s http://127.0.0.1:5000/products/13860428\nRunning 10s test @ http://127.0.0.1:5000/products/13860428\n  1 threads and 10 connections\n  Thread Stats   Avg      Stdev     Max   +/- Stdev\n    Latency   135.66ms   85.83ms 753.22ms   95.61%\n    Req/Sec    40.25     11.22    50.00     78.26%\n  382 requests in 10.08s, 176.82KB read\nRequests/sec:     37.89\nTransfer/sec:     17.54KB\n```\n\n## External Integrations\n\nHTTP interaction with Redsky service\n\n\n## Additional Performance Improvements (future)\n\n#### Cache the Redsky service calls periodically, TTL of 1 minute\n\nAs requests for product IDs come in, we could cache the response with a key of the product ID, and the value as the JSON string, e.g. in memcached or another key-value store, and then for subsequent requests for the same ID, server the JSON string from the cache store and not make a live HTTP call.\n\nWe could specify a period of time that the cached response is fresh, e.g. 1 minute (the TTL).\n\n#### Optimize JSON serialization\n\nBenchmark various JSON serialization options.\n\n#### Consider a slim API response variant\n\nUsing a parameter, a client could request a reduced set of attributes that represent the object. For example, in a mobile app on a summary screen, a trade-off for a faster summary screen could be fetching fewer attributes for each row, which would take less time to serialize, and produce a smaller JSON payload.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyatkinson%2Fmy-retail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyatkinson%2Fmy-retail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyatkinson%2Fmy-retail/lists"}