Public
NDX internal job production, labor, equipment, and cost dash
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

Production Command Center — Val Town migration

A Val Town-native rebuild of the NDX Production Command Center. Cloudflare Next.js/Vinext has been replaced with Hono (routes) + a client-side React frontend. Cloudflare D1 → this val's scoped SQLite. Cloudflare R2 → this val's scoped Blob Storage.

Phase status: Phase 2 — non-Monday dashboard features complete. Auth, roles, the full dashboard (jobs, rates, Vista/BusyBusy imports, cost consolidation, equipment/crew/phase views, equipment moves, reports), and permanent job storage are implemented and tested. Monday.com remains disconnected. No production job data is loaded.

Try it

Sign in with the existing administrator account. Every dashboard page and data API requires authentication.

Architecture

Rendering mermaid diagram...

Files

index.ts                  ← Hono HTTP entrypoint (auth + jobs + data + files + rates)
db.ts                     ← SQLite migrations (users, sessions, jobs, rates, data, Monday, files)
auth.ts                   ← PBKDF2 hashing, HTTP-only session cookies, role middleware
equipmentRates.ts         ← Equipment rate book (source of hourly operating rates)
frontend/
  root.tsx                ← HTML shell (stamps immutable asset URLs)
  index.tsx               ← React entrypoint
  App.tsx                 ← Auth + jobs, rates, imports, cost/equipment/report views
  styles.css              ← NDX black/white/red interface

Auth model

  • Email + password login (PBKDF2-SHA256 hashed, per-user salt).
  • HTTP-only, Secure, SameSite=Lax session cookie (pcc_session), token hashed in DB, 30-day expiry.
  • Approved-email allowlist (approved_emails) with admin / user roles. Admins manage jobs; both may view/enter data.
  • Every data API requires auth (requireAuth); job create/edit/delete also requires requireAdmin.

Administrator password recovery

A "Forgot password?" link on the sign-in screen opens a recovery form. To reset an administrator password you need the administrator email, the recovery code, and a new password entered twice.

  • The recovery code is read only from the ADMIN_RECOVERY_CODE environment variable — it is never hardcoded, displayed, or logged.
  • The new password is hashed with the same PBKDF2 system used for sign-in.
  • On success all of that administrator's sessions are invalidated (signed out).
  • The email + code combination is validated with a timing-safe comparison and failures return a generic message (no user-enumeration).
  • No default password or hardcoded secret is used.

👉 Add ADMIN_RECOVERY_CODE here: https://www.val.town/x/wnewton/production-command-center/environment-variables?key=ADMIN_RECOVERY_CODE

Phase 2 — implemented & tested

  • Jobs — create, select (top bar), edit, delete (cascades data, rates, files, blobs).
  • Per-job labor / operator / foreman rates — saved per job with standard defaults.
  • Vista TXT target import — browser-side CSV parsing, targets stored in the job's production map, original saved to Blob.
  • BusyBusy Excel import — SheetJS in the browser; actual costs per cost code, equipment usage, crew size, phase-code breakdown, equipment moves. Original saved to Blob.
  • Cost-code consolidation — first-4-digit grouping (1201.2 + 1201.3 → 1201), toggle in the cost-code table.
  • Equipment usage / crew size / phase-code views — most-used equipment, crew-by-workday, expandable per-phase detail.
  • Equipment moves (phase 1101) — equipment moved, move hours, driver labor cost, hauling truck cost, total; no charge for the transported machine.
  • Manual production + cost per unit — enter quantities per cost code; actual vs. Vista target unit cost.
  • Reports + print/PDF — executive report cover, top cost codes, print stylesheet.
  • Permanent storage — job data in SQLite, original uploads in Blob Storage keyed by job.

Monday.com: disconnected. The Utility Schedule import is deferred to Phase 3.

Monday.com (Utility Schedule)

  • Server-side integration in monday.ts using Deno.env.get("MONDAY_TOKEN"). The token is never returned, logged, or sent to the browser.
  • Board discovery by name (or MONDAY_BOARD_ID env), column mapping from the board's own metadata, imports only Utility Schedule items, and ignores every item in a group whose normalized name is "Completed" / "Completed.".
  • Each synced job stores a permanent monday_item_id (migration 0003, unique index), so refreshes update existing jobs instead of duplicating. Manually created jobs are never touched.
  • The Refresh button is functional (admin only): POST /api/monday-refresh imports, writes a snapshot to monday_snapshots, and returns added / updated / completed-ignored / last-refresh. Errors are generic and never reveal credentials.
  • Status is surfaced in the monday strip and the Migration checklist.

Status: the connection/error path is verified reachable and safe. The currently configured MONDAY_TOKEN is rejected by Monday (HTTP 401 — invalid or expired), so no jobs have been imported yet. To complete the live sync, replace the token with a valid Monday personal API token and click Refresh.

Remaining

  • Replace MONDAY_TOKEN with a valid token, then click Refresh to import the Utility Schedule (the write/import path is implemented but not yet executed against live data).
  • Optionally re-import the tail of the equipment-rate PDF (the migration source was truncated at entry 5103, so equipmentRates.ts carries 96 records; some small-tool entries may be missing).

Secrets

The val injects its own API token; no valtown env var is needed. The credentials used are MONDAY_TOKEN (server-only) and ADMIN_RECOVERY_CODE.

👉 Add MONDAY_TOKEN here: https://www.val.town/x/wnewton/production-command-center/environment-variables?key=MONDAY_TOKEN

Safety

  • Monday.com token (when added) stays server-side only.
  • All reads/writes/uploads are authenticated; uploaded file type + size validated.
  • Parameterized SQL throughout.
  • The live hosted Command Center is untouched.