BTC
24h
+2.40%

Documentation

Architecture, metrics, and how to extend.

v1.0 · 9 sections

Bitcoin Value OS

A research-and-education terminal for understanding Bitcoin's value. Not financial advice.

What this app is

Bitcoin Value OS combines three lenses:

  1. Bloomberg-style terminal — dense, monospaced metrics across market, on-chain, macro, and institutions.
  2. Glassnode-style on-chain analytics — MVRV, SOPR, realized cap, HODL waves, supply distribution.
  3. Perplexity-style AI research — ask any question and get a structured answer with bull case, bear case, and risks.

It also includes a Workspace mode (Notion-style) for notes, watchlists, prompt libraries, and research dossiers.

Architecture

src/
  routes/        TanStack file-based routes (terminal + workspace + api/chat)
  components/    layout, charts, ai
  dal/           Data Access Layer
    types.ts     Zod schemas (single source of truth)
    interfaces.ts repo interfaces (IMarketRepo, IOnChainRepo, ...)
    mock/        mock implementation (5y synthetic series + seed records)
  hooks/         React Query wrappers around the DAL
  lib/           ai-gateway.server, tenant, format

SOLID

  • Single Responsibility — each repo handles one domain; components are split into presentational and container hooks.
  • Open/Closed — repos sit behind interfaces; swap mock for a real API without touching pages.
  • Liskov / Interface Segregation — narrow per-domain interfaces.
  • Dependency Inversion — pages depend on hooks → hooks depend on repo interfaces → factory chooses the implementation.

Multitenant

A tenantId (default "default") is resolved from localStorage and threaded into every repo call and every React Query key, so tenant data never mixes. Workspace records (notes, watchlists, dossiers, prompts) are persisted under the key bvos:{tenantId}:{kind}.

Switch tenant in Settings → Tenant.

Validation, dates, async UX

  • All schemas validated with Zod (src/dal/types.ts).
  • All dates formatted with date-fns (src/lib/format.ts).
  • All async flows follow: skeleton → fetch → try/catch → sonner feedback with severity (info / success / warning / error).

AI assistance

The assistant is powered by Lovable AI Gateway.

  • Backend boundary: src/routes/api/chat.ts — a TanStack server route using streamText and google/gemini-3-flash-preview.
  • Frontend: @ai-sdk/react's useChat + DefaultChatTransport rendering streamed markdown.
  • The AI Ask button (top bar) opens a global chat sheet on any page.
  • The Research AI page is a full-page chat with example prompts.
  • The assistant is instructed to structure analytical answers as: Summary, Bull, Bear, Risks, Confidence, Sources.

Metrics glossary

  • MVRV (Market Value to Realized Value) — ratio of market cap to realized cap. High = profit; low = capitulation.
  • SOPR (Spent Output Profit Ratio) — average profit ratio of coins moved on chain. >1 = realizing profit; <1 = realizing loss.
  • Realized Cap — sum of coin values at last-moved price; a "cost basis" of the network.
  • Hash Rate — total computational power securing the network; a proxy for miner conviction.
  • Difficulty — mining target; adjusts every ~2 weeks toward 10-minute blocks.
  • HODL Waves — % of supply by age band; long bands rising = accumulation.
  • Dominance (BTC.D) — BTC market cap as % of total crypto.
  • DXY — US dollar index vs major currencies; inversely correlated with BTC in liquidity-driven regimes.
  • M2 — broad money supply; rising M2 historically correlates with rising BTC over multi-year periods.

Pages

  • Dashboard — high-level vitals + AI Daily Summary.
  • AI Daily Brief — one-click AI-generated morning research note. Snapshots price, on-chain, macro, sentiment, and headlines; the model writes a structured markdown brief (TL;DR, price action, on-chain, macro, catalysts, risks). Saved per day in your tenant.
  • Market — price, volume, dominance, volatility, drawdowns, comparison vs Gold/S&P/NDX, correlation matrix.
  • On-Chain — hash rate, MVRV, SOPR, realized cap, HODL waves, supply distribution.
  • Macro — DXY, CPI, M2, rates, unemployment, yields vs BTC.
  • Sentiment — Fear & Greed gauge + history, social volume, sentiment by source.
  • Institutions — ETFs, public companies, countries, miners, custodians with P/L vs current price.
  • News — filterable headline cards with summary and sentiment.
  • Valuation Lab — five fair-value models (Stock-to-Flow, Power Law, Metcalfe, Realized × Multiplier, Thermocap) with tunable parameters. Computes a weighted composite and overlays every model against historical price.
  • Cycle Comparator — overlay BTC halving cycles (2012, 2016, 2020, 2024) normalized to halving-day price. Toggle log/linear, isolate cycles, see how far into Cycle 4 we are.
  • Backtester — run DCA, Lump Sum, or MVRV-band rebalancing against the historical window. Reports ROI, alpha vs HODL, BTC accumulated, avg cost basis. Export CSV.
  • Scenarios — Monte Carlo simulator (Geometric Brownian Motion). Define start price, horizon, annual drift μ, and annual volatility σ; get P10/P50/P90 terminal distributions and sample paths. Saved scenarios attach to dossiers.
  • Portfolio — manual lot tracker. Add BTC lots with date, amount, and cost; see cost basis, market value, and unrealized P&L against live spot. Read-only — no keys, no custody.
  • Alerts — threshold rules on price, MVRV, SOPR, DXY, Fear & Greed, and dominance. Evaluated every render; firing rules show a badge, trigger a toast, and append to the feed.
  • Flows — daily and cumulative ETF net flows plus a unified treasury tracker for ETFs, public companies, and nation states with live P/L vs spot.
  • Research AI — full-page chat.
  • Knowledge Graph — interactive ecosystem map.
  • Historical Replay — scrub through 2011 → 2024 with the narrative that was knowable at each point.
  • Settings — theme, tenant, API keys, notifications.

Power tools

  • ⌘K Command Palette — open from anywhere with <kbd>⌘K</kbd> / <kbd>Ctrl+K</kbd>. Jump to any page or toggle the theme.
  • AI Dossier Auto-Fill — every dossier section has a wand button that drafts that section's markdown via the AI gateway. "AI fill all" walks every section in turn.
  • Export everywhere — Daily Brief exports to markdown, Dossiers to markdown, Backtester and Cycle Comparator to CSV.

Workspace mode

A second mode for analyst work:

  • Notes — markdown notes, autosaved per tenant.
  • Watchlists — symbol lists.
  • Dossiers — long-form research with sections: Bull case, Bear case, Risks, Metrics, Sources, Timeline, AI summaries.
  • Prompt Library — reusable prompts that one-click into the AI assistant.

How to extend the DAL with a real data source

  1. Implement the interface from src/dal/interfaces.ts (e.g. IMarketRepo) against your provider.
  2. Replace the mock export in src/dal/index.ts with your implementation.
  3. Pages and hooks don't change — they only depend on the interface.

Roadmap

  • Real-time data via WebSockets.
  • Persistent multitenant storage via Lovable Cloud.
  • Saved AI conversations attached to dossiers.
  • Backtests over historical regimes.