Thanks for your interest in contributing — this file explains how to work with the frontend (static site) and the Cloudflare Worker backend in this repository.
Project layout (short):
index.html,app.js,styles.css— frontend static UI and preview.data/— device and country presets (devices.js,countries.js).worker/— Cloudflare Worker source and config (wrangler.toml,package.json,src/).
- Fork the repo on GitHub and clone your fork locally.
- Create a branch with a descriptive name, e.g.
feat/add-device-presetorfix/svg-rendering.
git checkout -b feat/your-featureThe frontend is a static site — no build step required. Two quick options:
- Open
index.htmlin your browser. - Or run a simple static server from the project root:
# using npm package 'serve' (install globally or use npx)
npx serve .
# open http://localhost:3000The UI loads presets from data/devices.js and data/countries.js.
The worker lives in the worker/ folder and uses Cloudflare Wrangler. The worker code sends back SVG/PNG images generated by worker/src/*.js and uses @resvg/resvg-wasm for rasterization.
Prerequisites:
- Node.js and npm
- Cloudflare Wrangler CLI (
npm install -g wrangler) or usenpx wrangler
Typical workflow:
cd worker
npm install
# run locally (wrangler will emulate the Worker)
npm run dev
# or: npx wrangler dev
# deploy (requires Cloudflare account + secrets configured)
npm run deploy
# or: npx wrangler deployYou can exercise the worker with the /generate endpoint. Example:
GET /generate?country=us&type=year&bg=000000&accent=FFFFFF&width=1179&height=2556
Tip: worker/wrangler.toml includes the main = "src/index.js" entry and a build.command used by Wrangler.
data/devices.js: add or update device objects (name, width, height, dpi). Follow existing format and keep entries sorted when possible.data/countries.js: timezone / country presets. Ensure ISO codes match the API usage.
When changing presets, verify the UI loads them and the preview renders correctly (open index.html).
- Main entry:
worker/src/index.js - Utilities:
worker/src/timezone.js,worker/src/validation.js - SVG generation helpers:
worker/src/svg.jsandworker/src/generators/*.js
If you modify the worker, test locally via npx wrangler dev and validate responses (SVG or PNG) using curl or the browser. Example:
curl "http://127.0.0.1:8787/generate?country=us&type=year&width=1179&height=2556" --output sample.pngThere is no centralized test runner configured in the repository currently. If you add tests, include a top-level test script in worker/package.json or a root package.json and document how to run them in this file.
- Branch name describes the change (use
feat//fix//docs/). - Description explains the problem and solution.
- Small, focused commits with clear messages.
- Update
data/orREADME.mdif relevant. - If you touched the worker, verify
npx wrangler devand the/generateendpoint work.
Use the issue templates in .github/ISSUE_TEMPLATE/ (Bug, Feature, Good First Issue). A high-quality issue usually includes:
- Short title and description
- Steps to reproduce or sample URL for the
/generateendpoint - Expected vs actual behavior
- Screenshots, logs, or example params
Suggested labels: good first issue, help wanted, area: frontend|worker|data|docs, difficulty: easy|medium|hard.
- Keep changes small and focused.
- Follow existing JS style (ES modules, descriptive names).
- Add inline comments for non-obvious algorithmic code (especially in generators).
- When editing SVG output, include visual examples/screenshots in the PR description.
- Do not commit API keys or Cloudflare secrets. Use Wrangler secrets for deployment.
# to set a secret
npx wrangler secret put MY_SECRETBe respectful and follow CODE_OF_CONDUCT.md. If you have questions, open an issue and mention a maintainer.
Thanks for helping improve LifeGrid — every contribution is appreciated.