A referral payout runner on AWS for a few dollars a month
Referral programmes fail in a predictable way. Somebody refers three friends, sees nothing appear for two months, asks, gets a vague answer, and tells everyone the programme does not pay. The money was usually fine; the visibility was not. This post walks through a small system built around that failure rather than around the arithmetic.

Key takeaways
- A referral is stamped with the rule version in force when it was made.
- Payable means earned, not signed up. Pay after the refund window, not before.
- A held referral is visible to the person it belongs to, with a reason.
- Every payout comes with an itemised statement somebody can dispute.
- Designed on AWS for about $2 a month.
The whole system on one page
Before any code, here is the shape of what we are designing.
- Database
- Machine learning
- People
The stamp is the whole design
Referral terms change. The commission goes from twenty pounds to fifteen, a product gets excluded, a minimum order value appears. Every one of those changes is legitimate, and every one of them creates the same question: what happens to the referral somebody made last week under the old terms?
The answer has to be that it pays under the old terms, and the only way to guarantee that is to write the rule version onto the referral when it is created and to have no code path anywhere that reads the current rules for an existing referral. It is a small amount of engineering that prevents the single most damaging kind of dispute.
What runs (the inside)
- The recorder. Captures the referral, who made it, when, and which published rule version applies. Part 2.
- The qualifier. Decides when a referral has actually been earned, and holds the ones that need a person. Parts 3 and 4.
- The runner. Pays on a stated day and produces a statement per person, including the held items. Part 5.
One referral, end to end
- Machine learning
- Management
- Front-end & mobile
- People
In plain words
Somebody shares their link. A friend clicks it and orders three days later. The referral was recorded when the link was clicked, stamped with rules version four, which said twenty pounds on any order over fifty.
On day nine the business drops the commission to fifteen pounds. Version five is published, dated, and applies to referrals made from that point. This referral was made under version four, so it stays at twenty.
On day seventeen the refund window closes with no refund, and the referral becomes payable. On the next payout run it is paid, and the referrer gets a statement that says: one referral, ordered 3 August, qualified 17 August, twenty pounds, rules v4. If they had a second referral being held, that would be on the same statement with the reason next to it.
Design rules that shaped every decision
- Stamp the rule version at creation. Never read current rules for an old referral.
- Payable means the money is safe, not that somebody signed up.
- A hold is always visible to the person, with a reason and a way to respond.
- Every payout produces an itemised statement, including zero-payment runs.
- The event log is append-only. A referral’s history is never rewritten.
- No automatic clawback from a future payout without telling the person first.
Why this shape
The distinguishing feature of this system compared to most of the others in this series is that its outputs are other people’s money, and people notice money. A scheduling system that is wrong once a month is annoying; a payout system that is wrong once a month generates a permanent reputation.
That pushes the design towards conservatism in the payment direction and openness in the information direction: pay later than feels good, hold when unsure, and tell people everything about both. Almost every complaint about a referral programme is about silence rather than about the amount.
The next four posts walk through each piece: how a referral is recorded, when it becomes payable, how fraud is handled without punishing everyone, and how a disputed payout gets resolved. One diagram per post, a cost breakdown, and an engineering reference at the end.
All posts