Skip to content

Consumer Platform Rework: retire Streamlit, build advisory front-end - #56

Merged
digitalflanker-ux merged 10 commits into
mainfrom
rework/consumer-platform
Jun 28, 2026
Merged

Consumer Platform Rework: retire Streamlit, build advisory front-end#56
digitalflanker-ux merged 10 commits into
mainfrom
rework/consumer-platform

Conversation

@digitalflanker-ux

@digitalflanker-ux digitalflanker-ux commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Overview

Umbrella PR for the consumer platform rework — streamlining HRP into a product a non-technical owner can trust and use daily.

Locked direction:

  • Replace the 21-page Streamlit dashboard with a React/Next.js consumer app over a new HTTP/JSON API.
  • Moderate scope cut: keep the engine fully intact, trim the surface (delete only the Streamlit UI, dead scripts, and launcher sprawl).

This PR starts with the plan doc; subsequent commits land Phase 0 (cleanup & consolidation) on this branch.

What's here so far

  • docs/plans/2026-06-27-hrp-consumer-platform-plan.md — full plan including:
    • Engine-vs-cockpit strategic frame
    • Competitive teardown of The Assembly (assemblyprivate.com): module taxonomy, design language, strategic read
    • The Recommendation Output Contract (the product spec)
    • 5-view consumer app set, each mapped to existing hrp/advisory/ modules
    • Phased roadmap 0–5, incl. the key finding that no HTTP/JSON API exists yet (74 PlatformAPI methods, only ops/server.py serves HTTP)

Roadmap (this branch)

  • Plan doc
  • Phase 0 — dedupe scripts, collapse launchers into hrp start/status/stop/doctor, fix /doctor permission rule
  • Phase 1 — HTTP/JSON API
  • Phase 2 — Next.js consumer app
  • Phase 3 — retire Streamlit
  • Phase 4 — reliability polish
  • Phase 5+ — research modules

🤖 Generated with Claude Code

https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

digitalflanker-ux and others added 10 commits June 27, 2026 18:24
…ory front-end)

Strategic plan to streamline HRP for non-technical users: retire the
21-page Streamlit dashboard in favor of a Next.js consumer app over a new
HTTP/JSON API, with a moderate scope cut (keep the engine, trim the surface).

Includes a competitive teardown of The Assembly (assemblyprivate.com): module
taxonomy, the recommendation output contract, the 5-view consumer app spec, and
a phased roadmap (Phase 0 cleanup -> HTTP API -> Next.js app -> retire Streamlit
-> reliability polish -> research modules).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
…(Phase 0)

Unified front door for service management, wrapping scripts/startup.sh and
scripts/setup.sh. Non-destructive: existing launcher scripts remain in place
(they retire in Phase 3 alongside Streamlit). New subcommands sit beside the
existing job commands (run-now, list-jobs, job-status, clear-history); the new
`status` reports running services while `job-status` keeps reporting ingestion
history.

- hrp start [--full|--dashboard-only|--mlflow-only] -> startup.sh start
- hrp stop / restart / status                       -> startup.sh ...
- hrp doctor                                         -> setup.sh --check
- README: document the unified commands

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
New `hrp/api/http/` FastAPI layer exposing the advisory surface as JSON for the
consumer front-end. Implements the Recommendation Output Contract from the
rework plan (thesis / entry-target-stop / risks / provenance).

Endpoints (under /api, bearer-token optional via HRP_API_TOKEN):
- GET  /api/health
- GET  /api/recommendations           (conviction list; status/symbol/limit)
- GET  /api/recommendations/history
- GET  /api/recommendations/{id}       (full contract + provenance; 404 if absent)
- POST /api/recommendations/{id}/approve|reject
- POST /api/recommendations/approve-all
- GET  /api/portfolio                  (live positions + NAV)
- GET  /api/track-record               (win rate, returns, alpha by period)

- create_app() factory mirrors hrp.ops.server; run via `python -m hrp.api.http`
- Local-first auth: no token required unless HRP_API_TOKEN is set
- 17 tests via TestClient + dependency_overrides stub (DB-free)
- README + CLAUDE.md document the new service

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
…orts

Addresses the Phase 1 caveats.

Caveat 1 — column-drift bugs (grounded in real schema):
- portfolio: map live_positions.entry_price -> avg_cost (+ unrealized_pnl_pct)
- track-record: rebuild on real columns (profitable/unprofitable); derive
  win_rate and closed_recommendations

Caveat 2 — previously-deferred endpoints:
- GET/PUT /api/settings backed by the active user_profiles row (defaults when
  none; CSV-encodes excluded_symbols/sectors for the VARCHAR columns)
- POST /api/assistant/query: Claude grounded on the user's recommendations/
  portfolio/track-record; daily RateLimiter; 503 when ANTHROPIC_API_KEY unset,
  429 when the daily cap is hit

Caveat 3 — CLI import-heaviness:
- hrp/agents/__init__.py now exports lazily (PEP 562 __getattr__); importing the
  package no longer pulls the full ML/data stack
- cli.py imports heavy job/scheduler/platform modules inside handlers
- result: `hrp --help` and `hrp status/doctor` emit 0 DB-init lines
- CLI tests repointed to patch the source modules (where names now resolve)

23 HTTP API tests + all CLI tests pass; ruff/black clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
claude-sonnet-4-20250514 reached end-of-life (2026-06-15) and now 404s. Verified
end-to-end: POST /api/assistant/query returns a grounded answer with the daily
rate limit decrementing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
Dark editorial "members terminal" SPA (Next.js 16 + TS + Tailwind) consuming the
/api HTTP layer. Mirrors The Assembly's UX with HRP's validation provenance as
the differentiator.

Views: Conviction List, Recommendation dossier (thesis / entry-target-stop /
risks / validated provenance / approve-reject), My Portfolio (live NAV +
allocation + P/L), Track Record (win-rate/avg/excess), Vault Assistant (chat,
remaining_today, graceful 503/429), Settings (user_profiles-backed form).

- Typed API client (lib/api.ts) against the final contract; bearer token via
  NEXT_PUBLIC_API_TOKEN; base via NEXT_PUBLIC_API_BASE
- Live UTC clock, // NOT INVESTMENT ADVICE footer, loading/error/empty states
- fix: confidence is a categorical string (HIGH/MEDIUM/LOW), not a percentage
- `npm run build` passes clean

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
The Next.js app runs on a different origin (:3000) than the API (:8090), so
browser fetches require CORS. Adds CORSMiddleware (origins via
HRP_API_CORS_ORIGINS, default http://localhost:3000) + a regression test.
Verified end-to-end in a live browser walkthrough of all views.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
Don't leak raw Anthropic error text (billing message, request_id) to the
consumer. Log full detail server-side; return a generic 502 message. Adds a test
asserting the raw upstream text never reaches the response body.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
…Phase 3)

Removes the 21-page Streamlit dashboard now that the HTTP API (hrp/api/http)
and the Next.js consumer app (web/) cover the consumer surface.

Deleted (self-contained — zero production importers):
- hrp/dashboard/ (42 files, ~15.9k LOC)
- tests/test_dashboard/, tests/dashboard/, tests/test_e2e/test_dashboard_workflow.py

Dependencies:
- drop streamlit, plotly, streamlit-authenticator from pyproject (dashboard-only)

Rewire (dashboard service -> API server):
- scripts/startup.sh: replace start/stop_dashboard with start/stop_api
  (python -m hrp.api.http on :8090); --dashboard-only -> --api-only
- hrp/agents/cli.py: hrp start --dashboard-only -> --api-only
- scripts/open_hrp.sh ("Open HRP"): now starts the API + builds/serves the
  Next.js app and opens http://localhost:3000
- scripts/setup.sh: drop streamlit from verify; dashboard-auth phase -> API-access
  note (HRP_API_TOKEN); go_live/run_full_cycle/start_monitoring echoes updated
- README/CLAUDE.md/docs: dashboard/8501 -> API (:8090) + web app (:3000)

Test isolation fix (pre-existing, surfaced by the new API tests):
- tests/test_ops/conftest.py clears ambient HRP_THRESHOLD_* env (leaked from .env
  via hrp.utils.config load_dotenv) so threshold tests are order-independent

Verified: hrp start --api-only -> health 200 -> status -> stop; advisory+api+ops
sweep green; collection clean (3237 tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
CI (no .env) surfaced 3 order-dependent failures:
- test_smoke patched hrp.agents.cli.IngestionScheduler, which is now a lazy
  import inside the handler -> repoint to hrp.agents.scheduler.IngestionScheduler
- test_factory polygon tests set POLYGON_API_KEY via monkeypatch but the source
  reads get_config() (a cached singleton); when an earlier test cached it as
  None (CI has no .env), the patch was ignored -> reset_config() after setenv

Verified: all 3 pass without .env locally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
@digitalflanker-ux
digitalflanker-ux merged commit 99e0416 into main Jun 28, 2026
1 check passed
@digitalflanker-ux
digitalflanker-ux deleted the rework/consumer-platform branch June 28, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant