Real-time Track & Trace at LOGIVAN
By Kiên Đỗ on January 31st 2020
For logistics newbie, read this article from our Head of Product first
I still remember using GrabFood for the first time. Back then, I was trying to order a beef sandwich for lunch. A few minutes after ordering the food, immediately I saw on the screen that said “The driver has picked up your food and is arriving”. Then the app was showing that it’d take about 20 minutes for the food to arrive in my room. And when every 5 minutes I check the app, I can see the current location of the driver, to see if he’d arrive on time or not.
That’s the best experience I’ve ever had as a customer ordering a food delivery service. Also I’m sure that Grab uses this data too, as a surveillance tool to watch the driver behavior and ensure the delivery quality.
Similarly in logistics, when moving cargo from point A to point B, everybody wants the same experience too, or EVEN MORE (because logistics is far complicated than car hailing). LOGIVAN needs to provide that kind of experience, and at scale (we have 30,000 shippers in Dec 2019, so just imagine).
Why Track & Trace
Normally, the traditional delivery process from Hai Phong to Ha Noi would be like: on the delivery day, the shipment leaves Hai Phong, hopefully on schedule. If a shipper wants to know where the truck is or if it’s on time, they must call the broker, who calls the carrier, who calls the trucker, who is busy driving. If there’s an accident, the communication chain occurs again, resulting to late information.
There could be a lot of parties involved in the process, and they all want to get that end-to-end visibility of the shipment. With the traditional process, all they can do is calling on the phone, and it’s very frustrating.
When building Track & Trace feature, we want to solve problems and bring values to the users.
For shippers (the customer who wants to move cargo), end-to-end visibility means having immediate access to real-time information about shipment location and status–all the way through the last mile, so they can have better plan & decision like preparing the facility before the truck arrives.
For drivers (the actual person who drives the truck), it means clear instructions on all assigned deliveries and a system that optimizes delivery, to make their lives better.
How it works
Track & Trace consists of four main components:Real-time location tracking, Shipment status, Proof of Delivery (POD) and Notification.
Real-time location tracking
This is the coolest and most important part of Track & Trace. Basically during the whole delivery phase of the shipment, from arriving at pick-up point until dropping off the shipment, the Driver app continuously gets the GPS location and sends it to the backend server. Then, the Shipper app (and some other products) displays shipment location in realtime on the map.
Some product requirements:
- We want the app to track and send GPS data even when the app is in background, or when there’s no internet.
- We want to have realtime location, meaning the location of the shipment is updated real time on the map.
- The journey of the shipment must be drawn accurately as a continuous line on the map
Overview of our solution
- We use a customized version of @mauron85/react-native-background-geolocation to enable background location service on the Driver app, and twist the configs quite a bit to fit with our business needs (minimum distance the driver must move to track & send GPS data, minimum time interval between location updates, .v.v).
- We pre-process the GPS data in our Ruby on Rails app (for authorization, validation and data enrichment) before storing the enriched data to a Firebase Cloud Firestore (which supports real-time syncing out-of-the-box). Then client-side apps like the Shipper app can get the location data and display the whole journey of the shipment in realtime on the map.
- To draw the journey of the shipment on the map, we use
react-google-mapsfor ReactJS apps and
react-native-mapsfor React Native apps.
- It turned out to be quite good after releasing the Offline GPS tracking mode in Dec 2019, as the number of shipments tracked successfully has increasedby 6X (successfully meaning GPS location and other data are all recorded).
To know more about challenges we’re facing, both technical(inaccurate GPS data, background service on low-end Android devices, high throughput API) and non-technical (no internet during the trip, user churn-out); read part II of this article.
A part of the end-to-end visibility is the ability for all parties to know at any given time that who do what at when.
- There’re a couple of milestones in delivering a shipment from A to B, as displayed with timestamp. We store other information about each milestone as well, like who changed the status of the shipment, and where.
- At each milestones, we require the driver to press a button on the app to update the status of the shipment. This is kind of a repetitive work for the driver, so in the future we want to automate this, based on the behavior and the location of the driver.
- Each milestone is corresponded with a shipment status. There are validations & triggers to execute when the status is changed, so we represented them in a state machine. As the business logic grows, we try to keep the AASM state machine file lean & clean. We move most of the complex logic into different services to keep the code decoupled & reusable.
Proof of Delivery (POD) documents
Proof of Delivery documents like cargo photo, work handover, receipt, … are very important in logistics process. They could be used when the warehouse staff needs a work handover document from the driver to let him in to pick up the cargo; or when the shipper needs a confirmation document & cargo photo to pay for the delivery.
Different shipper/driver usually requires a different set of POD, so there could be many types of POD documents we need to capture. Some clients have more complex POD requirements than others (for example: multiple pick-up/drop-off points, require special type of documents or signing .v.v.)
The goal here is to centralize all the documents into one place, so all parties can access them at any time.
react-native-camera to take & pre-processing the photo, and
react-native-image-picker to display it. We store all the photos in Firebase Storage (for quickly setting up and convenient file management APIs).
After having all of the data points above, we will notify someone when a particular event is triggered, in the form of mobile app notification (OneSignal is da best ⭐️), email or SMS.
Notification helps businesses be more aware about the operation events, to help them plan & operate better. For example:
- Every time the status of the shipment is updated → send notifications to related parties.
- When the driver is less than 5km away from pick-up/drop-off point → send notifications to related parties so they could prepare timely.
- When the driver is staying at one location for too long, or if we didn’t receive the location data for about 30 minutes → send notifications to LOGIVAN trucking team to investigate.
Since the first MVP of Track & Trace, it’s been proved to bring lots of values to the business. The first client to use the MVP was happy to see all documents in one place, so their billing and payment process could be much faster. Then a couple of months later, we rolled out a 6X better location tracking with background GPS service on the mobile app, and it helped another client (Ajinomoto) a lot. Ajinomoto staff could easily be aware of the delivery when receiving notification or see the current location of the shipment. It helped them plan their facility sooner, to cut down the loading/unloading time, and also see which of their facilities is the fastest/slowest one.
To see more about how we iterate & improve Track & Trace, as being driven by business outcome, read part II of this article.
Track & Trace is one of the most exciting stuffs we’ve been building at LOGIVAN. To dive deeper into technical stuff, like how we build the offline mode for GPS tracking, how we iterated and improved the feature by data-driven approach, or what we’re going to do next (reporting, automation, AI models); read part II of this article.
See you guys in the next post!