Skip to content

torchbear/product-reviews

Repository files navigation

Products & Reviews management

Set of services for managing products and their reviews.

Automatically calculates average rating for each product and updates it when review is created/edited/deleted.

Technology stack

Services

product-reviews

Contains modules for managing products and their reviews. Runs on localhost:3000.

Swagger API is available on localhost:3000/api.

  • Products module
    • provides REST API for managing products
  • Reviews module
    • provides REST API for managing reviews
  • App module
    • provides HTML page on root path with all products and their reviews

review-processor

Contains module for updating average product ratings based on reviews.

Architecture

  • product-reviews:
    • handling all DB operations related to products and reviews
    • using Redis for caching products and reviews to decrease DB traffic
    • sending messages to dedicated queue in RabbitMQ about rating recalculation needs
  • review-processor:
    • listening for messages on dedicated RabbitMQ queue
    • fetching product reviews from DB to recalculate average product rating
    • stores new rating into DB
    • invalidates relevant caches in Redis
    • can be scaled to n replicas as needed
  • dynamic configuration based on .env file

Installation

$ npm install

Running the app on localhost

# start dependencies
$ docker-compose up -d db rabbitmq redis

# start product-reviews service
$ npm run start:product-reviews

# start review-processor service
$ npm run start:review-processor

# or start both just by running
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod:<service-name>

Running the app in docker

# build & run unit tests & start all services (review-processor in 2 instances - no limit on number of instances)
$ docker-compose up --build -d

Testing

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

# lint
$ npm run lint

# formatting
$ npm run format

Documentation

Generated from codebase using compodoc.

$ npm run compodoc

Optional TODOs

  • extract entities to library to remove redundant definitions per app
  • health check endpoints to be used in k8s

Known issues (to be resolved)

  • e2e tests doesn't end properly, they pass but something is wrong with teardown

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published