Overview
Version 1 · Initial project documentation, derived from repository inspection (server.js, raceView.js, db-config.js, setup-auth.js, run.bat, package.json, git history)
Purpose
A single-page web dashboard for reviewing one date's race meetings at a glance: a grid of meeting x race number, colored/badged to surface data problems before race day (missing or duplicate jockeys, missing trainers, bad/duplicate tab numbers, bad or clashing scheduled times, abandoned meetings). Clicking a race cell shows full runner-level detail in a popup. Built for Thoroughbred, Harness, and Greyhound meetings (shown as separate tabs).
Repository: https://github.com/QuantumDataGroup/Race-Day-Dashboard.git
Architecture
- Backend: Node.js + Express (
server.js). Reads race/meeting documents from MongoDB and renders server-side HTML (no client framework, no build step). - Core logic:
raceView.jsis deliberately kept free of the MongoDB driver and Express so it stays plain-data-in/HTML-string-out and trivially unit-testable. It builds the per-discipline schedule, computes every "issue" flag (missing/duplicate jockey, tab-number problems, missing trainer, bad schedule time), and renders the dashboard/login pages by filling{{PLACEHOLDER}}tokens in static HTML templates (views/dashboard.html,views/login.html) with the dynamic fragments (meeting rows, discipline tabs, country options, etc.) it builds from the DB data. - Styling: all CSS lives in
public/styles.css, served statically by Express (express.static) rather than embedded in the JS. - Data: MongoDB
racesandmeetingscollections, read-only. Connection string comes from an externaldb.jsonconfig file (same format/loader used by other QDG tools), never committed to the repo. - Auth: a single shared username/password (bcrypt-hashed) protects only the
/dashboard route via an Express session cookie; report downloads,/api/race/:id, and/healthare intentionally left open.
Components
| File | Role |
|---|---|
server.js |
Express app: routes, MongoDB queries/projections, session/login, CSV/XLSX/PDF report generation (via exceljs/pdfkit) |
raceView.js |
Pure logic: schedule building, issue detection, HTML rendering (unit-testable, no DB/Express dependency) |
db-config.js |
Shared loader for the external MongoDB config file/connection string, also used by other QDG CLI tools against the same DB |
setup-auth.js |
One-time/rerunnable CLI (node setup-auth.js) to set the dashboard's shared username/password; writes only a bcrypt hash, never the plaintext, to a config file outside the repo |
views/dashboard.html, views/login.html |
Static HTML page skeletons with {{PLACEHOLDER}} tokens, filled in by raceView.js |
public/styles.css |
All page CSS, served statically |
run.bat |
Windows launcher: installs npm deps if missing, starts server.js in its own console window, opens the dashboard in Chrome (or default browser) |
Development
- No test suite or
testscript currently exists inpackage.json. raceView.js's DB/Express-free design is intentional so its schedule-building and issue-flagging logic can be exercised with plain sample data.- Config paths (
DB_CONFIG_PATH,AUTH_CONFIG_PATH) default to files underC:\Users\Dinesh\projects-config\, outside the project folder, so credentials are never at risk of being committed.
Operations
Key environment variables (all optional, with defaults baked into server.js):
PORT(default3000)DB_CONFIG_PATH(defaultC:\Users\Dinesh\projects-config\db.json)AUTH_CONFIG_PATH(defaultC:\Users\Dinesh\projects-config\auth.json)DB_CONNECTION_NAME(defaultmongodb-prod) -- selects which named entry indb.jsonto use
Main endpoints:
GET /(login required) -- the dashboard grid; query params?date=YYYY-MM-DDand?includeTrials=trueGET /login,POST /login,GET /logout-- shared single-account session loginGET /api/race/:id-- runner-level detail for one race, as JSON (open, no login)GET /report.{csv,xlsx,json,pdf}?date=...-- cross-discipline issues report for one date (open)GET /meeting-report.{csv,xlsx,json,pdf}?date=...&meeting=...&country=...&discipline=...-- full race+runner detail for one meeting (open)GET /health-- DB connectivity check (open)
Until node setup-auth.js has been run once on the host machine, nobody can log in (the server
still starts and /health still works).