Skip to content
clariant @ arch : ~/clariant/work/partner-portal
cd ~/work

~/work/partner-portal on ⎇ main [✓]❯cat case-study.md

shipping

Partner Portal

Commission tracking, payouts, deal registration, and tiered rebates for Dewaweb's reseller program. It calculates money owed to partners, so idempotency and race-proof state were requirements, not features. I started it; a teammate now leads it.

role
AI Engineer Intern
period
Jun – Oct 2026
company
Dewaweb
status
shipping
Next.js Prisma PostgreSQL Better Auth Docker

Context

Dewaweb wanted one portal for its partner program: resellers and affiliates checking commissions, registering deals, and requesting payouts, with an admin side for the team running the program. The spec came out of discussions with the General Manager rather than being handed down. I started the repo and built the first version with one teammate. Since August the teammate has led development; what I added after that is under “Since August”.

What I built

Eight spec modules, scaffolded on 11 June and built out over 12 June with an AI coding agent. That day included a work-in-progress commit that says plainly the session was cut short by an API spend limit.

  • Billing ingest and attribution. A webhook receiver with idempotent processing, so the same billing event can never pay commission twice, plus promo redirects and landing pages for attribution.
  • Payouts. Hold-by-debit withdrawal requests on a race-proof state machine, with a prioritized admin queue. Concurrent requests can’t turn into a double payout.
  • Deal registration. A first-to-register lock so two partners can’t claim the same prospect, an up-front check so partners see conflicts before submitting, and bulk import from Excel.
  • Engines. Claim-based quarterly rebates, yearly re-tiering, and perks with annual catch-up, plus reconciliation.
  • Dashboards. A partner dashboard and an admin core with a partner directory, webhook monitor, and tier editor.
  • A billing simulator. Rather than only unit-testing the money logic, I built a simulator that runs a full demo dataset through the real engines, with 13 scenarios acting as an executable contract.

Deployment

Shipped to Dewacloud through GitLab CI, and the path there was a run of real infrastructure problems. Prisma 7 broke inside Docker because of pnpm symlinks, which took four attempts to resolve fully. The CI runner ran out of disk; I relaxed the gates temporarily and said so explicitly in the commit message, so it didn’t become hidden debt. Switching deploys to rsync then started wiping the node’s .env until I excluded it.

Since August

  • Automated invoice sync. A job pulls DewaVPS invoices every 10 minutes and prunes duplicate events, with contract tests pinning the API’s pagination behaviour.
  • Webhook replay. Admins can find webhook events by customer and replay them in bulk, with a guard so replays are never replayed again.
  • Account Executives. An AE role with a coverage field and an AE directory, broken down into quarterly MRR and rebates.
  • Payouts. A withdrawal can be redeemed as product credit, and each withdrawal emails a PDF statement.

Outcome

On 23 June the business shut down the B2C affiliate program. I narrowed the portal to VIP B2B partners and raised the rebate ceiling to 18%, cutting scope after most of it was already built. It runs in production on Dewacloud.

Stack

Next.js · TypeScript · Prisma 7 · PostgreSQL · Better Auth · Tailwind CSS 4 · shadcn · recharts · Vitest · Docker · nginx · GitLab CI