SS

Search

Jump to a page, project or post

In progress

Order-fulfilment backend: purchase order to customs

An event-driven fulfilment service on FastAPI, PostgreSQL and Kafka that carries a purchase order through shipment and customs, with DHL carrier integration and Claude parsing the trade documents.

Organisation
1buy.ai
Role
Backend engineer
Date
Kind
Work
Order-fulfilment backend: purchase order to customs: system sketchpublishPurchase ordershipment · customsTrade documentsparsed by ClaudeFulfilment serviceFastAPI · explicit statesKafkadomain eventsPostgreSQLappend-only logDHLbooking · tracking
System sketch. Boxes are the real components; packets show the direction of flow.
Workflow
PO → shipment → customs
Integrations
DHL carrier API, Microsoft 365 mail
Documents
Packing lists, Bills of Entry parsed by Claude
  • Python
  • FastAPI
  • PostgreSQL
  • Kafka
  • SQLAlchemy
  • Alembic
  • Claude API

Context

Fulfilment for a B2B procurement platform spans several departments and several external parties: suppliers, carriers, customs agents, finance. Most of the coordination used to happen in email threads.

What the service does

  • Models the lifecycle of a purchase order through shipment creation, carrier booking and customs clearance as explicit states and events.
  • Publishes domain events to Kafka so other departments react to what happened rather than polling.
  • Reads trade documents (packing lists, Bills of Entry) with Claude and turns them into structured records with human review where confidence is low.
  • Reads its own inbox: an inbound mail pipeline anchors every email to an order or shipment, classifies it, and dispatches the resulting action to the context that owns it.
  • Talks to the DHL carrier API for bookings and tracking.

Engineering notes

  • PostgreSQL with SQLAlchemy 2 async and Alembic migrations. The schema is designed around an append-only event log so the timeline of a shipment is always reconstructible.
  • Strict module boundaries enforced with import rules, so contexts talk through published events rather than direct imports.

This is live work, so the write-up stays at this level of detail.