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.
- NestJS framework
- TypeORM ORM for database operations
- MySQL DB engine
- RabbitMQ message broker
- Redis in-memory data structure store used for caching
- Docker for containerization
- docker-compose for running multi-container Docker applications
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
Contains module for updating average product ratings based on reviews.
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
$ npm install
# 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>
# build & run unit tests & start all services (review-processor in 2 instances - no limit on number of instances)
$ docker-compose up --build -d
# 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
Generated from codebase using compodoc.
$ npm run compodoc
- extract entities to library to remove redundant definitions per app
- health check endpoints to be used in k8s
- e2e tests doesn't end properly, they pass but something is wrong with teardown