How ankan00v/verdikt works
Purpose and Entry Points
Verdikt is a Next.js investment-research agent. A user submits a company name and receives a traceable INVEST/PASS recommendation derived from financial, news, and web research. The UI entry points are the landing page at src/app/page.tsx and research console at src/app/research/page.tsx; execution enters through the SSE API route src/app/api/research/route.ts.
Client Research Console
The research page starts and monitors a run through the SSE-consuming hook src/lib/useResearch.ts. It renders progress and structured node results in the console components, principally src/components/verdikt/NodeTracker.tsx, src/components/verdikt/FindingsFeed.tsx, and src/components/verdikt/DetailPane.tsx. This is a streaming visualization layer, not the source of decision logic; frontend types are shared through src/lib/researchTypes.ts.
Agent Graph Orchestration
The core backend is a LangGraph StateGraph defined in src/lib/agent/graph.ts, with typed shared state in src/lib/agent/state.ts. The graph controls ordering, parallel fan-out/fan-in, and progression from request input to final verdict. src/lib/agent/nodes/gather-data.ts is the synchronization boundary between independent data retrieval and analysis stages.
Identity Resolution and Data Acquisition
The pipeline first maps a company query to a tradable ticker using src/lib/agent/nodes/resolve-ticker.ts. It then runs three retrieval branches concurrently:
• Financial/company data from Yahoo Finance: src/lib/agent/nodes/fetch-financials.ts
• Recent news from Tavily: src/lib/agent/nodes/fetch-news.ts
• Competitive/web research from Tavily: src/lib/agent/nodes/fetch-web-research.ts
Yahoo requests may use a configured proxy to work from Vercel infrastructure. These external-data nodes establish the boundary between live source material and downstream LLM interpretation.
Structured Analysis and Decisioning
After fan-in, specialized LLM nodes independently interpret each evidence domain: src/lib/agent/nodes/analyze-fundamentals.ts, src/lib/agent/nodes/analyze-sentiment.ts, and src/lib/agent/nodes/analyze-competitive.ts. A final synthesis node, src/lib/agent/nodes/synthesize-decision.ts, combines those outputs into the INVEST/PASS verdict, confidence, strengths, risks, and rationale. Output contracts live in src/lib/agent/schemas.ts, using Zod-enforced structured responses rather than free-form parsing.
LLM and Failure Boundaries
src/lib/agent/llm.ts centralizes NVIDIA NIM/Llama inference, structured-output invocation, timeout handling, retry/backoff, and optional fallback-key rotation. This keeps model-provider resilience outside individual analysis nodes. Failures in retrieval or analysis are represented in graph state and surfaced to the streaming console rather than silently hidden.
Durability, Caching, and Runtime
The application runs as Next.js App Router/serverless code, intended for Vercel. Redis integration in src/lib/redis.ts provides per-node result caching; src/lib/agent/upstash-saver.ts persists LangGraph checkpoints to Upstash Redis so an SSE reconnect after a serverless timeout can resume work. Required external services are NVIDIA NIM, Tavily, Yahoo Finance, and optionally Upstash Redis plus a Yahoo proxy.
Main entry points: gather-data.ts Gather data · llm.ts LLM gateway · synthesize-decision.ts Synthesize decision · graph.ts Research StateGraph
Components 24
Research UI
- Landing page
src/app/page.tsx - Research console · Displays streaming run progress and results.
src/app/research/page.tsx - SSE research hook
src/lib/useResearch.ts - Result views · Progress tracker, findings feed, and detail pane.
src/components/verdikt/NodeTracker.tsx - Research types
src/lib/researchTypes.ts
Server Runtime
- Research SSE route · Starts or resumes graph execution and streams state updates.
src/app/api/research/route.ts - Redis cache · Caches per-node results.
src/lib/redis.ts - Upstash checkpoint saver · Allows reconnects to resume serverless runs.
src/lib/agent/upstash-saver.ts
Agent Pipeline
- Research StateGraph · Controls fan-out, fan-in, and verdict progression.
src/lib/agent/graph.ts - Shared graph state · Carries evidence, failures, progress, and outputs between nodes.
src/lib/agent/state.ts - Resolve ticker
src/lib/agent/nodes/resolve-ticker.ts - Fetch financials
src/lib/agent/nodes/fetch-financials.ts - Fetch news
src/lib/agent/nodes/fetch-news.ts - Fetch web research
src/lib/agent/nodes/fetch-web-research.ts - Gather data · Synchronization boundary before analysis.
src/lib/agent/nodes/gather-data.ts - Analyze fundamentals
src/lib/agent/nodes/analyze-fundamentals.ts - Analyze sentiment
src/lib/agent/nodes/analyze-sentiment.ts - Analyze competitive
src/lib/agent/nodes/analyze-competitive.ts - Synthesize decision · Produces INVEST/PASS, confidence, strengths, risks, and rationale.
src/lib/agent/nodes/synthesize-decision.ts - Output schemas · Enforces structured LLM responses.
src/lib/agent/schemas.ts - LLM gateway · Centralizes structured calls, retries, timeouts, and key fallback.
src/lib/agent/llm.ts
External Services
- Yahoo Finance · May be reached through a configured proxy.
- Tavily
- NVIDIA NIM / Llama
Connections 33
- Landing page → Research console: opens research
- Research console → SSE research hook: starts and monitors run
- SSE research hook → Research SSE route: SSE request
- SSE research hook → Result views: streamed updates
- Research types → SSE research hook: types
- Research types → Result views: types
- Research SSE route → Research StateGraph: execute or resume
- Research SSE route → Upstash checkpoint saver: load/save checkpoints
- Research StateGraph → Shared graph state: reads and updates
- Research StateGraph → Resolve ticker: first stage
- Resolve ticker → Fetch financials: ticker fan-out
- Resolve ticker → Fetch news: ticker fan-out
- Resolve ticker → Fetch web research: ticker fan-out
- Fetch financials → Yahoo Finance: live company data
- Fetch news → Tavily: recent news search
- Fetch web research → Tavily: competitive web search
- Fetch financials → Gather data: financial evidence
- Fetch news → Gather data: news evidence
- Fetch web research → Gather data: web evidence
- Gather data → Analyze fundamentals: analyze
- Gather data → Analyze sentiment: analyze
- Gather data → Analyze competitive: analyze
- Analyze fundamentals → Synthesize decision: fundamental assessment
- Analyze sentiment → Synthesize decision: sentiment assessment
- Analyze competitive → Synthesize decision: competitive assessment
- Analyze fundamentals → LLM gateway: structured inference
- Analyze sentiment → LLM gateway: structured inference
- Analyze competitive → LLM gateway: structured inference
- Synthesize decision → LLM gateway: structured synthesis
- LLM gateway → NVIDIA NIM / Llama: model invocation
- LLM gateway → Output schemas: validates outputs
- Research StateGraph → Redis cache: cache node results
- Synthesize decision → Research SSE route: verdict and state events