DEV Community

Cover image for Modelling Truck Flow Through a Container Terminal as Events
Suraj Informatics
Suraj Informatics

Posted on Originally published at surajinformatics.com

Modelling Truck Flow Through a Container Terminal as Events

Container terminals are a good example of a system where the interesting data is not the state but the events. A truck enters the gate, gets weighed, picks up a box in the yard and leaves. If each of those moments is recorded as an event, almost every operational question becomes a simple query.

The events

A minimal event table for the land side of a terminal:

CREATE TABLE truck_events (
  id          BIGINT PRIMARY KEY,
  visit_id    BIGINT NOT NULL,      -- one truck visit
  vehicle_no  VARCHAR(20) NOT NULL, -- read by ANPR
  container   VARCHAR(11),          -- read by OCR, ISO 6346 format
  event_type  VARCHAR(20) NOT NULL, -- GATE_IN, WEIGH_1, YARD_PICK, WEIGH_2, GATE_OUT
  location    VARCHAR(30),          -- gate lane, weighbridge id, yard block
  created_at  TIMESTAMP NOT NULL
);
Enter fullscreen mode Exit fullscreen mode

Questions it answers

  • Truck turnaround time: GATE_OUT minus GATE_IN per visit_id.
  • Where trucks wait: the gap between consecutive events in the same visit shows which stage is slow.
  • Yard hot spots: count YARD_PICK events per block per hour.

Why automatic capture matters

The model only works if events are recorded at the moment they happen. Manual entry adds delay and typing errors, so the timestamps drift and the analysis lies. That is why terminals pair this kind of data model with OCR and ANPR cameras at the gate and an unmanned weighbridge: the event is created by the hardware, not by a clerk.

For the operational side (the quay, the yard, the gate and the KPIs terminal managers track), see this guide to container terminal operations.

Top comments (0)