Kalavya — a market-learning platform built on dependency Webs
A four-pillar market-learning platform — gated curriculum, dependency Webs, options-shaped paper trading, and planned read-only brokerage linking. Live at kalavya.trade; the Webs are the differentiator.
Abstract. Kalavya started as one AI supply-chain diagram and grew into a four-pillar market-learning platform: Learn, Webs, Build, Connect. Pillars 1–3 are live at kalavya.trade — two dependency Webs over a shared 110-ticker universe, paper trading in equities and single-leg options, and a transparent 5-factor risk model with a per-factor 'here's why' readout. Connect is spec-only and copy-trading is a documented north star, not a product. There are no usage numbers yet; the evidence here is calibration, tests and closed security holes, not returns.
§ 1 · Problem
Four pillars, built in order
Kalavya is a market-learning platform organized as four pillars: Learn (a gated
curriculum, Investing 101 → Options 101), Webs (themed dependency diagrams over a
shared ticker universe), Build (a persistent paper-trading simulator, options-shaped
from day one), and Connect (read-only real-brokerage linking — planned, not started).
The framing in the decision log is honest about what it is: a real app friends use and
an interview showcase. Pillars 1–3 are the shippable showcase; Connect is the strategic
bet; the copy-trading social platform is the north star and explicitly not v1.
What is actually shipped: phases 0–4 plus the options pillar are live on kalavya.trade —
public Learn and Webs with no sign-in, a read-only demo portfolio for signed-out visitors,
authenticated paper trading in equities and single-leg options with live Greeks, Web-aware
exposure views with chokepoint-concentration warnings, model portfolios with cloning, an
opt-in paper leaderboard ranked by time-weighted return, and the risk worker’s 110 real
scores. Connect has not been started.
§ 2 · The Webs
Who depends on whom — kept buyable
A Web is one themed dependency diagram — the AI Web, the Metals Web — capturing
who-depends-on-whom in a market slice. The name was a deliberate decision (D4): the
dependency relationships are the point, so Webs over Maps, Sectors, or Chains. The AI Web
holds 86 companies across 19 layers (spine plus side-rails, chokepoints ranked); the
Metals Web holds 27 placements across 10 layers. Together they prove the many-to-many
model: a company exists once in the universe and Webs reference it.
A hard rule keeps the diagrams honest for the intended audience: only tickers buyable on
mainstream US/EU platforms appear. Foreign-only names resolve to a listed proxy or get
dropped — Lynas→MP, Glencore→VALE, Sprott Uranium→URA — because a user’s friend must be
able to actually buy everything shown.
The content is hand-researched — an AI supply-chain compendium and field guides seeded
both Webs — and the docs are explicit that this doesn’t scale and shouldn’t: the
hand-written narratives are the moat; auto-generating them for 500 names produces generic
mush. Prices come from Massive (the rebranded Polygon) as EOD prev-closes written into a
snapshot table by a sync job; the app’s hot path reads cached snapshots, never the live
API. The sync gate required at least 80 percent real closes before placeholders dropped;
the first live sync priced 108 of 110 tickers.
SnapTrade · read-only forever Phase 5 · not started spec only
Fig. 1 — a company exists once in the universe; Webs reference it many-to-many, the simulator holds it, and brokerage sync will map onto it.
The single most important design decision, per the log (D22): an instruments table where
an equity is the degenerate option — no strike, no expiry, multiplier 1 — so options
later dropped in without a rewrite. It was verified when a 2-contract NVDA call priced at
exactly 2 × 100.60 × 100 = $20,120 through the same trade RPC equities use. Transactions
are an immutable ledger; positions are a derived cache; time-weighted return is computed
from the ledger so returns aren’t distorted by when money was added.
The risk model is a deliberate anti-ML choice (D15): a transparent 5-factor cross-sectional
percentile model — realized vol 0.30, max drawdown 0.25, beta-vs-SPY 0.20, size 0.15,
liquidity 0.10 — in a Python worker, because every score must decompose into “here’s why”
for an education product. Three fundamental factors are deferred by data-plan limits,
stored as NULL and rendered as “not yet scored” rather than faked.
§ 4 · Status
Calibration and tests, not P&L
The evidence for the risk model is calibration, not returns. All 110 of 110 universe
tickers are scored, and the v1 run reproduced the hand-calibrated face-validity anchors
without being fit to them: the low anchors (MSFT 15, GOOGL 8, NVDA 15) and high anchors
(SMR 96, OKLO 93, NVTS 94) separate at anchor means of 15.2 vs 88.0. That gate passed.
The full validation suite — predictive check, external-anchor rank-correlation, stability —
has not yet run; the model’s own doc calls face validity necessary but not sufficient,
and I’m keeping that framing.
The test surface is real: 134 Vitest, 28 pytest, 7 Playwright E2E, all green, with the
RLS integration suite running live against a local Supabase across 13 anon/authed cases.
After security hardening v2, 18 of 18 re-attack probes against production passed.
The gaps are stated plainly: all 16 Learn lesson bodies exist as drafts behind an amber
“this lesson is being written” banner — none are published until I author the real prose.
§ 5 · What it taught
Two closed exploits, logged as lessons
Two red-team audits (v1 and v2) found and closed 1 Critical and 5 High issues. The worst
was a raw PostgREST INSERT grant on the transactions table sitting beside the hardened
trade RPC: a forged sell bought infinite paper cash and the #1 leaderboard spot, bypassing
every validation in the RPC.
security-audit-v2 · re-attack probe
# before hardening: raw PostgREST INSERT grant on transactions
POST /rest/v1/transactions
payload = '{ "side": "SELL", "qty": 1000000, "price": 99999 }'# 201 Created -> forged ledger row -> infinite paper cash -> leaderboard #1# after: SECURITY DEFINER RPCs are the only write path into the paper economy
POST /rest/v1/transactions
# 42501 insufficient_privilege -- verified on production, 18/18 probes
Option-mark poisoning was the second real find: any user could write another holder’s
contract mark. The fix clamps fills to intrinsic ≤ mark ≤ 5 × max(spot, strike) and trusts
only cron-written marks. The RLS suite also caught a subtle regression — a hardened
leaderboard read that joined portfolios silently showed viewers only their own rows,
because PostgREST inner-join embeds drop RLS-filtered rows; fixed by persisting the display
values on the leaderboard row itself, so clients have no write grant on either displayed
value and opt-in is enforced in RLS, not app logic.
The reusable lessons went into the log as templates: never leave a raw table grant beside
a hardened RPC, and authorize the specific object, not just the authenticated user.
§ 6 · North star
Copy trading is the endgame — documented, not shipped
The north star (D3) — copy-trading, creator rewards, real-time trade posting, a community —
is documented and not built; it may end up a separate product. Only the linking
architecture is being built now, because it’s the foundation the endgame needs. Connect
itself (SnapTrade) is Phase 5, not started, blocked on registration, and carries a
permanent principle: read-only forever — a tracker, not a broker.
Just as plainly: there are zero usage metrics. No user counts, no traffic, no
engagement numbers exist anywhere in the docs — the audience today is me and friends,
private. Streaming intraday prices were deferred as a want, not a need; for a handful of
users, fresh-on-load quotes suffice.
Next, per the status doc, is a choice between Phase 5 Connect (long lead time), the
risk-model fast-follow (fundamental factors via SEC EDGAR, the full validation suite, a
nightly cron), and authoring the 16 Learn lessons.