Under the hood

How Adswish works

A complete look at the backend architecture — from campaign creation to creator payout, every system is explained below.

Tech stack

Next.js 16

App Router + Turbopack

Server components, API routes, middleware

Supabase

Postgres + Auth + Storage

Database, authentication, file storage, realtime

Stripe Connect

Payments + Payouts

Destination charges, transfers, onboarding

Upstash Redis

Rate Limiting

Serverless Redis for rate limit counters

Edge Functions

Tracking Redirects

/t/{slug} redirects with JWT verification

Playwright

E2E Testing

Full browser automation for integration tests

Payments

Payment flow

From business card charge to creator payout — every step is escrow-protected with a 7-day hold window.

1

Business saves card

Stripe Customer created with default payment method. Card details are never stored on Adswish servers.

2

Conversion webhook fires

POST /api/v1/webhooks/conversion receives token, orderId, amount, and attribution method from the tracking system.

3

Destination charge

createDestinationChargeForConversion charges the business card off-session using the saved default PM. 90% goes to creator, 10% platform fee.

4

Ledger entry created

Hold entry (+90% creator) recorded in the ledger as pending_hold. Funds held in Stripe Connect.

5

7-day hold period

Release-holds cron runs daily. After 7 days with no dispute, funds transfer to the creator's Connect account.

6

Creator payout

Stripe Connect v2 onboarding → bank transfer. Payout invoices generated monthly.

Attribution

Tracking & attribution

Edge-redirected links with HMAC-signed JWTs. First-party cookies survive ad blockers. Chrome extension and desktop tracker keep the heartbeat alive.

1

Tracking link created

Edge function generates HMAC-signed JWT with 24h expiry. /t/{slug} redirect captures the attribution token.

2

Click captured

Edge-redirected link sets _adswish cookie with token. Chrome extension or desktop tracker keeps heartbeat alive via /api/v1/pixel/ping.

3

Heartbeat maintained

Extension sends periodic pings to maintain attribution window. Tab visibility changes trigger reconnects.

4

Conversion recorded

Business fires POST to /api/v1/webhooks/conversion with token + orderId + amount. Last-click attribution wins.

Deliverables

Sequential deliverables

Lock-and-key system: Box 1 → Box 2 → Box 3. Database triggers enforce ordering. No slot advances until the previous one is approved.

1

Sequential slots

Creators get Box 1 → Box 2 → Box 3. Each slot unlocks only after business approval. Database trigger enforces ordering.

2

Hashtag verification

Each deliverable needs a unique hashtag. Verified via platform oEmbed API (Instagram, TikTok). Never scrapes pages.

3

Business approval

Business reviews and approves each deliverable. Bulk-approve removed — one at a time for quality control.

4

Tracking link generated

Approved deliverable gets a unique tracking link. Creator shares it — sales attributed automatically.

Security

Security & hardening

Every layer is hardened — Stripe safety, database RLS, rate limiting, SSRF protection, and single-session enforcement.

Stripe Connect v2

Creator onboarding uses the latest Connect v2 API with platform-controlled account creation.

HMAC JWT tokens

Every tracking link signed with HMAC-SHA256. 24-hour expiry prevents replay attacks.

Rate limiting

Upstash Redis rate limiting on all public endpoints. Prevents abuse without blocking legitimate traffic.

SSRF protection

URL validation blocks internal network requests. parsePublicHttpUrl validates all external URLs.

RLS policies

Every database table has Row Level Security. Users can only access their own data.

Single-session

Each login stamps a random session ID. Newer logins supersede older ones across devices.

Database

Core database tables

Supabase Postgres with Row Level Security on every table. 68+ migrations covering the full schema.

campaigns

Campaign definitions, budget, deadlines

deliverables

Sequential slots, status, hashtags

conversions

Attributed sales, amounts, tokens

ledger_entries

Hold/release/refund/chargeback

charge_retries

3DS retry queue for failed charges

payout_invoices

Monthly creator payout records

tracking_links

HMAC JWTs, clicks, attribution

applications

Creator campaign applications

messages

Real-time chat with PII filtering

reviews

Two-sided ratings, right-to-reply

business_profiles

Company info, verified domains

creator_profiles

Tiers, niches, social links

Ready to see it in action?

Create a free account, post your first campaign, and start tracking conversions today.