Ask one market question. Get a live-scraped evidence graph.
An AI research terminal that plans queries, scrapes the web in real time via Bright Data, and builds a linked knowledge graph β streamed live to a map-first workspace.
You type a market question β "Why is BTC down today?" or "NVDA post-earnings: what's the evidence?" β and the terminal:
- Plans 4β6 targeted search queries using an LLM
- Searches Google SERP concurrently via Bright Data (news + web verticals)
- Scrapes the top source pages for full-text markdown via Bright Data Web Unlocker (deep mode)
- Extracts structured evidence: titles, excerpts, entities, catalysts, sentiment
- Builds a knowledge graph β assets, events, sources, entities β linked with typed, confidence-scored edges
- Streams everything live to a map-first workspace via Server-Sent Events
- Answers follow-up questions grounded strictly in the collected evidence
No static datasets. No hallucinated sources. Every answer traces back to a scraped URL.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Browser (SSE) β
β ββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββββ β
β β Evidence Map β β Timeline β β Chat (grounded) β β
β β (graph viz) β β (tape + events) β β /api/chat β β
β βββββββββ¬βββββββββ ββββββββββ¬ββββββββββ βββββββββββ¬βββββββββββ β
ββββββββββββΌββββββββββββββββββββΌβββββββββββββββββββββββΌβββββββββββββ
β β SSE stream β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β /api/run β 8-stage pipeline β
β β
β plan β search β scrape β extract β summaries β artifacts β
β β link β render β ready β
ββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββββββββ¬βββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββ
β Bright Data β β LLM β β Convex β
β SERP + β β OpenRouter β β session DB + β
β Unlocker β β (Gemini 3) β β event log β
ββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββ
| Stage | What Happens |
|---|---|
| plan | LLM generates 4β6 targeted search queries from your topic |
| search | 4β6 concurrent Bright Data SERP requests (news β web fallback) |
| scrape | Top 4 URLs extracted to markdown via Bright Data Web Unlocker (deep mode) |
| extract | SERP snippets + markdown merged into structured evidence items |
| summaries | LLM extracts bullets, entities, catalysts, sentiment per item (deep mode) |
| artifacts | LLM builds knowledge graph nodes + edges with confidence scores |
| link | Heuristic enrichment: connectivity repair, domain tagging, tape events |
| render β ready | Final artifacts streamed to client, session persisted to Convex |
The core output is a typed knowledge graph β not a flat list of links.
Node types
| Type | Examples |
|---|---|
asset |
BITCOIN, NVDA, DXY |
entity |
Federal Reserve, BlackRock, MicroStrategy |
event |
ETF Approval, Fed Rate Hike, Earnings Miss |
source |
reuters.com, bloomberg.com, coindesk.com, forexfactory.com |
Edge types
| Type | Meaning |
|---|---|
hypothesis |
Event β Asset (this catalyst may explain this move) |
mentions |
Source β Event (this outlet covered this catalyst) |
co_moves |
Entity β Asset (correlated in the evidence) |
same_story |
Event β Event (same narrative, different angles) |
Every edge carries a confidence score [0, 1] and cites the evidence IDs that support it.
The terminal offers four ways to explore the same underlying data:
| View | Description |
|---|---|
| Graph | Interactive force-directed knowledge graph β drag, zoom, click nodes |
| Flow | Directional flow diagram showing causal chains |
| Mind Map | Hierarchical view radiating from the primary asset |
| Timeline | Chronological tape of events ordered by publish date |
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) + React 19 |
| Styling | Tailwind CSS 4 |
| Realtime DB | Convex β sessions, event log, TTL cleanup |
| Web Data | Bright Data β SERP + Web Unlocker |
| AI | OpenRouter β Gemini 3 Flash Preview (configurable per pipeline stage) |
| Graph Viz | react-force-graph-2d |
| Validation | Zod |
| Icons | lucide-react |
market-terminal/
βββ src/
β βββ app/
β β βββ api/
β β β βββ run/ # Main pipeline β SSE orchestrator
β β β βββ chat/ # Evidence-grounded Q&A
β β β βββ sessions/ # Listing, event trace, snapshots
β β β βββ health/ # Config check + live dependency probes
β β β βββ serp/ # Direct SERP search (debug/test)
β β βββ terminal/ # Interactive evidence workspace
β β βββ dashboard/ # Session history + event replay
β β βββ how-it-works/ # Architecture documentation page
β βββ components/
β β βββ terminal/
β β β βββ Terminal.tsx # Workspace orchestrator
β β β βββ EvidenceGraph.tsx # Force-directed graph
β β β βββ EvidenceFlow.tsx # Flow diagram
β β β βββ EvidenceMindMap.tsx # Mind map
β β β βββ EvidenceTimeline.tsx # Chronological tape
β β β βββ PipelineTimeline.tsx # Live pipeline progress bar
β β βββ dashboard/
β β βββ SessionDashboard.tsx # History + replay UI
β βββ lib/
β β βββ brightdata.ts # SERP + Web Unlocker client
β β βββ ai.ts # LLM client + JSON parsing utilities
β β βββ modelRouting.ts # Provider/model selection per stage
β β βββ env.ts # Typed environment configuration
β βββ prompts/ # Multi-stage LLM prompt templates
β βββ signalTerminalPlan.ts
β βββ signalTerminalSummaries.ts
β βββ signalTerminalArtifacts.ts
β βββ signalTerminalImpact.ts
β βββ signalTerminalChat.ts
βββ convex/
β βββ schema.ts # sessions + sessionEvents table definitions
β βββ sessions.ts # CRUD, search, 24h TTL cleanup
β βββ sessionEvents.ts # Event log insert + query
βββ public/
βββ brightdata.svg
βββ convex.svg
- Node.js 20+
- A Bright Data account with SERP and Web Unlocker zones configured
- An OpenRouter API key
- A Convex project (free tier works)
cd market-terminal
npm installcp .env.local.example .env.local# Bright Data
BRIGHTDATA_API_TOKEN=your_token_here
BRIGHTDATA_WEB_UNLOCKER_ZONE=unblocker
BRIGHTDATA_SERP_ZONE=serp
# AI β OpenRouter
OPENROUTER_API_KEY=sk-or-...
OPENROUTER_MODEL=google/gemini-3-flash-preview
# Convex
CONVEX_DEPLOYMENT=prod:your-deployment-slug
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloudnpx convex devnpm run devOpen http://localhost:3000/market-terminal
Starts the research pipeline. Returns a Server-Sent Events stream.
{
"topic": "Bitcoin",
"question": "Why is BTC down today?",
"mode": "fast"
}| Mode | Behavior |
|---|---|
fast |
SERP only, broad time window, lighter AI model β ~3β5s |
deep |
SERP + full-page markdown extraction, richer AI summaries β ~8β15s |
SSE event types: session Β· plan Β· search.partial Β· search Β· scrape.page Β· data Β· step Β· warn Β· perf.mark Β· perf.summary Β· ai.usage
# Example curl
curl -N -X POST http://localhost:3000/market-terminal/api/run \
-H 'Content-Type: application/json' \
-d '{"topic":"Bitcoin","mode":"fast"}'Answer a follow-up question grounded in a session's collected evidence.
{
"sessionId": "uuid",
"message": "What is the strongest bullish signal?",
"focusEvidenceIds": ["ev_1", "ev_2"]
}List sessions with artifact counts and narrative map tags.
GET /api/sessions?limit=50&q=bitcoin&status=ready
Live health check β actively tests Bright Data SERP, Web Unlocker, AI model, and Convex connectivity.
Bright Data is the data backbone of every run:
- SERP β Concurrent multi-query Google search with news/web vertical routing, domain diversity scoring, and automatic staleness filtering. Results are scored for editorial authority and catalyst-signal density before being fed to the LLM.
- Web Unlocker β Full-page markdown extraction from any URL, bypassing bot detection to deliver clean, readable content for deep-mode evidence enrichment.
- Resilience β Exponential backoff on 429/5xx responses, newsβweb fallback on empty verticals, best-effort scrape failures so the pipeline always completes and streams a result.
Convex is the persistent backbone behind each research session:
- Session records β Full metadata, pipeline progress, and final artifacts (
evidence,tape,nodes,edges,clusters) stored inmeta.artifacts - Event log β Every SSE event is persisted to
sessionEvents, enabling full replay, debugging, and performance analysis from the Dashboard - Auto-expiry β Sessions are cleaned up after 24 hours via a Convex scheduled mutation
- Non-blocking writes β Convex persistence is fire-and-forget; the pipeline streams to the client regardless of DB latency
Every run is logged. The /dashboard page shows all sessions with:
- Topic, status, mode, model used
- Artifact counts (evidence items, graph nodes/edges, narrative clusters)
- Map tags (top entities, catalysts, narrative themes extracted automatically)
- Full event trace with per-stage timing breakdowns
Click any session to re-open its evidence workspace β no re-run required.
The pipeline emits granular perf.mark events for every sub-operation:
plan β 450ms
serp[0] β 820ms
serp[1] β 790ms
scrape[0] β 1240ms
ai.summaries β 2100ms
ai.artifacts β 3300ms
ββββββββββββββββββββββββββ
total β ~6.1s
ai.usage events log input/output token counts per LLM call. The /api/health?probe=1 endpoint actively probes all external dependencies and reports configuration status.
- Building a Live AI Market Research Terminal: How Bright Data and Convex Replace Polling With Real-Time Everything β Full architecture walkthrough covering both Bright Data paths, Convex roles, the reflection stage, and model selection logic.