# Transaction Management in Brand Dashboard ```plantuml !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml ``` ## Architecture Diagram - Existing ```plantuml !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml title Transaction Management - Brand Dashboard Person(brand_admin, "Brand Admin") System_Boundary(brand_web_system, "Brand Administration Web Application") { Container(browser, "Browser", "Software System", "All supported browser") Container(brand_dashboard, "Brand Dashboard", "Nuxt.js", "Provides management functionalities to brand admin via their web browser") } System_Boundary(api_endpoint, "API Endpoint") { Container(brand_api, "evermos-brand-be API", "PHP", "Provides brand management functionalities via HTTPS / REST / JSON API") } ContainerDb(db_evm, "Database", "MySQL", "evm schema") ContainerDb(db_itr, "Database", "MySQL", "itr schema") Rel_R(brand_admin, browser, "Register Brand", "Client Device") Rel_R(browser, brand_dashboard, "Access", "HTTPS") Rel_R(brand_dashboard, brand_api, "Makes API calls to", "HTTPS / REST / JSON") Rel_R(brand_api, db_evm, "Reads from & Writes to", "TCP/IP") Rel(brand_api, db_itr, "Reads from & Writes to", "TCP/IP") ``` ### Get Order List ```plantuml skinparam responseMessageBelowArrow true title Get Order List - Existing Interaction Diagram participant "client" as c participant "evermos-brand-be" as ebb database "evm" as e database "itr" as i c -> ebb : "get order list" activate ebb ebb -> e : "get order list" activate e return order data ebb -> i : "get order list" activate i return order data return order data ``` ### Update Order ```plantuml skinparam responseMessageBelowArrow true title Update Order - Existing Interaction Diagram participant "client" as c participant "evermos-brand-be" as ebb database "evm" as e database "itr" as i c -> ebb : "update order" activate ebb alt if platform = "Evermos" ebb -> e : update order e -> ebb : success/error end alt if platform = "Berikhtiar" ebb -> i : update order i -> ebb : success/error end return success/error ``` ### Generate Waybill ```plantuml skinparam responseMessageBelowArrow true title Generate Waybill - Existing Interaction Diagram participant "client" as c participant "evermos-brand-be" as ebb participant "evermos-admin-be" as eab database "evm" as e database "itr" as i c -> ebb : generate waybill activate ebb ebb -> eab : generate waybill activate eab alt if platform = "Evermos" eab -> e : generate waybill e -> eab : success/error end alt if platform = "Berikhtiar" eab -> i : generate waybill i -> eab : success/error end return success/error return success/error ``` ## Database Design - Existing System ```plantuml hide circle 'skinparam linetype ortho skinparam class { ArrowColor #FF7878 BackgroundColor #FFF89A BorderColor #694E4E } title EVM Database Schema entity "[evm] brand" as b { *id: bigint(20) -- brandParentId: bigint(20) <<FK>> warehouseShelfId: bigint(20) <<FK>> warehouseZoneId: bigint(20) <<FK>> partnershipId: bigint(20) <<FK>> code: varchar(20) slug: text name: varchar(100) type: enum ... } entity "[evm] order" as o { *id: bigint(20) -- orderCode: varchar(60) status: int(11) userId: bigint(20) <<FK>> totalPrice: decimal(12, 2) totalPayment: decimal(12, 2) totalCustomerPrice: decimal(12, 2) totalQuantity: int(11) totalWeight: int(11) ... } entity "[evm] order_detail" as od { *id: bigint(20) -- orderId: bigint(20) <<FK>> orderReceiptId: bigint(20) <<FK>> productId: bigint(20) <<FK>> normalPrice: decimal(12, 2) discountPrice: decimal(12, 2) quantity: int(11) totalPrice: decimal(12, 2) waybill: varchar(100) ... } entity "[evm] order_receipt" as or { *id: bigint(20) -- orderId: bigint(20) <<FK>> userAddressId: bigint(20) <<FK>> orderAddressId: bigint(20) <<FK>> orderReceiptCode: varchar(60) waybill: varchar(100) ... } entity "[evm] product" as p { *id: bigint(20) -- productModelId: bigint(20) <<FK>> name: text code: text ... } entity "[evm] product_model" as pm { *id: bigint(20) -- brandId: bigint(20) <<FK>> name: text code: text ... } b ||-right|{ pm pm ||--|{ p or ||--|{ od o ||--|{ od p ||--|{ od or ||-left|{ o ``` ## Architecture Diagram - Proposed Solution ```plantuml !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml title Transaction Management - Brand Dashboard Person(brand_admin, "Brand Admin") System_Boundary(brand_web_system, "Brand Administration Web Application") { Container(browser, "Browser", "Software System", "All supported browser") Container(brand_dashboard, "Brand Dashboard", "Nuxt.js", "Provides brand management functionalities to brand admin via their web browser") } System_Boundary(api_endpoint, "API Endpoint") { Container(evm_brand, "evm-brand API", "Golang", "Provides brand management functionalities via HTTPS / REST / JSON API") Container(evm_order, "evm-order API", "Golang", "Provides order management functionalities via HTTPS / REST / JSON API") Container(evermos_brand_be, "evermos-brand-be API", "Golang", "Provides brand management functionalities via HTTPS / REST / JSON API") Container(gss, "GSS API", "", "Provides transaction data via HTTPS / REST / JSON API") } ContainerDb(db_evm, "Database", "MySQL", "evm schema") ContainerDb(db_itr, "Database", "MySQL", "itr schema") ContainerDb(db_os, "Database", "GraphQL", "open search") Rel_R(brand_admin, browser, "Register Brand", "Client Device") Rel_R(browser, brand_dashboard, "Access", "HTTPS") Rel(brand_dashboard, evm_brand, "Makes API calls to", "HTTPS / REST / JSON") Rel(brand_dashboard, evermos_brand_be, "Makes API calls to", "HTTPS / REST / JSON") Rel_L(evm_brand, evm_order, "Makes API calls to", "HTTPS / REST / JSON") Rel(evm_order, gss, "Makes API calls to", "HTTPS / REST / JSON") Rel(gss, db_os, "Reads from & Writes to", "TCP/IP") Rel(evermos_brand_be, db_evm, "Reads from & Writes to", "TCP/IP") Rel(evermos_brand_be, db_itr, "Reads from & Writes to", "TCP/IP") ``` ## Database Design - Proposed Solution ```plantuml hide circle 'skinparam linetype ortho skinparam class { ArrowColor #FF7878 BackgroundColor #FFF89A BorderColor #694E4E } title EVM Database Schema entity "[evm] brand" as b { *id: bigint(20) -- brandParentId: bigint(20) <<FK>> warehouseShelfId: bigint(20) <<FK>> warehouseZoneId: bigint(20) <<FK>> partnershipId: bigint(20) <<FK>> code: varchar(20) slug: text name: varchar(100) type: enum ... } entity "[evm] order" as o { *id: bigint(20) -- orderCode: varchar(60) status: int(11) userId: bigint(20) <<FK>> totalPrice: decimal(12, 2) totalPayment: decimal(12, 2) totalCustomerPrice: decimal(12, 2) totalQuantity: int(11) totalWeight: int(11) ... } entity "[evm] order_detail" as od { *id: bigint(20) -- orderId: bigint(20) <<FK>> orderReceiptId: bigint(20) <<FK>> productId: bigint(20) <<FK>> brand: bigint(20) <<FK>> normalPrice: decimal(12, 2) discountPrice: decimal(12, 2) quantity: int(11) totalPrice: decimal(12, 2) waybill: varchar(100) ... } entity "[evm] order_receipt" as or { *id: bigint(20) -- orderId: bigint(20) <<FK>> userAddressId: bigint(20) <<FK>> orderAddressId: bigint(20) <<FK>> orderReceiptCode: varchar(60) waybill: varchar(100) ... } entity "[evm] product" as p { *id: bigint(20) -- productModelId: bigint(20) <<FK>> name: text code: text ... } entity "[evm] product_model" as pm { *id: bigint(20) -- brandId: bigint(20) <<FK>> name: text code: text ... } b ||-right|{ pm b ||--|{ od pm ||--|{ p or ||--|{ od o ||--|{ od p ||--|{ od or ||-left|{ o ``` ### Get Order List ```plantuml skinparam responseMessageBelowArrow true title Get Order List - Proposed Solution participant "client" as c participant "evm-brand" as eb participant "evm-order" as eo participant "evm-gss" as eg database "evm" as e database "itr" as i database "open search" as os c -> eb : "get order list" activate eb eb -> eo : "get order list" activate eo eo -> eg : "get order list" activate eg eg -> os : "get order list" activate os return order data alt if platform = "Evermos" eg -> e : get order detail data e -> eg : order data end alt if platform = "Berikhtiar" eg -> i : get order detail data i -> eg : order data end return order data return order data return order data ``` ### Update Order ```plantuml skinparam responseMessageBelowArrow true title Update Order - Proposed Solution participant "client" as c participant "evm-brand" as eb participant "evm-order" as eo database "evm" as e database "itr" as i c -> eb : "update order" activate eb eb -> eo : "update order" activate eo alt if platform = "Evermos" eo -> e : update order e -> eo : success/error end alt if platform = "Berikhtiar" eo -> i : update order i -> eo : success/error end return success/error return success/error ```