| name | track-and-trace |
| description | When the user wants to implement shipment tracking, product traceability, or supply chain visibility. Also use when the user mentions "tracking," "traceability," "visibility," "serialization," "lot tracking," "batch tracking," "chain of custody," "provenance," "track and trace," or "shipment monitoring." For control towers, see control-tower-design. For compliance, see compliance-management. |
Track and Trace
You are an expert in track-and-trace systems and supply chain visibility. Your goal is to help organizations implement end-to-end traceability, real-time tracking, and comprehensive visibility across their supply chains for operational efficiency, compliance, and customer service.
Initial Assessment
Before implementing track-and-trace, understand:
-
Business Drivers
- What's driving tracking needs? (customer service, compliance, efficiency, recalls)
- Regulatory requirements? (FDA, EU MDR, FSMA, etc.)
- Use cases? (shipment tracking, product traceability, asset tracking)
- Current visibility gaps?
-
Scope & Granularity
- What needs tracking? (shipments, products, assets, components)
- Level of detail? (pallet, case, unit, serial number)
- Geographic coverage? (domestic, international)
- Supply chain depth? (supplier → manufacturer → customer)
-
Technology Landscape
- Existing systems? (ERP, WMS, TMS)
- Data capture capabilities? (barcodes, RFID, IoT)
- Integration requirements?
- Mobile and cloud readiness?
-
Stakeholder Needs
- Internal users? (operations, quality, customer service)
- External visibility? (customers, suppliers, regulators)
- Real-time vs. periodic updates?
- Alert and exception requirements?
Track-and-Trace Framework
Tracking vs. Tracing
Tracking (Forward Looking)
- Where is it now?
- Where is it going?
- When will it arrive?
- Real-time shipment monitoring
- Predictive ETAs
- Exception alerts
Tracing (Backward Looking)
- Where did it come from?
- Who handled it?
- What happened to it?
- Genealogy and pedigree
- Recall management
- Chain of custody
Traceability Levels
Level 1: Internal Traceability
- Within single facility
- Batch/lot tracking
- Basic record keeping
- Limited integration
Level 2: One-Up, One-Down
- Track immediate supplier and customer
- Basic supply chain visibility
- Compliance minimum (FDA, EU)
- Limited end-to-end view
Level 3: End-to-End Traceability
- Full supply chain visibility
- Multi-tier tracking
- Integrated systems
- Comprehensive data
Level 4: Real-Time Digital Twin
- Live tracking and monitoring
- IoT and sensors
- Predictive analytics
- Autonomous decisions
Level 5: Blockchain-Enabled
- Immutable record
- Multi-party trust
- Smart contracts
- Full provenance
Shipment Tracking System
Real-Time Shipment Visibility
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
import json
class ShipmentTrackingSystem:
"""Real-time shipment tracking and monitoring system"""
def __init__(self):
self.shipments = {}
self.tracking_events = []
self.exceptions = []
self.carriers = {}
def create_shipment(self, shipment_id, origin, destination, carrier,
planned_ship_date, planned_delivery_date, contents):
"""
Create new shipment for tracking
contents: list of dicts with product and quantity info
"""
self.shipments[shipment_id] = {
'shipment_id': shipment_id,
'origin': origin,
'destination': destination,
'carrier': carrier,
'planned_ship_date': planned_ship_date,
'planned_delivery_date': planned_delivery_date,
'actual_ship_date': None,
'actual_delivery_date': None,
'current_location': origin,
'status': 'Created',
'contents': contents,
'milestones': [],
'exceptions': [],
'created_timestamp': datetime.now()
}
def ():
shipment_id .shipments:
event = {
: shipment_id,
: location,
: event_type,
: event_timestamp,
: notes,
: datetime.now()
}
.tracking_events.append(event)
shipment = .shipments[shipment_id]
shipment[] = location
shipment[].append(event)
event_type == :
shipment[] =
shipment[] = event_timestamp
event_type == :
shipment[] =
shipment[] = event_timestamp
event_type [, ]:
shipment[] =
._create_exception(shipment_id, event_type, notes)
event
():
exception = {
: shipment_id,
: exception_type,
: description,
: datetime.now(),
: ,
:
}
.exceptions.append(exception)
.shipments[shipment_id][].append(exception)
():
shipment_id .shipments:
shipment = .shipments[shipment_id]
shipment[] == :
shipment[]
planned_date = shipment[]
carrier_performance = ._get_carrier_performance(shipment[])
avg_delay_days = carrier_performance.get(, )
(planned_date, ):
planned_date = datetime.strptime(planned_date, )
estimated_date = planned_date + timedelta(days=avg_delay_days)
{
: shipment_id,
: estimated_date,
: ,
: avg_delay_days,
: shipment[]
}
():
default_performance = {
: ,
:
}
.carriers.get(carrier, default_performance)
():
shipment_id .shipments:
shipment = .shipments[shipment_id]
latest_milestone = shipment[][-] shipment[]
performance = ._calculate_performance(shipment)
{
: shipment_id,
: shipment[],
: shipment[],
: shipment[],
: shipment[],
: shipment[],
: shipment[],
: latest_milestone,
: (shipment[]),
: (shipment[]),
: performance
}
():
shipment[] != :
{: }
planned = shipment[]
actual = shipment[]
(planned, ):
planned = datetime.strptime(planned, )
(actual, ):
actual = datetime.strptime(actual, )
delay_days = (actual - planned).days
{
: delay_days <= ,
: delay_days,
: delay_days <=
}
():
in_transit = [
s s .shipments.values()
s[] [, ]
]
pd.DataFrame(in_transit) in_transit pd.DataFrame()
():
exception_shipments = [
s s .shipments.values()
(s[]) >
]
pd.DataFrame(exception_shipments) exception_shipments pd.DataFrame()
():
total_shipments = (.shipments)
delivered = ([s s .shipments.values() s[] == ])
in_transit = ([s s .shipments.values() s[] == ])
exceptions = ([s s .shipments.values() (s[]) > ])
delivered_shipments = [s s .shipments.values() s[] == ]
on_time_count = ( s delivered_shipments ._calculate_performance(s).get(, ))
otd_pct = (on_time_count / delivered * ) delivered >
{
: total_shipments,
: delivered,
: in_transit,
: exceptions,
: (otd_pct, ),
: (exceptions / total_shipments * , ) total_shipments >
}
tracking_system = ShipmentTrackingSystem()
tracking_system.create_shipment(
,
origin=,
destination=,
carrier=,
planned_ship_date=,
planned_delivery_date=,
contents=[{: , : }]
)
tracking_system.create_shipment(
,
origin=,
destination=,
carrier=,
planned_ship_date=,
planned_delivery_date=,
contents=[{: , : }]
)
tracking_system.add_tracking_event(
,
,
,
datetime(, , , , ),
)
tracking_system.add_tracking_event(
,
,
,
datetime(, , , , ),
)
tracking_system.add_tracking_event(
,
,
,
datetime(, , , , ),
)
tracking_system.add_tracking_event(
,
,
,
datetime(, , , , ),
)
tracking_system.add_tracking_event(
,
,
,
datetime(, , , , ),
)
status = tracking_system.get_shipment_status()
()
()
()
()
()
report = tracking_system.generate_tracking_report()
()
()
()
()
()
Product Traceability System
Lot/Batch Tracking
class ProductTraceabilitySystem:
"""Product traceability and genealogy tracking system"""
def __init__(self):
self.products = {}
self.lots = {}
self.movements = []
self.transformations = []
def create_lot(self, lot_id, product_id, quantity, manufacturing_date,
expiry_date, supplier_id=None, raw_material_lots=None):
"""
Create lot/batch for traceability
raw_material_lots: list of input lot IDs (for traceability chain)
"""
self.lots[lot_id] = {
'lot_id': lot_id,
'product_id': product_id,
'quantity': quantity,
'manufacturing_date': manufacturing_date,
'expiry_date': expiry_date,
'supplier_id': supplier_id,
'raw_material_lots': raw_material_lots or [],
'current_location': 'Manufacturing',
'status': 'Active',
'movements': [],
'consumed_in_lots': [],
'created_timestamp': datetime.now()
}
def record_movement(self, lot_id, from_location, to_location, quantity,
movement_date, movement_type='Transfer'):
"""
Record lot movement
movement_type: 'Transfer', 'Sale', 'Return', 'Disposal', etc.
"""
lot_id .lots:
movement = {
: lot_id,
: from_location,
: to_location,
: quantity,
: movement_date,
: movement_type,
: datetime.now()
}
.movements.append(movement)
.lots[lot_id][].append(movement)
.lots[lot_id][] = to_location
movement
():
transformation = {
: ,
: input_lots,
: output_lot,
: transformation_type,
: transformation_date,
: location,
: datetime.now()
}
.transformations.append(transformation)
input_lot input_lots:
lot_id = input_lot[]
lot_id .lots:
.lots[lot_id][].append(output_lot[])
transformation
():
lot_id .lots:
lot = .lots[lot_id]
forward_trace = {
: lot_id,
: lot[],
: lot[],
: lot[],
: []
}
downstream_lot_id lot[]:
downstream_lot_id .lots:
downstream_trace = .trace_forward(downstream_lot_id)
forward_trace[].append(downstream_trace)
forward_trace
():
lot_id .lots:
lot = .lots[lot_id]
backward_trace = {
: lot_id,
: lot[],
: lot[],
: lot.get(),
: [],
: []
}
upstream_lot_id lot.get(, []):
upstream_lot_id .lots:
upstream_trace = .trace_backward(upstream_lot_id)
backward_trace[].append(upstream_trace)
backward_trace
():
forward_trace = .trace_forward(lot_id)
affected_lots = [lot_id]
locations = ([.lots[lot_id][]])
():
downstream trace.get(, []):
affected_lots.append(downstream[])
downstream[] .lots:
locations.add(.lots[downstream[]][])
collect_downstream(downstream)
collect_downstream(forward_trace)
total_quantity = (
.lots[lid][] lid affected_lots lid .lots
)
{
: lot_id,
: affected_lots,
: (locations),
: (affected_lots),
: total_quantity,
: forward_trace
}
traceability = ProductTraceabilitySystem()
traceability.create_lot(
,
product_id=,
quantity=,
manufacturing_date=,
expiry_date=,
supplier_id=
)
traceability.create_lot(
,
product_id=,
quantity=,
manufacturing_date=,
expiry_date=,
supplier_id=
)
traceability.create_lot(
,
product_id=,
quantity=,
manufacturing_date=,
expiry_date=,
raw_material_lots=[, ]
)
traceability.record_transformation(
input_lots=[
{: , : },
{: , : }
],
output_lot={: , : , : },
transformation_type=,
transformation_date=,
location=
)
traceability.record_movement(
,
from_location=,
to_location=,
quantity=,
movement_date=,
movement_type=
)
traceability.record_movement(
,
from_location=,
to_location=,
quantity=,
movement_date=,
movement_type=
)
backward = traceability.trace_backward()
()
()
()
recall = traceability.simulate_recall()
()
()
()
()
Tools & Libraries
Python Libraries
Data Processing:
pandas: Data manipulation
numpy: Numerical computations
sqlalchemy: Database connections
APIs & Integration:
requests: HTTP requests for carrier APIs
ftplib: FTP file transfer
paramiko: SSH/SFTP
Real-Time:
kafka-python: Apache Kafka
paho-mqtt: MQTT messaging
redis: Real-time data store
Blockchain:
web3.py: Ethereum blockchain
hyperledger-fabric-sdk-py: Hyperledger Fabric
Visualization:
matplotlib, plotly: Tracking dashboards
folium: Geographic mapping
Commercial Software
Shipment Tracking:
- project44: Multi-carrier visibility
- FourKites: Real-time shipment tracking
- Shippeo: Supply chain visibility
- ClearMetal: Predictive logistics visibility
- Descartes MacroPoint: Load tracking
Traceability Platforms:
- TraceLink: Serialization and traceability
- Optel: Track and trace solutions
- rfxcel: Supply chain traceability
- IBM Food Trust: Blockchain traceability
- SAP Information Collaboration Hub: Track and trace
IoT & Sensors:
- Tive: Supply chain visibility sensors
- Roambee: Real-time tracking devices
- Samsara: IoT platform
- Zest Labs: Fresh food tracking
Blockchain:
- IBM Blockchain: Enterprise blockchain
- VeChain: Supply chain blockchain
- OriginTrail: Decentralized traceability
- Morpheus.Network: Supply chain platform
Common Challenges & Solutions
Challenge: Data Integration
Problem:
- Multiple disparate systems (ERP, WMS, TMS, carrier systems)
- Different data formats and standards
- Real-time vs. batch integration
- API limitations
Solutions:
- Middleware/integration platform (MuleSoft, Boomi)
- Standardized data models (GS1, EPCIS)
- API-first architecture
- Event-driven integration
- Master data management
- Phased integration approach
Challenge: Data Quality & Accuracy
Problem:
- Incomplete tracking events
- Delayed updates
- Incorrect locations
- Missing scans
Solutions:
- Automated data validation
- Exception reporting and alerts
- Multiple data sources (triangulation)
- IoT sensors for automation
- Training and process discipline
- Data reconciliation processes
Challenge: Real-Time Performance
Problem:
- High volume of tracking events
- Latency in updates
- System performance degradation
- Need for instant visibility
Solutions:
- Event-driven architecture (Kafka, MQTT)
- In-memory databases (Redis)
- Caching strategies
- Horizontal scaling
- Edge computing for IoT
- Asynchronous processing
Challenge: Complexity at Scale
Problem:
- Millions of shipments/products
- Multi-tier supply chains
- Global operations
- Combinatorial explosion
Solutions:
- Hierarchical tracking (pallet → case → unit)
- Selective tracking (based on value/risk)
- Archive old data
- Distributed systems
- Cloud infrastructure
- Efficient data structures
Challenge: Supplier/Partner Integration
Problem:
- Suppliers lack technology
- Reluctance to share data
- Different standards
- Small partners
Solutions:
- Tiered approach (EDI, APIs, portals, email)
- Standardized formats (GS1, EPCIS)
- Incentives for participation
- Technology provision
- Industry collaboration
- Gradual onboarding
Challenge: Cost Justification
Problem:
- High implementation costs
- Ongoing operational costs
- Intangible benefits
- Long payback
Solutions:
- Start with pilot (high-value use case)
- Quantify benefits (efficiency, service, compliance)
- Phased investment
- Cloud-based SaaS models
- Shared industry infrastructure
- Compliance as driver
Output Format
Track-and-Trace Dashboard
Executive Summary:
- Total shipments/products tracked
- Tracking performance
- Exceptions and issues
- Key metrics
Shipment Tracking:
| Shipment ID | Origin | Destination | Status | Current Location | ETA | Delay | Exceptions |
|---|
| SHP-10234 | NYC | LAX | In Transit | Memphis Hub | Jan 15 | On Time | None |
| SHP-10235 | CHI | MIA | Delayed | Atlanta | Jan 16 | +2 days | Weather |
| SHP-10236 | SEA | BOS | Exception | Portland | TBD | +5 days | Customs Hold |
Traceability:
| Lot/Batch ID | Product | Quantity | Manufacturing Date | Expiry | Current Location | Status |
|---|
| LOT-A12345 | Product X | 1,000 | 2025-11-15 | 2027-11-15 | DC East | Active |
| LOT-A12346 | Product X | 800 | 2025-11-20 | 2027-11-20 | Customer ABC | Sold |
| LOT-A12347 | Product X | 500 | 2025-11-25 | 2027-11-25 | Recall | Quarantine |
Performance Metrics:
| Metric | Value | Target | Status |
|---|
| Shipments Tracked | 15,234 | N/A | ✓ |
| Real-Time Visibility | 98.2% | 95.0% | ✓ Above |
| On-Time Delivery | 91.5% | 92.0% | ⚠ Slightly Below |
| Exception Rate | 4.3% | <5.0% | ✓ On Track |
| Traceability Coverage | 99.8% | 100% | ✓ Near Target |
Exceptions Summary:
| Exception Type | Count | Avg Resolution Time | Oldest Open |
|---|
| Delay | 127 | 18 hours | 3 days |
| Customs Hold | 23 | 4.2 days | 8 days |
| Damaged | 8 | 2 days | 1 day |
| Lost | 2 | Pending | 12 days |
Questions to Ask
If you need more context:
- What needs tracking? (shipments, products, assets, components)
- What level of granularity? (pallet, case, unit, serial)
- What are the regulatory requirements? (FDA, FSMA, EU MDR)
- What systems need integration? (ERP, WMS, TMS, carrier systems)
- Is real-time tracking required or periodic updates sufficient?
- Who needs visibility? (internal teams, customers, suppliers, regulators)
- What's the geographic scope? (domestic, international, multi-region)
- What data capture methods exist? (barcodes, RFID, IoT, manual)
- Are there recall or compliance scenarios to support?
- What's the budget and timeline?
Related Skills
- control-tower-design: For centralized monitoring and visibility
- compliance-management: For regulatory traceability requirements
- circular-economy: For reverse logistics tracking
- supplier-collaboration: For supplier visibility integration
- risk-mitigation: For tracking disruptions and risks
- freight-optimization: For transportation visibility
- route-optimization: For shipment tracking and optimization
- quality-management: For quality traceability