Skip to content

TommyTraddles/ob_phonebey_api

Repository files navigation

Phonebey API: Ecommerce Catalog and Product's detail mock API

✅ FEATURES

  1. Scope [ Backend structure ]
  • The architecture is designed to fulfill the needs of this UX/UI Prototype.
  1. Seed / Web scraping
  • store the output JSON at the /tmp directory.
  • sanitizes the web scrap input values
  • use the flag npm run seed -- debug to visualize the web scrap on the action with a smaller sample and store the output on script/json.
  • create one-to-one, one-to-many, and many-to-many tables
  • handle ARRAY [] queries to the DB
  • store the retrieved products and product variations on the database
  • check there are no repeating values stored
  1. Get all phones
  • safely constructs custom queries based on the endpoint's query values.

  • supports:

    • no filters, and without order.
    • no filters, and ordered (either ASC or DESC).
    • one filter (single or arrays), and without order.
    • one filter (single or arrays), and ordered (either ASC or DESC).
    • multiple filters (single or arrays), and without order.
    • multiple filters (single or arrays), and ordered (either ASC or DESC).
  1. Get all filters
  • return all values used for filters based on created products.
  1. Get one phone
  • return all the information about a selected phone.
  1. Add a new phone
  • validate user input.
  • sanitize uploaded file types (jpg, png, jpeg).
  • handle asset storing on the cloud service cloudinary.
  • return product id.
  1. Delete one phone
  • delete a phone base in its id.
  • delete the related assets stored on cloudinary.

👋 STACK

Application

  • API: node, express
  • web scrap: puppeteer

Image management services

  • cloud image storage: multer, cloudinary.

Persistence layer

  • DB: PostgreSQL via Slonik ( on top of pg)

Testing

  • API e2e: jest and supertest

Shipping

  • docker: database

👋 SETUP


  1. Environment setup requirements

Make sure you have installed:

  • API:
    • node >= 14.17.0
  • containers:
    • docker >= 1.29.2

  1. Start the repo
git clone [email protected]:TommyTraddles/ob_phonebey_api.git
cd ob_phonebey_api
npm install
npm run docker:up

Within the main folder, create a .env, and update its info based on the .env-sample variables:

Populate the tables and start the server with:

npm run seed
npm run start

  1. Understanding the scaffold
  |- /public (assets)
  |- /script (seed)
  |- /src
  |   |- /api
  |       |- endpoints, services, and queries.
  |   |- /config
  |       |- database, cloudinary and multer setups.
  |   |- /middlewares
  |       |- error handler and input validator.
  |   |- /test
  |       |- API tests.
  |   |- index.js
  |- .env
  |- package.json
  |- docker-compose.yml

  1. Database schema and relations


👋 SCRIPTS


npm run seed

  • to web scrap a provider website, and create and populate the databases.
  • stores the retrieved data within the tmp folder.

npm run seed -- debug

  • to visualize the chromium browser.
  • retrieving a samll portion of all the available data.
  • store the retrieved data within the script/json folder.

npm run test

  • Execute all available tests (/src/test)


npm run start


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published