diff --git a/crates/stock_manager/docs/Actions.puml b/crates/stock_manager/docs/Actions.puml new file mode 100644 index 0000000..d370333 --- /dev/null +++ b/crates/stock_manager/docs/Actions.puml @@ -0,0 +1,47 @@ +@startuml +'https://plantuml.com/state-diagram + +'scale 600 width +[*] --> CreateProduct +[*] --> LoadAllProducts + +state CreateProduct { + HttpCreateProduct --> CallRpcCreateProduct : RPC + CallRpcCreateProduct --> InsertRecord + + InsertRecord ---> RpcReturnDetailedProduct : RPC + InsertRecord ---> ProductCreatedEvent : MQTT + + RpcReturnDetailedProduct --> [*] + ProductCreatedEvent --> [*] +} + +state LoadAllProducts { + state "Received Load all HTTP Request" as HttpLoadAll + state "Call RPC Load All" as CallRpcLoadAll + state "Load add required data from DB" as LoadAllData + state "Load all products" as LoadProducts + state "Load all variants for all products" as LoadProductsVariants + state "Load all products photos" as LoadProductsPhotos + + HttpLoadAll --> CallRpcLoadAll : RPC + CallRpcLoadAll --> LoadAllData + + LoadAllData --> LoadProducts : concurrently + LoadProducts --> CombineData + + LoadAllData --> LoadProductsVariants : concurrently + LoadProductsVariants --> CombineData + + LoadAllData --> LoadProductsPhotos : concurrently + LoadProductsPhotos --> CombineData + + LoadAllData --> LoadProductsStock : concurrently + LoadProductsStock --> CombineData + + CombineData --> RpcReturnsList : RPC + + RpcReturnsList --> [*] +} + +@enduml diff --git a/crates/stock_manager/docs/Product.puml b/crates/stock_manager/docs/Product.puml new file mode 100644 index 0000000..056c8c1 --- /dev/null +++ b/crates/stock_manager/docs/Product.puml @@ -0,0 +1,52 @@ +@startuml +'https://plantuml.com/class-diagram + +class Product { + int id + String name + String category +} + +class ProductVariant { + int id + int product_id + String name + String short_description + String long_description + int price +} + +class Stock { + int id + int product_variant_id + int quantity + QuantityUnit quantity_unit +} + +class Photo { + int id + String local_path + String file_name + String unique_name +} + +class ProductPhoto { + int id + int product_variant_id + int photo_id +} + +Product -- ProductVariant : owns > +ProductVariant -- Stock : owns > +Photo -- ProductPhoto : < owns +ProductVariant -- ProductPhoto : < owns +Stock -- QuantityUnit : contains + +enum QuantityUnit { + g + dkg + kg + piece +} + +@enduml diff --git a/crates/stock_manager/migrations/202204131841_init.sql b/crates/stock_manager/migrations/202204131841_init.sql index 0e06e07..f352411 100644 --- a/crates/stock_manager/migrations/202204131841_init.sql +++ b/crates/stock_manager/migrations/202204131841_init.sql @@ -16,7 +16,7 @@ CREATE TABLE photos ( CREATE TABLE products ( id integer NOT NULL PRIMARY KEY, - name character varying NOT NULL, + "name" character varying NOT NULL, category character varying, deliver_days_flag integer DEFAULT 127 NOT NULL ); @@ -24,7 +24,7 @@ CREATE TABLE products ( CREATE TABLE product_variants ( id integer NOT NULL PRIMARY KEY, product_id integer REFERENCES products (id) NOT NULL, - name character varying NOT NULL, + "name" character varying NOT NULL, short_description character varying NOT NULL, long_description character varying NOT NULL, price integer NOT NULL, diff --git a/docs/infrastructure.puml b/docs/infrastructure.puml new file mode 100644 index 0000000..1c71abc --- /dev/null +++ b/docs/infrastructure.puml @@ -0,0 +1,103 @@ +@startuml +'https://plantuml.com/deployment-diagram + +scale 1000 + +rectangle "API" { + node "bazzar" + queue rumqttd + + component "Accounts Manager" { + node "account-manager" + database "PostgreSQL bazzar_accounts" + + "account-manager" <--> "PostgreSQL bazzar_accounts" + "account-manager" --> rumqttd : emit event + + usecase "create account" + usecase "me" + + "account-manager" -- "create account" + "account-manager" -- "me" + } + + component "Carts Manager" { + node "cart-manager" + database "PostgreSQL bazzar_carts" + + "cart-manager" <--> "PostgreSQL bazzar_carts" + "cart-manager" <-- rumqttd : account created + } + + component "Search Manager" { + node "search-manager" + database "sonic" + + "search-manager" <--> "sonic" + "search-manager" <-- rumqttd : product created + "search-manager" <-- rumqttd : product deleted + } + + component "Stock Manager" { + node "stock-manager" + database "PostgreSQL bazzar_stocks" + + "stock-manager" <--> "PostgreSQL bazzar_stocks" + "stock-manager" --> rumqttd : emit event + } + + component "E-Mail Sender" { + node "email-sender" + cloud "sendgrid" + + "email-sender" --> "sendgrid" + "email-sender" <-- rumqttd : account created + "email-sender" <-- rumqttd : account deleted + } + + actor " rumqttd" + + "bazzar" -- "Accounts Manager" : rpc + "bazzar" -- "Carts Manager" : rpc + "bazzar" -- "E-Mail Manager" : rpc + "bazzar" --> " rumqttd" : emit event +} + +rectangle "Dependencies" { + database "PostgreSQL bazzar_accounts " + database "PostgreSQL bazzar_carts " + database "sonic " + database "PostgreSQL bazzar_stocks " { + } + cloud "sendgrid " + queue "rumqtt d" +} + +'actor actor +'actor/ "actor/" +'agent agent +'artifact artifact +'boundary boundary +'card card +'circle circle +'cloud cloud +'collections collections +'component component +'control control +'database database +'entity entity +'file file +'folder folder +'frame frame +'interface interface +'label label +'node node +'package package +'queue queue +'rectangle rectangle +'stack stack +'storage storage +'usecase usecase +'usecase/ "usecase/" + +@enduml