# THE MONEY FACTORY — Operator Console Tutorial

**Live URL:** https://nr-money-factory.pages.dev

The Money Factory is now a **5-tab operator console** for the entire Next Realm Overnight Money Apps portfolio.

---

## The 5 tabs

### 1. **Grid** — visual portfolio at a glance
- Every app in the portfolio as a card
- Status badge (LIVE / BUILD / QUEUE), price, category
- Hover any card → quick-action chips (admin, preview)
- Filter by status or category (Creator / Finance / Social / Gamer / etc.)
- Click any LIVE card → opens app in new tab

### 2. **Console** — real-time event stream
- Terminal-aesthetic event firehose across all live apps
- Filter by app or event type (generate / purchase / pageview / checkout_start / error)
- Pause / resume / clear controls
- Polls every 5 seconds
- Click "Show demo events" if `FACTORY_TOKEN` not yet wired

### 3. **Analytics** — cross-app charts
- 30-day revenue line chart (aggregated)
- 30-day visitors line chart
- 30-day generations line chart
- Per-app revenue breakdown table
- Conversion funnel: Visitors → Generations → Paywall views → Checkouts → Purchases
- All data pulls from `/api/factory/snapshot/[slug]` per app

### 4. **Previews** — iframe grid of every live app
- Each live app rendered as a 380px-wide iframe at full UI
- "open" / "admin" / "↻ refresh" actions per preview
- "↻ Refresh all" button reloads every iframe

### 5. **Admin** — master operator console
Single password (`MASTER_PASSWORD` secret). 8 sections in left sidenav:
- **Overview** — portfolio health check + per-app row with live status
- **App Manager** — change any app's status (queue/build/live), export updated apps.js
- **Deploy / Rollback** — copy-to-clipboard `wrangler pages deploy` commands per app
- **Secrets & Bindings** — copy-to-clipboard secret-set commands per app for all 8 secrets
- **D1 Strategy** — three D1 path options visualized (reuse / recycle / upgrade)
- **Asset Bible** — link to ASSETS.md + summary
- **Deploy Logs** — placeholder for future Cloudflare API integration
- **Settings** — log out, view config

---

## Top hero bar (always visible)

- Brand mark + 5-tab nav (Grid / Console / Analytics / Previews / Admin)
- Pulsing "● LIVE" badge in nav bar
- 7 KPI cards: Apps Live · In Build · Queued · Revenue · MRR · Visitors/day · Generations/day
- "→ AppName" quick chips for every live app
- Last deploy timestamp + tutorial / asset bible links

KPIs auto-refresh every 60 seconds.

---

## Status of every component

| Component | URL | Status |
| --- | --- | --- |
| **Master Operator Console** | https://nr-money-factory.pages.dev | 🟢 LIVE |
| Roast My Website | https://nr-roastmywebsite.pages.dev | 🟢 LIVE |
| HookForge | https://nr-hookforge.pages.dev | 🟢 LIVE |
| MemeCannon | https://nr-memecannon.pages.dev | 🟢 LIVE |
| App Idea Validator | https://nr-idevalidator.pages.dev | 🔨 Build complete, awaiting deploy |
| LP Writer | https://nr-lpwriter.pages.dev | 🔨 Build complete, awaiting deploy |
| UGC Ad Generator | https://nr-ugcadgen.pages.dev | 🔨 In build |
| Discord Setup Wizard | https://nr-discordsetup.pages.dev | 🔨 In build |
| 92 more apps | (queued, see master grid) | ⚪ Queued |

---

## To enable real-time data flow

1. **Master grid secrets** are already auto-set during deploy:
   - `MASTER_PASSWORD` — for the Admin tab login (printed during setup)
   - `MASTER_SECRET` — HMAC cookie signing
   - `FACTORY_TOKEN` — bearer for talking to per-app snapshot endpoints
2. **Per-app secrets** still need:
   - `ANTHROPIC_API_KEY` — to enable AI generation
   - `STRIPE_SECRET_KEY` — to enable checkout
   - `STRIPE_WEBHOOK_SECRET` — to record payments
   - `ADMIN_PASSWORD` — per-app admin login
   - `ADMIN_SECRET` — per-app HMAC cookie signing
   - `FACTORY_TOKEN` — same as master for cross-app snapshot
3. **D1 binding** per app — pick one of 3 paths from Admin → D1 Strategy tab

The Admin tab provides copy-to-clipboard `wrangler pages secret put` commands for every secret on every app. Just click the codebox, paste your value when prompted.

---

## Asset Bible (for AM 2K-4K replacements)

Open `_BIBLE/ASSETS.md` — full list of every visual / motion / audio placeholder per app. Drop your finals at the listed paths with the listed filenames; no code changes needed.

---

## Rapid commands

```bash
# Deploy any app from its folder
cd NR-roastmywebsite
wrangler pages deploy public --project-name=nr-roastmywebsite --branch=main --commit-dirty=true

# Re-deploy master grid after editing apps.js / index.html / factory.js
cd OVERNIGHT_MONEY_APPS
wrangler pages deploy . --project-name=nr-money-factory --branch=main --commit-dirty=true

# Set a per-app secret
echo "your-key" | wrangler pages secret put ANTHROPIC_API_KEY --project-name nr-roastmywebsite

# View live tail of any app
wrangler pages deployment tail --project-name nr-roastmywebsite
```
