Store (Shopping cart services)

  • (I've been updating this project constantly).
  • Simple project used to study about microservices and apply some technologies and knowledges.
  • Basically there are 2 WebApis: Product and Shopping Cart.
  • The Product Api sends a products list or unique product (get by id) to Front-end app, using HTTP requests.
  • The front-end app sends to ShoppingCart Api by HTTP request: [UserId, ProductId, Quantity, Price].
  • The ShoppingCart Api sends by messaging (RabbitMQ) to Products Api: [ProductId and Quantity].
  • Product Api consumes the queue and update the quantity by ProductId.

Technologies applied:

  • - .Net 7 (C#)
    • Product WebApi:
      • - Clean Architecture
      • - Dapper
      • - Mapper
      • - SQLite Database
      • - RabbitMQ (Consumer)
      • - Logger
      • - Load Tests - K6
      • - Unit Tests
    • ShoppingCart WebApi:
      • - Clean Architecture
      • - Dapper
      • - Mapper
      • - SQLite Database
      • - RabbitMQ (Producer)
      • - Logger
      • - Load Tests - K6
      • - Unit Tests
  • - Git Submodules
  • - Azure Pipelines (Multi-Stage)
  • - Docker
  • [?] - Front End (I don't know if I will do it).

Git submodules:

- To clone a project using submodules:

git clone <URL_MAIN_PROJECT>
git submodule update --init --recursive

- To update a project submodule in the main project:

  • just enter the project and execute:
git pull

To run RabbitMQ:

  • I preferred not to install RabbitMQ because I don't have free space in my Virtual Machine, I've been using a Docker container to use RabbitMQ.

  • You can execute to create a container:

docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.12-management

  • (You will need to create the queue everytime that you want use the system).

  • You can see more here: https://www.rabbitmq.com/download.html

  • In the WebApis (Product and ShoppingCart), It will be necessary install the RabbitMQ client.

  • To install the client, execute it:

 dotnet add package RabbitMQ.Client

Running Product WebApi:

  • The first time that you run the WebApi, It will be created a Database.
  • Before to use the WebApi, you need populate the table (Products).
  • There is a script called Insert_product.sql in Util/Scripts.
  • ...Or you can uncomment the lines commented in Infrastructure/Data/ProductContext.cs (line 19 and lines between 37 and 63).

  • To run webapi, execute it:
dotnet run

Running ShoppingCart WebApi:

  • The first time that you run the WebApi, It will be created a Database.
  • To run webapi, execute it:
dotnet run

Installing k6 Load Test:

  • create a js file:
k6 new 
or 
k6 new SCRIPT_NAME.js
  • You need configure the endpoint, like this:

  • running your script:
$ k6 run script.js

or to define VUs = 10 and duration = 30s.

$ k6 run --vus 10 --duration 30s script.js

About Azure Pipelines: