You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b2f4057
Browse filesBrowse the repository at this point in the historyBrowse files
OpenNext + wrangler config, Hyperdrive pg per request on Workers, KYC files to R2 (still AES-256-GCM), PGlite excluded from the Worker bundle, db:migrate script and idempotent db:seed, README Deploy section.
Copy file name to clipboardExpand all lines: README.md
+29-2Lines changed: 29 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,12 +60,39 @@ pnpm dev # http://localhost:3000 (next dev --webpack)
60
60
```
61
61
62
62
- The database is PGlite, a file at `./.data/pglite`. It migrates and seeds the demo business on first start. Set `DATABASE_URL` to use a real Postgres instead.
63
-
- `pnpm db:seed` deletes and re-creates the demo business. Owners can also reset it from **Settings**.
63
+
- `pnpm db:seed` seeds the demo business if it is missing (safe to run twice); `pnpm db:seed -- --reset` deletes and re-creates it. Owners can also reset it from **Settings**.
64
+
- `pnpm db:migrate` applies the committed SQL migrations to `DATABASE_URL`.
64
65
- KYC files go to `./.data/uploads`, encrypted with AES-256-GCM (key from `KYC_KEY` or `SESSION_SECRET`).
65
66
- QR codes and WhatsApp links use `APP_URL` (`https://nestkeep.craftlayer.store` in production, `http://localhost:31NN` in dev).
66
67
- Checks: `pnpm typecheck && pnpm lint && pnpm test && pnpm build`, then `pnpm exec astryx doctor --built .next`.
67
68
- `pnpm db:generate` writes a new SQL migration after a schema change (`src/server/db/migrations`, committed).
68
69
70
+
## Deploy (Cloudflare Workers)
71
+
72
+
Production runs on Cloudflare Workers via [OpenNext](https://opennext.js.org/cloudflare) at `https://nestkeep.craftlayer.store`. Config: [`wrangler.jsonc`](wrangler.jsonc), [`open-next.config.ts`](open-next.config.ts).
DATABASE_URL=postgres://... pnpm db:seed # seed the demo business, idempotent
77
+
pnpm cf:build # OpenNext build into .open-next/
78
+
pnpm cf:preview # build and run locally in workerd
79
+
pnpm cf:deploy # build and deploy
80
+
pnpm cf-typegen # regenerate cloudflare-env.d.ts
81
+
```
82
+
83
+
| Kind | Name | Purpose |
84
+
|---|---|---|
85
+
| Binding | `HYPERDRIVE` | Postgres (Neon) via Hyperdrive. A `pg` pool is created per request. Replace `REPLACE_WITH_HYPERDRIVE_ID` in `wrangler.jsonc` |
86
+
| Binding | `UPLOADS` | R2 bucket `craftlayer-uploads`. KYC files, AES-256-GCM encrypted, keys under `nestkeep/`. Served only through staff-authorised routes |
87
+
| Binding | `ASSETS` | Static assets from `.open-next/assets` |
88
+
| Binding | `WORKER_SELF_REFERENCE` | Service binding to itself (OpenNext) |
89
+
| Var | `APP_URL` | `https://nestkeep.craftlayer.store`, used in QR codes and WhatsApp links |
90
+
| Var (optional) | `DEMO_MODE` | `1` shows OTPs on screen (demo only) |
| Secret | `KYC_KEY` | Recommended. Key source for KYC file encryption. Must never change once files exist |
93
+
94
+
On Workers the app does not migrate or seed at runtime, writes nothing to the filesystem, and never loads PGlite (the Cloudflare build aliases it away). Rate limits are in memory per isolate.
95
+
69
96
## Demo walkthrough
70
97
71
98
| Step | Where | What happens |
@@ -102,7 +129,7 @@ pnpm dev # http://localhost:3000 (next dev --webpack)
Integrations are adapters: WhatsApp (`src/server/adapters/messaging.ts`) writes to an `outbox` table; payments (`adapters/payments.ts`) build `upi://pay` links; documents (`adapters/storage.ts`) are local encrypted files. No real API keys and no third-party network calls.
132
+
Integrations are adapters: WhatsApp (`src/server/adapters/messaging.ts`) writes to an `outbox` table; payments (`adapters/payments.ts`) build `upi://pay` links; documents (`adapters/storage.ts`) are AES-256-GCM encrypted files on local disk, or in R2 on Cloudflare Workers. No real API keys and no third-party network calls.
0 commit comments