Development
Run Helpdear locally, run the tests, and find your way around the code.
Run it locally
You need Node.js 24.
git clone https://github.com/onmyway133/helpdear.git
cd helpdear
npm install
cp .dev.vars.example .dev.vars # set ENCRYPTION_KEY to any random string
npm run dev # http://localhost:5173
node scripts/seed.mjs # optional: demo conversations, articles and ideasnpm run dev runs the Worker, the Durable Object and a local D1 database in workerd through
Vite. The dashboard is at /admin, the public pages at /, and the widget at /widget.js.
To try the widget on another site, put the embed code from Settings → Websites in any HTML file and serve it from another port.
Check your work
npm run check # TypeScript and the tests
npm run build # the production buildTests run the whole Worker against an in-memory SQLite database shaped like D1, with no mocks of the database.
Layout
| Folder | What's there |
|---|---|
src/worker/ | The Worker: app.ts has the routes, index.ts the Cloudflare entry, services.ts reads bindings |
src/worker/conversations/ | Conversations, messages, and what happens after people write (hooks.ts) |
src/worker/visitors/ | Contacts, visitor tokens, page views and identity |
src/worker/email/ | Sending, the outbox, notifications and inbound email |
src/worker/realtime/ | The Durable Object that pushes live updates |
src/worker/portal/ | The public help center, feedback, roadmap and changelog pages |
src/worker/mcp/ | The MCP server |
src/app/ | The dashboard (React) |
src/widget/ | The chat widget's iframe app (React); public/widget.js is the loader |
src/shared/ | Types and logic used by both sides |
migrations/ | The database schema, applied by the Worker on the first request |
test/ | Tests |
Rules worth knowing
- A schema change is a new file in
migrations/plus the same change insrc/worker/db/schema.ts;test/schema.test.tschecks they match. - Route code reads bindings only through
c.var.services. - Installs keep their own
wrangler.jsoncwhen they update, so new code must work without a binding that's added later.