- Scope [ Backend structure ]
- The architecture is designed to fulfill the needs of this UX/UI Prototype.
- 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 onscript/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
- 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).
- Get all filters
- return all values used for filters based on created products.
- Get one phone
- return all the information about a selected phone.
- 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.
- Delete one phone
- delete a phone base in its id.
- delete the related assets stored on
cloudinary
.
Application
- API:
node
,express
- web scrap:
puppeteer
Image management services
- cloud image storage:
multer
,cloudinary
.
Persistence layer
- DB:
PostgreSQL
viaSlonik
( on top ofpg
)
Testing
- API e2e:
jest
andsupertest
Shipping
docker
: database
- Environment setup requirements
Make sure you have installed:
- API:
node
>= 14.17.0
- containers:
docker
>= 1.29.2
- 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
- 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
- Database schema and relations
- to web scrap a provider website, and create and populate the databases.
- stores the retrieved data within the
tmp
folder.
- to visualize the chromium browser.
- retrieving a samll portion of all the available data.
- store the retrieved data within the
script/json
folder.
- Execute all available tests (
/src/test
)
- run the API.
- ⛔️ See here the API documentation and sample output.