Code Monkey home page Code Monkey logo

shophub's Introduction

ShopHub Microservices Project

This project consists of multiple microservices that communicate using RabbitMQ and are managed through Docker. Follow the steps below to set up and run the project.

Prerequisites

Setup

  1. Set the JWT Secret Key

    You need to set the SecretKey for JWT in the appsettings.Development.json file for both ApiGateway and UserService.

    Generate a SecretKey using the following PowerShell command:

    [Convert]::ToBase64String((1..32 | ForEach-Object { (Get-Random -Maximum 256) }))
    

    Add the generated SecretKey to the following files:

    • src/ApiGateway/appsettings.Development.json
    • src/UserService/UserService.API/appsettings.Development.json
  2. Running the Project

    You have two options to run the project:

    Option 1: Using Visual Studio 2022

    • Open the solution in Visual Studio 2022.
    • In the Startup Project dropdown, select docker-compose.
    • Click the play button to start the project.

    This will automatically open the Swagger page with the Order and User services.

    Visual Studio Docker Compose

    Option 2: Using PowerShell

    • Open PowerShell.
    • Navigate to the root directory of the project.
    • Run the following command:
      docker compose -f docker-compose.local.yml up --build -d
      
    • Wait for all the services to stabilize.

    Access the Swagger page at: http://localhost:8080/swagger

Services

  • ApiGateway: Manages routing and authentication for other services.
  • OrderService: Manages orders.
  • UserService: Manages user registration and authentication.
  • NotificationService: Listens to events from RabbitMQ and processes notifications.
  • RabbitMQ: Message broker for event-driven communication between services.

Viewing Notification Service Logs

To see the notification service in action, messages are logged to the console with information about the order ID and the user ID when a new order is created. You can view these messages by:

  • Opening Docker Desktop.
  • Navigating to the notificationservice logs to see the messages.

Things to Improve

  • Validations: Add necessary validations to ensure data integrity.
  • Centralized Authentication Service: Configure an independent service for authentication to avoid adding the SecretKey to multiple projects and installing the same JWT dependencies across multiple microservices.

shophub's People

Contributors

alvarengav avatar

Watchers

 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.