Code Monkey home page Code Monkey logo

products-manager's Introduction

Backend Challenge - Products Manager

About

The goal is to develop a scalable system for bulk uploading products via csv files and CRUD operations of those products in the database. The infrastructure of the solution consists of a Restful API made in nodeJS where you can upload files and request CRUD operations. These files are queued and products are added to the Postgres database from worker processes. The queue is a Redis instance and the files are uploaded to some cloud storage service, in this case we use AWS S3. The entire project runs in a local environment using Docker. The Minio container emulates the AWS S3 environment and would also work for Google Cloud Storage. The project's architecture was inspired by Uncle Bob's Clean Architecture concepts. The following diagram represents the suggested deployment on AWS services. The Elastic Container Service is used to automatically scale API containers and Workers as needed.

Technologies/Concepts

  • Docker
  • Redis
  • postgreSQL
  • Typescript
  • NodeJS
  • Express
  • Bull
  • Minio
  • Clean Architecture

Getting Started

  • Rename the .env.example to .env.
  • Start the local environment of the project with docker-compose up.
  • Reinstall the dependencies with sh dev-reinstall.sh.
  • Run the test environment with sh run-all-tests.sh.

Available Endpoints

Csv file upload

Csv file upload containing a list of products to be added to the database.

curl --request POST \
  --url http://localhost:5000/product-list \
  --header 'Content-Type: multipart/form-data' \
  --form 'csvFile=@{file_path}'

Parameters

  • csvFile (required): A file to upload using the multipart/form-data protocol.

Returns

  • storageFilename: generated name of the file stored on bucket.
  • jobId: id of the job related to the file in the queue.

Get Product List job status

Returns the status of the job in the queue.

curl --request GET \
  --url http://localhost:5000/product-list-status/:jobId

Parameters

  • jobId (required): id of the job related to the file in the queue.

Returns

  • productListStatus: status of the job in the queue. Possible values: ["waiting", "completed", "active", "failed", "delayed", "paused", "stuck", "notFound"]

Get all products

Returns all products from the database

curl --request GET \
  --url http://localhost:5000/products

Returns

  • Array with all products data

Get product

Return data of single product from the database

curl --request GET \
  --url http://localhost:5000/product/:id

Parameters

  • id (required): id of the product.

Returns

  • Product data

Remove product

Remove single product from the database

curl --request DELETE \
  --url http://localhost:5000/product/:id

Parameters

  • id (required): id of the product.

Returns

  • Only status code.

Update product

Update single product from the database

curl --request PATCH \
  --url http://localhost:5000/product/:id \
  --header 'Content-Type: application/json' \
  --data '	{
		"lm": 1001,
		"name": "Furadeira X",
		"freeShipping": 0,
		"description": "Furadeira eficiente X",
		"price": 100,
		"category": 123123
	}'

Parameters

  • id (required): id of the product.
  • lm
  • name
  • freeShipping
  • description
  • price
  • category

Returns

  • Only status code.

products-manager's People

Contributors

wcarugatti avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.