Giter Club home page Giter Club logo

stockmanagement's Introduction

Stock Management

This project is designed for managing stock operations for products. Project's use-cases are listed below:

  • Adding a new product to stock
  • Increasing the amount of a certain product in stock
  • Decreasing the amount of a certain product in stock
  • Reset stock of a certain product

Adding a new product to stock

ProductModel class would be reflection of products in the ProductManagement project if ProductManagement project existed. If there exist a ProductManagement project, the StockManagement project would create ProductModel by observing ProductCreatedIntegrationEvent. In our case, ProductModel is created by the user's HTTP request [Post /products]. For every product, InitializeStock action is saved into db. When InitializeStock action is saved into db, StockSnapShotModel is also created and saved. When transactional operation is finished successfully, StockSnapShotCreatedIntegrationEvent is raised.

The StockManagement project is one of the observers which observe StockSnapShotCreatedIntegrationEvent. The StockManagent project creates StockModel for each event. This model is used for only read operations.

Increasing the amount of a certain product in stock

ProductId, Count, and CorrelationId values are required to increase the amount of a certain product in stock. CorrelationId is required to ensure that this operation is executed only once. When AddToStock operation is finished successfully, StockCountIncreasedIntegrationEvent is raised.

StockModel's AvailableStock value will be updated by the StockManagement project when StockCountIncreasedIntegrationEvent is observed.

Decreasing the amount of a certain product in stock

ProductId, Count, and CorrelationId values are required to decrease the amount of a certain product in stock. CorrelationId is required to ensure that this operation is executed only once. When RemoveFromStock operation is finished successfully, StockCountDecreasedIntegrationEvent is raised.

StockModel's AvailableStock value will be updated by the StockManagement project when StockCountDecreasedIntegrationEvent is observed.

Reset stock of a certain product

ProductId and CorrelationId values are required to reset stock of a certain product. CorrelationId is required to ensure that this operation is executed only once. ResetStock operation is similar to RemoveFromStock operation. When ResetStock operation is finished successfully, StockCountDecreasedIntegrationEvent is raised.

RUN

Way 1

The project could be executed via docker-compose. If you have an IDE which is capable of debugging docker-compose file, docker-compose.yml whic is located at the main directory would be useful for you.

In case of choosing this way to run the project, you can reach swagger screen via http://localhost:2020.

Note: Because the sql server needs more time to be ready compared to StockManager-Api, it might take a while for you to reach the endpoints after docker-compose up command execution.

Way 2

If you want to execute the project without using docker, it is required that you set the connection strings inside the StockManagement/appsettings.json file.

Changes to be made are:

  1. DbConfig -> DbOptions -> ConnectionStr value should be changed with the Sql Server connection string that you have.
  2. DistributedLockConfig -> DistributedLockOptions -> ConnectionStr value should be changed with the Sql Server connection string that you have.
  3. MassTransitConfig -> MassTransitOptions -> HostName, VirtualHost, Username, Password values should be changed with the RabbitMq platform information that you have.

In the first item if the connection string information is invalid, application will crash immediately. In order to check if the remaining settings are valid, you can use http://localhost:5000/healthchecks-ui endpoint.

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.