Skip to content

Commit 8140d7c

Browse files
Add deployment instructions for Zenith Offline Proof
Document the deployment process for the Zenith Offline Proof application, including steps for setup, testing, pushing to GitHub, and obtaining a public link.
1 parent be349d6 commit 8140d7c

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

‎deploy.md‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Getting this into GitHub and onto a link
2+
3+
## 1. Put the files in your repo
4+
5+
1. Unzip `zenith-offline-proof.zip` **over your repo folder** (the folder with `server.js` and `package.json`). Say yes to replace.
6+
2. The zip only contains files I changed or added. It does **not** contain `risk.js`, `package.json`, `.gitignore` or `public/lib/`, so those stay as they are.
7+
8+
| Replaced (same name) | New |
9+
| --- | --- |
10+
| `server.js`, `test.js`, `README.md` | `public/index.html` (landing page) |
11+
| `public/npp.js`, `merchant.js/html`, `bank.js/html`, `sw.js`, `style.css` | `public/dashboard.html`, `public/dashboard.js` |
12+
| | `docs/DEMO_SCRIPT.md`, `docs/DEPLOY.md` |
13+
14+
Nothing is deleted. The signed receipt format is unchanged, so overlap with what's on GitHub is just updated versions of the same files.
15+
16+
## 2. Check it works
17+
18+
```bash
19+
npm install
20+
npm test # should end with "tally tests passed" and "risk tests passed"
21+
npm start # http://localhost:9100
22+
```
23+
24+
## 3. Push to GitHub
25+
26+
```bash
27+
git status # review what changed
28+
git diff --stat
29+
git add -A
30+
git commit -m "Zenith Offline Proof: merchant-initiated tally, dashboard, offline allowance, branding"
31+
git push origin main
32+
```
33+
34+
This pushes to your fork (`lord-saviord1/offline-payment-proof`). If the submission needs the original repo, push there too, or open a pull request from your fork.
35+
36+
`data/` is gitignored, so keys and receipts never get committed.
37+
38+
## 4. Get a link
39+
40+
The camera and service worker need **HTTPS**, and the customer's phone needs a link it can open. `localhost` won't work for that, so you need a public address.
41+
42+
### Fastest: Cloudflare Tunnel (recommended for the demo)
43+
44+
Keeps the app on your laptop and gives it a public HTTPS URL. No account needed for a quick tunnel.
45+
46+
1. Install `cloudflared` (`brew install cloudflared`, or `winget install --id Cloudflare.cloudflared`, or the downloads page on Cloudflare's site).
47+
2. In one terminal: `npm start`
48+
3. In another: `cloudflared tunnel --url http://localhost:9100`
49+
4. It prints a `https://….trycloudflare.com` address. Open **that** address on both phones and the laptop.
50+
51+
The URL changes each time you restart the tunnel, and the laptop must stay on and connected. Open the merchant app through the tunnel URL on the merchant phone while online, so the QR links point to the public address.
52+
53+
### Stable: host it (Render, Railway or similar)
54+
55+
1. Create a new web service from your GitHub repo.
56+
2. Build command `npm install`, start command `npm start`.
57+
3. Set `OPERATOR_KEY` to something other than the default.
58+
4. If the host offers a persistent disk, mount it and set `DATA_DIR` to its path.
59+
60+
**Watch out:** on hosts without a persistent disk, a restart or redeploy creates a **new bank signing key** and clears receipts and dashboard data. Merchants then see "Bank key not stored" until they press **Update bank keys** while online. Free plans may also sleep and take a while to wake. Don't redeploy on demo day, and check the host's current free-tier terms.
61+
62+
### Why not a Cloudflare Worker?
63+
64+
A Worker isn't a Node server: it has no local disk and doesn't run this Express app as is. `server.js` stores its key and data in files, so it would need rewriting (routes and storage moved to something like KV, D1 or Durable Objects). That's a real rewrite, not worth it before a deadline. Cloudflare **Tunnel** (above) is a different product and works with the code unchanged.
65+
66+
## 5. Before the demo
67+
68+
- Load `/merchant.html` over the public link while online, press **Update bank keys**, then **Clear log**.
69+
- Turn airplane mode on only after that. Reloading offline works because the service worker cached the app.
70+
- Test the camera on the real phone over HTTPS, and keep the paste-the-code fallback in mind.
71+
- Change `OPERATOR_KEY` if the link is shared publicly.

0 commit comments

Comments
 (0)