# Partner Nook — Next.js + NestJS

Shopify affiliate & influencer marketing app, built as a working end-to-end loop
(not just an admin CRM). Modelled on GoAffPro's core functionality.

- **`apps/api`** — NestJS backend: tracking, attribution, commission engine,
  payouts. Prisma + PostgreSQL (`partner_nook` DB).
- **`apps/web`** — Next.js frontend: affiliate signup/login/dashboard, a demo
  store (conversion), and the merchant admin.

## The loop it implements

1. **Signup** — affiliate self-registers (`/signup`).
2. **Approve** — admin approves → unique coupon + referral link auto-generated (`/admin`).
3. **Share & click** — affiliate shares the referral link; a visit is tracked as a click.
4. **Convert** — customer buys via the link/coupon in the demo store (`/store`);
   commission is calculated automatically (per-affiliate → group → default rate).
5. **Earn** — the affiliate dashboard shows clicks, sales, earnings, balance (`/dashboard`).
6. **Payout** — affiliate requests a payout (min-threshold enforced); admin marks it paid.

## Run locally

Two terminals:

```bash
# 1) backend  → http://localhost:4000/api
cd apps/api && npm run start:dev

# 2) frontend → http://localhost:3000
cd apps/web && npm run dev
```

Then open **http://localhost:3000** and click through the loop.

Prereqs: PostgreSQL running with the `partner_nook` database (shared with the
earlier build). `apps/api/.env` holds `DATABASE_URL`.

## Tech

- NestJS 11, Prisma 6, PostgreSQL
- Next.js 16 (App Router), React 19, Tailwind v4

## Notes

- This supersedes the earlier `../partner-nook` (Shopify embedded-app template),
  which was an admin-only CRM. Real Shopify webhook wiring (replacing the demo
  `/checkout/simulate`) and Trackier integration are the next steps.
