E-Commerce Order & Shipping Reconciliation Pipeline
Automated multi-portal data collection, order-to-carrier reconciliation, and shipment email dispatch
Architectural summary only — client identity, third-party portal specifics, internal schemas, and operational credentials are intentionally omitted.
Context & Problem
Small and mid-sized e-commerce operations frequently end up split across three separate systems that never talk cleanly to each other: an online storefront for customer orders, an invoicing tool for billing, and a logistics carrier portal for shipping labels and tracking numbers.
Reconciling those exports manually in spreadsheets meant hunting down mismatched customer names, verifying which orders already had tracking numbers, formatting daily master workbooks, and copying tracking updates into customer emails one by one.
Pipeline Architecture
Storefront + Invoicing + Carrier Portals
│
▼ Resilient Headless Collection (retry wrappers · shadow-DOM handling · session checks)
│
▼ Multi-Pass Pandas Reconciliation
│ ├─ Pass 1: Exact Order ID & normalized tracking number joins
│ ├─ Pass 2: Unmatched row isolation across all three sources
│ └─ Pass 3: Fallback matching by city + postal code for name/email mismatches
│
├──► Formatted Multi-Sheet Master Workbook (OpenPyXL / XlsxWriter)
└──► Grouped In-Transit Tracking Emails + Success/Failure Alerts
1. Resilient Export Collection
Web portals often change DOM timing, hide controls inside shadow roots, or drop sessions mid-run. The collection stage wraps browser interactions in explicit retry decorators (retry_on_exception), driver liveness checks, shadow-element waiters, and deterministic download completion verification before moving exported CSVs into the processing workspace.
2. Multi-Pass Pandas Reconciliation
Order records across storefront, billing, and shipping exports rarely share clean foreign keys on every row. The reconciliation engine normalizes identifier formats and runs staged DataFrame joins:
- Deduplicates merged records by unique tracking number.
- Isolates unmatched storefront orders, unmatched invoices, and unmatched carrier shipments into dedicated exception tables.
- Applies a secondary heuristic matching unmatched orders against carrier exports using normalized city and postal-code pairs when customer names or email addresses diverge between billing and shipping.
3. Automated Excel Reporting & Grouped Customer Dispatch
The processed datasets are written back into a multi-sheet master Excel workbook with dynamic column auto-sizing and custom sort macros so operations staff can inspect matched and unmatched exceptions at a glance. Once reconciled, an email dispatcher groups tracking numbers per shipment batch, composes responsive HTML transit notifications, updates the tracking-sent state in the workbook, and triggers decorator-based failure/success alerts if any step throws.
Trade-offs & Lessons Learned
- Idempotent workbook updates: Tracking which rows have already triggered customer notifications prevents duplicate shipping emails if a later pipeline step fails and needs to be re-run.
- Explicit exception sheets over silent drops: Surfacing unmatched invoices and shipments in dedicated tabs gave operators trust in the automation because edge cases remained visible rather than disappearing into logs.