Technical reference

How Mosaic works under the hood

The full data pipeline, the five quant engines, the multi-agent orchestrator, vector RAG, and every specialist agent — click any node below to inspect its schema, formulas, or config.

How it works

Data lands in a dual local lake (ClickHouse + Qdrant), fans out to five quant engines, converges in a multi-agent orchestrator backed by a SQLite LLM cache so repeat questions are free, and surfaces wherever you work.

Click any component below to inspect its live schema & DDL
① Ingest & store watermark delta-sync engine
15 fetcher adapters · 14 live data feeds
Equities & ETFs
NSE Direct · Shoonya WS & REST · Yahoo · Zerodha Kite
Fund & flows
AMFI Flows · 14+ AMC Disclosures · MFAPI · Sensibull FII/DII
Macro & metals
RBI & MOSPI · World Bank · IMF WEO · CFTC COT · COMEX
News & sentiment
Google News RSS · NewsAPI
ClickHouse lake37 tables
daily_prices · mf_holdings · amfi_category_flows · indian_macro_indicators
bulk_block_deals · corporate_actions · cot_gold · fx_rates · ml_predictions
ReplacingMergeTree · watermark delta-sync
Qdrant vector DB5 collections
market_anomalies · mf_holdings
mf_fund_profiles · news_articles
768-dim nomic-embed-text · COSINE
Shoonya live tickWS + REST
N2 WebSocket broadcast · get_quotes
L2 5-level depth · VWAP · 52wk H/L
Real-time WebSocket tick stream
EventBus: DataImportedEvent → invalidate cache → re-predict ML → refresh signals
② Compute five quant engines
🎛️

Signals

6 pillars → 0–100 composite score

📈

ML forecast

LightGBM 5-day return + quantile bounds

⚖️

Volatility

GARCH(1,1) vol → Kelly sizing

🔬

Anomaly

MAD-Z → GARCH → Isolation Forest → PELT

🧬

Vector RAG

768d nomic-embed-text cosine memory

converge

Multi-agent orchestrator & StateGraph workflows (LangGraph ReAct)

LLM intent router → 10 specialist sub-agents + StateGraph parallel pipelines (80–90% token savings)

SQLite LLM cache
output/.cache · 24h TTL
repeat questions return instantly
surface
Streamlit dashboard
Conversational ask
./mosaic.sh CLI
Claude / Gemini MCP
PDF report export
Inspection drawer
Select any node above to inspect table DDL, mathematical formulas, or agent configuration.
Python 3.11+
ClickHouse
LangGraph ReAct
LightGBM
GARCH + arch
Isolation Forest
Streamlit
Ollama / Gemma 4
OpenAI / Anthropic
Qdrant
nomic-embed-text

Qdrant RAG: semantic memory, not just SQL

Five 768-dimensional collections store embedded representations of every anomaly, fund holding, news article, and portfolio fingerprint. Vector similarity finds cross-asset correlations and historical precedents that SQL can't express.

News RAG · macro correlation

Macro event → price shock correlation

When an anomaly fires, PostMacroShockStrategy embeds the event text and queries news_articles for semantically related headlines in the ±7-day window, no date exact-match required.

Anomaly detected GOLDBEES −5.7% on 2026-05-19 · Flash crash (Z=−4.2)
embed → query news_articles
Correlated news (cosine similarity)
RBI surprise rate hold0.91
India import duty hike gold0.87
USDINR breaks 84.5 resistance0.82
Fund RAG · holdings & allocation

Cross-fund holdings & allocation similarity

22k+ fund positions (809 funds) embedded as text. Fund-level profiles capture equity/gold/bond/cash fingerprints. Two query modes: find which funds share a stock, or find funds with similar multi-asset allocation.

Query find_similar_funds("DSP_MULTI_ASSET")
cosine → mf_fund_profiles
Similar portfolio composition
ICICI_MULTI_ASSETeq 52% · gold 15% · bond 22%0.94
QUANT_MULTI_ASSETeq 61% · gold 20% · bond 14%0.88
BAJAJ_MULTI_ASSETeq 67% · gold 16% · bond 4%0.83
Anomaly RAG · historical precedents

Historical precedent lookup for any regime

Every flagged anomaly date is auto-stored on pipeline run. Ask what past events looked like today's shock, ranked by embedding similarity, excluding a ±30-day self-match window.

Query find_similar_anomaly_events(
  "GOLDBEES", "Flash Crash"
)
cosine → market_anomalies
Historical precedents
2024-01-15Flash Crash Z=−4.20.96
2023-08-03Flash Crash Z=−3.80.91
2022-11-09Volatile Breakout0.79
news_articles
news RAG · tenant: category
clickhouse_metadata
schema RAG · prevents hallucination
market_anomalies
anomaly history · tenant: symbol
mf_holdings
22k fund positions · tenant: isin
mf_fund_profiles
portfolio fingerprints · tenant: fund_name
768-dim · nomic-embed-text · COSINE

Every engine, in detail

Signals

6-pillar composite scoring

18+ ETFs scored daily (0–100) combining macro, valuation, sentiment, flows, ML, and volatility.

Anomaly

6-step anomaly engine

MAD-Z, GARCH(1,1), Isolation Forest, PELT, and Volume HMM detect real price shocks & silent block deals.

Attribution

News-RAG attribution

Correlates price moves with earnings leaks, macro shocks, or cross-asset moves via Qdrant similarity.

ML

LightGBM 5-day forecast

Walk-forward CV quantile regression predicting 5-day returns with 80% confidence bands & Kelly sizing.

Risk

Volatility position sizing

GARCH(1,1) inverse-volatility scaling blended 50/50 with Kelly Criterion for optimal capital allocation.

Research

Indian & US equity deep-dives

Parallel research pulling 3-year cashflows, promoter trend checks, QIP dilution audits, and SEC 10-K filings.

Flows

Institutional whale tracking

Tracks monthly portfolio disclosures across 7 multi-asset funds (DSP, Nippon, ICICI, Quant, Bajaj) & CFTC COT.

Alerts

Real-time intraday & iNAV alerts

15-minute iNAV premium/discount arbitrage alerts and live order-flow bid/ask VWAP deviation monitors.

Reports

PDF report export

Generates institutional-grade PDF intelligence reports with GARCH charts, regime tables, and thesis summaries.

Vector

Qdrant semantic memory

5 vector collections storing embedded representations of anomalies, fund holdings, profiles, and news.

A guild of specialist analysts

Rather than one LLM with 80 tools, an intent router dispatches to 10 specialist sub-agents, each with a curated tool set, domain system prompt, and hard limits (20 tool calls / 30k tokens / 180s).

📊

SignalSubAgent

GOLDBEES ML pipeline, composite ETF scores, GARCH vol, anomaly explanation.

🇮🇳

IndianEquityResearchSubAgent

NSE/BSE stocks parallel fetch of price, earnings, promoter, MF holdings, news.

🌐

MacroSubAgent

COMEX pre-market, FII/DII flows, macro theme scanner, whale tracker.

🇺🇸

DeepDiveSubAgent

SEC EDGAR 10-K/10-Q, XBRL financials, exec comp, Workday hiring trends.

🌍

IntlETFSubAgent

MAFANG, Hang Seng, Nasdaq ETFs scarcity premium vs NAV analysis.

📰

NewsSubAgent

Multi-source sentiment aggregation NewsAPI + GNews per symbol.

💻

CodeSubAgent

Ad-hoc Python execution and raw ClickHouse SQL queries.

🗄️

DatabaseSubAgent

Schema inspection, watermark status, import freshness checks.

🏦

MFSubAgent

DSP, Nippon, Bajaj, Quant, ICICI fund holdings: MoM changes, cross-fund consensus, NAV returns.

🔭

AutonomousResearchAgent

Self-directed 10-layer research: fundamentals + macro + MF holdings + news + anomaly correlation, all in one report.

Learn the system