--- title: How is a shipment tendered ? --- ## How a shipment is tendered ? Below one can see all involved parts in tendering/sourcing a load/shipment. Two systems are involved in the process: [Alice](https://github.com/loadsmart/alice) and [Shopkeeper](https://github.com/loadsmart/shopkeeper). Other than describing the steps involved in this process, we also provide the code executed at each one. ```mermaid sequenceDiagram autonumber participant A as Alice participant SK as Shopkeeper A->>SK: Emit "shipment-booked" activate SK SK->>SK: Receive "on-shipment-booked" deactivate SK A->>SK: Emit "shipment-appointments-confirmed" activate SK SK -->> SK: Process with "confirm_appointments" deactivate SK SK-->>A: Emit "offer-accepted" activate A A->>A: Receive "offer-accepted" deactivate A ``` ### Code Reference Below we provide the code executed in each of the steps represented above. The mapping is one to one, which means the number "1" in the diagram is executed by the code in the first item of the bullet list. 1. [Alice "shipment-booked"](https://github.com/loadsmart/alice/blob/85a42f166fcec115e20fc3dab5ec6ef515ff4880/head/load_quotes/events/emit.py#L52) 2. [SK "on-shipment-booked"](https://github.com/loadsmart/shopkeeper/blob/926c9c759eda086d09893cce3eec5a7bfd9a3dd4/events/loads.py#L115) 3. [Alice "shipment-appointments-confirmed"](https://github.com/loadsmart/alice/blob/fcc060241ba1afb9cc1be74b3853d22ddee4e471/head/shipments/signals.py#L90) 4. [SK "shipment-appointments-confirmed"](https://github.com/loadsmart/shopkeeper/blob/99ee33623371442924df2fa185a0db8e1facfc60/events/loads.py#L50) 5. [SK "offer-accepted"](https://github.com/loadsmart/shopkeeper/blob/bb81960b82f29c1b75c4403ea2d8684f4ad32c73/offers/events.py#L100) 6. [Alice "offer-accepted"](https://github.com/loadsmart/alice/blob/443d3d0f3b2d86ac42b5ff1021e7e5a92cecc6c5/head/shopkeeper/events.py#L35) ## What's the problem ? Now LTL shipments are not imediately sourced to the carrier. Existing process requires manual intervention of a Sales Representative. Currenly the only way to scale such process is with humans, which is non-optimal since we're a tech company. Existing rule states that: A LTL shipment can't be sourced without confirmed appointments. Therefore, ASRs manually confirm these appointments allowing a load to be sourced by any carrier. What we want to provide is an automation tackling this process, avoiding human intervention. ## Proposed solution It's mandatory to disclose the fact we still don't know which business rule(s) we're going to apply to implement automatic LTL sourcing. Therefore, I could think of two scenarios: ### Sourcing shipments without appointments confirmed In this scenario, we don't need to wait for event "3" to happen and therefore Shopkeeper's team can write bypass logic to run for LTL shipments. This would mean a LTL shipment will get sourced immediatly after its booked. Roque Betiol, Tech lead of the team had proposed the above solution. ### Sourcing following some other business logic In the case where we don't need to wait for the appointment to be confirmed but need to wait for a specific conditions to happen (To be defined), Alice can create a new custom event named "custom-event", for example. Shopkeeper woudl then be responsible to listen to such event and act to source the LTL quote. We still need to collect information from the product managers to be abble to better propose an architecture robust and scalable enough to tackle the problem.