AI Logistics Coordinator Platform
Self-hosted freight control tower for X12 EDI 214 tracking, multi-constraint route optimization, 409-enforced HITL carrier comms, and ASN/BOL warehouse shrinkage reconciliation.
01. Problem & Context
Freight dispatchers and supply-chain coordinators process continuous streams of X12 EDI 214 status updates, detention exceptions, weather delays, and warehouse ASN/BOL receiving discrepancies—where an unapproved carrier email or misrouted reefer shipment immediately creates financial exposure.
02. Engineering Solution
Built a Phase 2 self-hosted freight Control Tower combining a FastAPI + async SQLAlchemy 2 backend (`tracking/`, `routing/`, `comms/`, `inventory/`, `memory/`, `workers/`, `core/`) with a React 18 TypeScript console. Ingests HMAC-SHA256 carrier webhooks and X12 EDI 214 segments, optimizes lanes across five weighted objectives, enforces `409 Conflict` approval gates on carrier outreach, reconciles ASN/BOL warehouse counts, and indexes resolved exceptions into `pgvector`-ready operational memory.
03. System Architecture
Domain modules (`tracking/`, `routing/`, `comms/`, `inventory/`, `memory/`, `workers/`, `core/`) run on async SQLAlchemy 2 with Alembic migrations, container startup migrations (`backend/entrypoint.sh`), HS256 JWT + `X-API-Key` RBAC (`VIEWER`, `WAREHOUSE`, `DISPATCHER`, `WEBHOOK_INGESTOR`, `ADMIN`), `RateLimitMiddleware`, pure ASGI security headers, optional OpenTelemetry, and SHA-256 hash-chained `audit_logs` (`/api/v1/audit/verify`).
Core Architectural Components
Freight Tracking & X12 EDI 214 Ingestion (`tracking/`)
Ingests HMAC-SHA256 signed carrier webhooks and X12 EDI 214 payloads (`B10`, `AT7`, `MS1`, `G62`, `L11`), normalizes status codes, raises ETA slip and exception alerts (`ETA_SLIP`, `DETENTION`, `CUSTOMS_HOLD`, `WEATHER_DISRUPTION`, `PORT_CONGESTION`, `TEMPERATURE_EXCURSION`), and auto-indexes resolved incidents.
Multi-Constraint Carrier Route Optimizer (`routing/`)
Evaluates active carrier lanes across `BALANCED`, `LOWEST_COST`, `FASTEST_TRANSIT`, `HIGHEST_RELIABILITY`, and `LOWEST_CARBON` objectives while honoring reefer, weight, budget, transit limits, live corridor penalties, and operational memory before dispatcher-approved re-routes.
409-Enforced HITL Carrier Outbox (`comms/`)
Generates carrier messages grounded in live BOL/PRO telemetry and open alerts, strictly returning `409 Conflict` until dispatcher sign-off before dispatching through `simulated`, `smtp`, or HMAC-signed `webhook` adapters with retries and delivery receipts.
ASN/BOL Inventory Reconciliation & Operational Memory (`inventory/`, `memory/`, `workers/`)
Reconciles expected ASN/BOL line counts against warehouse receiving counts to compute financial exposure and shrinkage (`SHORTAGE`, `OVERAGE`, `DAMAGED`, `UNEXPECTED_SKU`), runs Celery + Redis SLA breach sweeps and bulk EDI 214 jobs, and indexes L2-normalized operational memory.
04. Notable Engineering Decisions
HTTP 409 Conflict Dispatch Gate Grounded in BOL/PRO Telemetry
Automated carrier escalations with wrong detention claims or unapproved re-routes harm carrier relationships. Enforcing `409 Conflict` until explicit dispatcher approval ensures every outbound notice is verified.
Feedback Loop Between Resolved Exceptions and Operational Memory
Indexing resolved lane disruptions into L2-normalized `pgvector`-ready operational memory surfaces past corridor workarounds directly inside future route optimizations and carrier drafts.
Scoped Machine & Human Auth Across Warehouse, Dispatcher & Webhook Roles
Separating `WEBHOOK_INGESTOR` API-key ingestion from `WAREHOUSE` receiving and `DISPATCHER` re-routing prevents external carrier webhooks from mutating routes or approvals.
05. Engineering Challenges & Solutions
Challenge: Normalizing heterogeneous X12 EDI 214 segment streams alongside JSON carrier webhooks without dropping SLA alerts.
Engineering Solution: Built dedicated `B10`/`AT7`/`MS1`/`G62`/`L11` EDI 214 parsers and HMAC-SHA256 webhook verification feeding one unified exception detector and Celery SLA sweep.
Challenge: Balancing multi-objective lane re-routing across cost, transit time, reliability, carbon, and cold-chain constraints.
Engineering Solution: Engineered a multi-constraint lane evaluator incorporating reefer/weight/budget bounds and live corridor disruption penalties before dispatcher sign-off.
06. Implementation Highlights
- HMAC-SHA256 carrier webhooks and X12 EDI 214 parser (`B10`, `AT7`, `MS1`, `G62`, `L11`) with 6 exception classifications
- Multi-constraint route optimization (`BALANCED`, `LOWEST_COST`, `FASTEST_TRANSIT`, `HIGHEST_RELIABILITY`, `LOWEST_CARBON`)
- BOL/PRO-grounded carrier outbox enforcing `409 Conflict` HITL gates across `simulated`, `smtp`, and HMAC `webhook` adapters
- ASN/BOL warehouse receiving reconciliation computing financial exposure, shrinkage percentages, and SKU alerts
- L2-normalized operational memory (`pgvector`-ready) plus Celery + Redis SLA breach sweeps and bulk EDI jobs
- React 18 Control Tower UI with one-click demo seeding (`/api/v1/demo/seed`), audit verifier, and Ruff/Mypy/pytest/Vitest/Trivy CI