Skip to content

PrasanKumar93/redis-solutions-demo1

Repository files navigation

Microservice solutions using Redis

Sample Ecommerce application built to demonstrate redis solutions to solve common problems in microservice architecture.

Following are the Microservice tutorials referring this application :

Tech stack

  • Front end : built using nextJs and Tailwind
  • Backend : built using express (nodejs)
  • Database : Prisma (MongoDB, Postgresql ..etc) , Redis

Manage application

Start application

# to start docker app
docker compose up -d

Note:

  • Can view MongoDB data in MongoDB compass at URI mongodb://localhost:27017/dbFashion?directConnection=true

    • If postgresql, connection url is postgresql://prisma:prisma@localhost:5432/dbFashion?schema=public
  • Can view Redis data in RedisInsight at localhost with port 6379

  • Can change above connection details or ports by the environment variables in .env file

Other commands

# to stop docker app
docker compose down

# to stop & also delete volumes (mongodb & redis data)
docker compose down -v

# to rebuild all images & start
docker compose  up -d --build

# to rebuild image of specific service (after any code changes)
docker-compose build --no-cache <service_name>
# example
docker-compose build --no-cache orders-service

To change Database

  1. Configure DATABASE_URL in root .env file
DATABASE_URL=mongodb://mongodb-server:27017/dbFashion
# OR
DATABASE_URL="postgresql://prisma:prisma@postgresql-server:5432/dbFashion?schema=public"
  1. Run specific db schema generation
npm run mongodb-schema
# OR
npm run relational-schema

Note : above command copies database prisma schema file to various services (orders, payments..etc) and generate prisma types

  1. Start docker
docker compose up -d --build

View database

-For MongoDB, download mongodb compass and connect with url mongodb://localhost:27017/dbFashion?directConnection=true

  • For postgresql, connection url is postgresql://prisma:prisma@localhost:5432/dbFashion?schema=public

    • Current application contains pg admin GUI (docker) for postgres, if you want to use same then perform following

      1. open http://localhost:5200/ in browser & enter below details
      email: [email protected]
      password: password
      1. Add new db server -> connection details
      hostname: host.docker.internal
      port: 5432
      username: prisma
      password: prisma

Repo formatting

Run prettier on all the files with the following:

npm i

npm run format

API docs

All API docs are available at /docs/api folder

Database Product list

Smaller dataset of products is used for the demo, but refer database docs to add larger dataset easily

Main folder structure

  • cdn : Contains product images to be served to client (UI)
  • client : frontend of the application
  • database : To seed initial products data
  • docs : API documentation
  • server/ :
    • services : Some microservices of ecommerce app
    • api-gateway : Sample http proxy in-front of micro services
    • common : Shared files among microservices

Screenshots

Product

  • Dashboard: Shows the list of products with search functionality

    redis microservices e-commerce app frontend products page

  • Chat bot: The chat bot is available on the bottom right corner of the page. It can be used to search for products and view the product details.

    redis microservices e-commerce app frontend chat bot

    Clicking on a product in the chat shows the product details on dashboard

    redis microservices e-commerce app frontend product details

  • Shopping Cart: Add products to the cart, then check out using the "Buy Now" button redis microservices e-commerce app frontend shopping cart

  • Order history: Once an order is placed, the Orders link in the top navigation bar shows the order status and history

    redis microservices e-commerce app frontend order history page

  • Admin: The admin link in the top navigation bar shows purchase stats and trending products.

    redis microservices e-commerce app frontend admin page redis microservices e-commerce app frontend admin page

  • Settings: To control UI features

    Settings

and so on

MongoDB

  • products table

products

  • orders table

orders

  • orderProducts table

order-products

  • payments table

payments

Postgressql

  • products table

products

  • orders table

orders

  • orderProducts table

order-products

  • payments table

payments

Redis

  • order-with-products

order-with-products

  • transaction-stream

transaction-stream

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •