DRNX — Cloudflare deployment guide

Version 1.0.0 · engine 1.0.0 · .drnx schema 1.0.0


1. What gets deployed

DRNX is a single-file application. All engineering logic — hydrology, hydraulics, pipe sizing, technical drawing, PDF generation and exports — runs in the browser. Cloudflare Pages only serves static files.

The consequence: there is no application server, no build step, and no npm dependencies in production. Deployment means copying a directory.

The Workers layer (Stage E) is optional and exists solely to bypass CORS when fetching DTM tiles and to share projects. The application is fully functional without it.


2. Package contents


drnx/
├── index.html              ← THE ENTIRE application (no dependencies, no CDN)
├── _headers                ← security headers (CSP, COOP/COEP, HSTS)
├── _redirects              ← SPA redirects
├── wrangler.toml           ← Pages configuration
├── wrangler.worker.toml    ← Worker configuration (Stage E)
├── package.json            ← npm scripts (optional)
├── profiles/
│   ├── PL-2026.json        ← Polish normative profile (editable)
│   └── DE-2026.json        ← German normative profile (editable)
├── worker/
│   ├── index.ts            ← tile proxy + project sharing
│   └── schema.sql          ← D1 database schema
└── docs/                   ← documentation (PL/EN)

3. Prerequisites

ItemRequirement
Cloudflare accountthe free plan is sufficient for Pages
Node.js≥ 18 (only to run wrangler)
Wrangler CLInpm install -g wrangler
Paid Workers planonly if you want Stage E (R2 + KV + D1)

4. Basic deployment (Pages) — three commands


cd drnx
wrangler login
wrangler pages deploy . --project-name drnx

Wrangler returns an address such as https://drnx.pages.dev. The application is ready to use.

Git repository variant


5. Verifying the deployment

Open the address and run, in order:

Expected result: 22/22 tests passing, including a scale-fidelity measurement taken on the generated PDF within a ±0.1 % tolerance.


6. Custom domain


wrangler pages deployment list --project-name drnx

Then in the dashboard: Pages → drnx → Custom domains → Set up a domain. Cloudflare issues the TLS certificate automatically.


7. Stage E — Worker, R2, KV, D1 (optional)

Requires a paid Workers plan.


# 1. Resources
wrangler r2 bucket create drnx-tiles
wrangler r2 bucket create drnx-projects
wrangler kv namespace create META          # record the returned id
wrangler d1 create drnx                    # record the returned database_id

# 2. Fill the identifiers into wrangler.worker.toml

# 3. Database
wrangler d1 execute drnx --file worker/schema.sql

# 4. Deploy the Worker
wrangler deploy --config wrangler.worker.toml

# 5. Check
curl https://drnx-proxy.<your-account>.workers.dev/health
# expected: {"ok":true,"role":"proxy-only"}

If you serve the Worker from a domain other than *.workers.dev, add that origin to the connect-src directive in _headers.


8. Configuring normative profiles

The files in profiles/ are editable without touching code. After every change, recompute the checksum:


python3 -c "import json,hashlib; \
p=open('profiles/PL-2026.json').read(); d=json.loads(p); \
d['sha256']=hashlib.sha256(p.encode()).hexdigest(); \
open('profiles/PL-2026.json','w').write(json.dumps(d,indent=2,ensure_ascii=False))"

The checksum is carried into the computation report and guarantees auditability: it is always clear which version of the rules produced a given result.


9. Troubleshooting

SymptomCauseRemedy
Blank page_redirects was not deployedConfirm the file sits in the root, with no extension
Map does not renderCanvas had zero size at startupSwitch tabs or resize the window
PDF lacks Polish diacriticsDeliberate simplification — Helvetica, WinAnsiCharacters are transliterated; font embedding is a scope change
wrangler: command not foundNot installed globallynpm install -g wrangler
Worker returns 403Host not on the allowlistAdd the host to ALLOWLIST in worker/index.ts
Worker returns 429600 requests/min per IPAdjust the RATE_PER_MINUTE constant

10. Privacy and security