2.3 KiB
2.3 KiB
MyFreight Assessment
How to run
Easiest way to run this project is using docker compose:
docker compose up
It is possible that this will give some database connection issues on the first try, but after a couple of seconds, it should automatically reconnect.
Alternatively, it is possible to use your own mysql database, and run the code locally:
- Import the
database/entrypoint/init.sqlinto your own database - Update the
.envfile with the database credentials - Run
npm cito install all npm packages - Run
npm run buildto build the nestjs application - Run
npm run start:prodto start the nestjs application
Receiving Tracking information
When receiving Tracking information, the following steps need to be completed to process the data
flowchart TD
receiveTracking(["Receive Tracking"])
findContainerAndShipment["SELECT container JOIN Shipment"]
updateShipment[/Update shipment\]
isArrivingSoon{{"Is arrival estimate between now and now + 24h?"}}
hasArrived{{"Is arrival estimate <=now?"}}
isDelayed{{Is arrival estimate > original arrival + 24h?}}
sendNotification[/Send notification\]
receiveTracking -- "`
**Tracking data**
carrierName:**string**
destinationUnLoCode:**string**
departureDate:**string[_datetime_]**
arrivalDateEstimate:**string[_datetime_]**
containerNumber:**string**
`" --> findContainerAndShipment
findContainerAndShipment --> |WHERE containers.containerNumber = :trackingData.containerNumber| updateShipment
updateShipment --> isArrivingSoon & hasArrived & isDelayed
isDelayed -->|set delayed flag| sendNotification
hasArrived --> |set has arrived flag| sendNotification
isArrivingSoon -->|set is arriving soon flag| sendNotification
%% isArrivingSoon -->|yes| sendArriveSoon
Possible improvements
- Sending the actual notification, there should be a more general way to setup notifiers
- Moving some variables to config files
- when is a shipment "arriving soon"
- mock date
- Use the uuid package
- was not possible since the uuid's from the sample data were invalid uuid's
- Add end-to-end tests as well
- Get shipments should be paginated
- Could use a package like typeorm-crud
- Cleanup duplicate OpenApi decorators, perhaps consolidate them in a custom decorator