Skip to content

feat(gain): --web flag — local dashboard server #162

Description

@thehoff

Background

The natural extension for contextcrawler analytics is a local web UI that renders the data already in history.db instead of (or alongside) the CLI text output.

Pairs naturally with #158 (gain --insights) — the insights become dashboard cards.

Problem

gain, gain --weak-filters, gain --insights, gain --history all return text or JSON to the terminal. For glanceable per-day / per-tool / per-boundary trend views, a web dashboard is the right surface:

Proposed Design (clean-room)

New flag: contextcrawler gain --web [--port <N>] [--no-browser].

contextcrawler gain --web              # boots server on a free port + opens browser
contextcrawler gain --web --port 8765  # explicit port
contextcrawler gain --web --no-browser # no auto-open (for ssh/remote use)

Behaviour:

  1. Bind a tiny HTTP server (tiny_http crate, ~300KB; or hyper with rustls if we want HTTPS later) on the chosen port
  2. Serve a single-page HTML app from embedded assets (rust-embed pattern)
  3. Page hits JSON endpoints backed by the existing Tracker query functions:
  4. Auto-shutdown after 1h of inactivity (don't leave a server running)
  5. Read-only — no DB writes from the web UI. No auth (binds to 127.0.0.1 by default)

Frontend: minimal vanilla JS + a small chart lib (Chart.js inlined, or roll a 50-line SVG sparkline). No build pipeline; one self-contained HTML file embedded via include_str!. Left-side menu, scalable card layout.

Why now

Effort

M (1 week)

  • HTTP server + asset embedding: 1 day
  • 6 API endpoints: 1 day
  • Frontend HTML + JS + charts: 2-3 days
  • Tests (route handlers, JSON shape, inactivity shutdown): 1 day
  • Doc + screenshot in README: half day

Out of scope (v1)

  • Auth / HTTPS / cross-machine access (lab-only profile, 127.0.0.1 binding only)
  • Persistent server / daemon mode (autoshutdown handles this)
  • Realtime updates / SSE / WebSockets — polling is fine for a single-user local dashboard
  • Cross-machine federation (e.g. aggregating multiple developers' DBs)
  • Theme customisation
  • Auth integration with any external dashboard host (potential future hook — left-side menu plug-in)

Dependencies

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions