This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm start # production
npm run dev # development with auto-reload (node --watch)No build step. No tests. No linter configured.
Single-file Express backend (server.js) serving a plain HTML + vanilla JS frontend (public/). No framework, no bundler, no TypeScript.
Data flow:
server.jsconnects to MongoDB (spk-encoder-gatewaydb) on startup viamongoose.createConnectionGET /api/reportandGET /api/report/markdownboth callbuildReport(from, to), which runs a MongoDB aggregation onembed-jobsjoined withembed-encodersviaassignedWorker→name- Only community encoders (
embed-encoders.access === 'community') and the Butter encoder (name === 'Butter', hive account hardcoded asjoseamenac) are included — all other managed encoders are excluded buildMarkdown(report)renders the Hive post body as a markdown stringPOST /api/post-reportgenerates the report and posts to Hive server-side using@hiveio/dhivewith theHIVE_POSTING_KEYfrom env- A
node-cronjob fires every Sunday at midnight UTC to auto-post last week's report - The frontend (
public/app.js) can also publish via Hive Keychain browser extension usingwindow.hive_keychain.requestPost
Key constraints:
- Beneficiaries must be sorted alphabetically (Hive protocol requirement) — enforced in
buildReport - Beneficiaries capped at 8 accounts; weights computed from
completedjobs only; normalised to exactly 10000 total - ISO week math is duplicated between
server.jsandpublic/app.js(intentional — no shared module) - MongoDB field names in
embed-jobs:createdAt(date range filter),assignedWorker(join key),status('completed'|'failed'|'error'),assignedAt,webhookReceivedAt(duration) - MongoDB field names in
embed-encoders:name(join target),access('community'for community nodes),hiveAccount,displayName
MONGODB_URI= # required — MongoDB connection string
ENCODER_DB_NAME= # optional, default: threespeak
PORT= # optional, default: 3000
HIVE_POSTING_KEY= # WIF private posting key (required for server-side post + cron)
HIVE_POST_AUTHOR= # Hive account to post as (required for server-side post + cron)
HIVE_POST_COMMUNITY= # optional community tag (e.g. hive-181335)
HIVE_POST_TAGS= # optional, default: encoding,threespeak,hive,decentralization
Two paths:
- Browser (Hive Keychain) — "Post with Hive Keychain" button in the UI; requires the Keychain browser extension; signing is client-side
- Server-side — "Post via Server Key" button or the Sunday cron; uses
@hiveio/dhivewithHIVE_POSTING_KEY;comment_optionswith beneficiaries is passed viaclient.broadcast.commentWithOptions
The cron only fires if both HIVE_POSTING_KEY and HIVE_POST_AUTHOR are set; otherwise it logs a warning and skips.