[Postback]
Serverless Order & Campaign ETL
A Lambda pipeline from a checkout platform and an ad tracker into Postgres — idempotent, timezone-aware and recoverable.
An e-commerce client needed orders and campaign performance in one database to compute ROI per campaign and to send conversion postbacks to the ad tracker.
Solo: Lambda functions, schema, business rules and the recovery path.
Orders change status after they're created, arrive in a different timezone from the business day, and postbacks must never fire twice.
01 · Three modes, one function
A scheduled daily ETL, near-real-time order processing and a “recycle failed” mode that retries what didn't go through.
02 · Idempotent keys
(order, status) for orders and (campaign, landing, pre-landing, date) for campaigns, so reruns upsert instead of duplicating.
03 · Pull by update time
Orders are fetched by last update, not creation, so late refunds and status changes are captured.
04 · Two clocks
Business logic in São Paulo time; API calls in the timezone each API expects.
05 · Postback dedupe and retries
Click ids already sent are kept for two weeks; every external call retries with exponential backoff (1, 2, 4, 8 s).