Log Challenge
A support-engineer debugging exercise: a Datadog-style Lucene log search UI plus a read-only SQL database browser, both running entirely client-side against a SQLite file. Built with Vite; deployed to GitHub Pages via GitHub Actions.
The app has three tabs: Challenge (the brief — send candidates to the deployed site, they land here), Log Explorer, and Database Admin.
The answer key lives at answers.html — a separate page that nothing in the app links to. Don’t add a link to it from index.html/src/* and don’t share that URL with whoever is taking the challenge. It’s committed (so it travels with the repo and stays in sync with the generated data) but kept out of the candidate-facing surface — it’s noindex’d and reachable only if you type the path.
How it works
- Data:
public/data.db is a plain SQLite database with four tables — users, accounts, transactions, logs — generated by data/build_db.py (stdlib-only Python, deterministic seed). It also embeds several deliberate “incidents” that the tickets in the Challenge tab (src/app/challenge.js) are built around (declined charge, duplicate charge, account lockout, an unhandled-exception stack trace, a “silent failure” with no error log, and a systemic outage window).
- Runtime: the browser loads
data.db with sql.js (SQLite compiled to WebAssembly) and runs actual SQL against it in memory — nothing is written back, and the connection is opened with PRAGMA query_only = ON as a second line of defense on top of the UI’s statement allowlist.
- Challenge (
src/app/challenge.js): the ticket brief, rendered in-app — static content, no DB dependency.
- Log Explorer (
src/app/logs.js + src/app/lucene.js): a hand-rolled Lucene/Datadog-style query parser (field:value, quoted phrases, wildcards, AND/OR/NOT, parentheses, numeric ranges/comparisons) filters the logs table client-side, plus a facet sidebar (service, level, time range) and a detail panel with clickable IDs that jump to the matching row in Database Admin or re-scope the search to a trace_id.
- Database Admin (
src/app/dbadmin.js): table/schema browser and a SQL box restricted to SELECT / WITH / EXPLAIN, with a live-highlighted editor (real Shiki syntax highlighting, see src/app/highlight.js).
Local development
Requires Node 20+.
npm install
npm run dev # dev server with hot reload, http://localhost:5173
npm run build # production build → dist/
npm run preview # serve the dist/ build locally, to sanity-check before pushing
Regenerating the database
npm run gen-db # same as: python3 data/build_db.py — writes public/data.db
Re-running is deterministic (fixed random seed), so the ticket text in src/app/challenge.js and the walkthroughs in answers.html (usernames, merchants, IDs, approximate dates) stay valid as long as the generator itself isn’t edited. If you do edit it, double-check those two files still match — nothing enforces that automatically.
Deploying to GitHub Pages
Handled by .github/workflows/deploy.yml: every push to main runs npm ci && npm run build and publishes dist/ via GitHub’s official Pages Actions (configure-pages / upload-pages-artifact / deploy-pages). One-time setup on a new repo: Settings → Pages → Source → GitHub Actions (not “Deploy from a branch”).
Since GitHub Pages serves the whole build output, answers.html will be publicly reachable at <your-pages-url>/answers.html even though nothing links to it — that’s obscurity, not access control. If you want a harder guarantee that the candidate can’t stumble onto it, keep the repo private (Pages on a private repo needs GitHub Pro/Team/Enterprise), or ask for a stricter gate (e.g. a passphrase check) before pushing.
Project structure
index.html Vite entry — app shell (Challenge / Log Explorer / Database Admin)
answers.html Vite entry — private answer key, unlinked from the app, don't share
vite.config.js multi-page build config, relative base for GH Pages subpath hosting
package.json scripts + dependencies (vite, shiki, sql.js)
.github/workflows/deploy.yml build + deploy to Pages on push to main
src/
app/
main.js app bootstrap, tab navigation
util.js small DOM/formatting helpers
db.js sql.js bootstrap + query helpers
lucene.js Lucene-style query parser/evaluator
highlight.js Shiki SQL highlighter (shared by the app + answers.html)
challenge.js Challenge tab (ticket brief)
logs.js Log Explorer tab
dbadmin.js Database Admin tab
answers-main.js entry for answers.html
styles/
style.css app styling
answers.css answers.html-only styling
public/
data.db generated SQLite database (committed, copied as-is into the build)
data/
build_db.py mock data generator
评论