{
  "id": 17964473,
  "title": "Where do you put a referral program when everything it touches lives in the monolith?",
  "url": "https://urgent.news/2026/11/03/where-do-you-put-a-referral-program-when-everything-it-touches-lives",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-03T13:06:12.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/goodbarber/where-do-you-put-a-referral-program-when-everything-it-touches-lives-in-the-monolith-4hd1"
  },
  "original_language": "en",
  "account": "On October 22, the author chose to implement a referral program within the existing PHP monolith of GoodBarber, an app platform. The referral discount needed to be applied via the voucher system, while still being tracked in the system. The referral discount had to interact with various elements such as the checkout, payment confirmation, invoices, credit notes, vouchers, and renewals, all of which were located within the monolith.\n\nThe author explored several options for where to place the referral program. One option involved creating a new table in the shared database, but the author was hesitant about this approach due to concerns about breaking the existing billing models. Another option was to use a pre-existing key/value table, which held attributes for users and apps. This table could store referral codes and their states, but it would require a \"SELECT ... FOR UPDATE\" during reservation to handle concurrency. The author also considered creating a separate service with its own database, but this would introduce additional complexity in terms of deployment, hosting, monitoring, and backup.\n\nUltimately, the author opted for a voucher table, which eliminated the need for a new table or migration. Referral codes would be stored as vouchers, with the sponsor's app acting as the voucher's owner. Each use of the referral code would be recorded as a row in a usage table, which would switch to a paid status when an invoice was created. A cron job would then check for paid uses that were old enough to be validated and grant the rewards accordingly.\n\nThe author later reflected on the decision and considered questions such as whether a separate service would have been preferable from the start, whether using the shape of the code as a marker would be acceptable, and where to place small features that required significant changes to the monolith.",
  "summary": "On October 22, I picked up a referral program halfway through. A first version applied the referral discount by writing it straight into the order line. I refused it. I wanted the discount to go through the voucher system we already have, and the referral to stay tracked. Some context. I run backend engineering at GoodBarber , an app platform, and our customers pay for their apps through a back…",
  "key_points": [
    "Referral program implemented in PHP monolith of GoodBarber app platform",
    "Referral codes stored as vouchers in existing voucher table",
    "Cron job validates and grants rewards for paid referral uses"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}