# abinav-kishore/vantic architecture

> Architecture diagram of the GitHub repository abinav-kishore/vantic, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abinav-kishore/vantic
- Repository: https://github.com/abinav-kishore/vantic

## Overview

#### Purpose and entry points
Vantiq is a Next.js/React stock-intelligence application that runs explainable technical, fundamental, and sentiment analysis for a selected symbol. The primary UI is `app/dashboard/page.tsx`; `app/page.tsx` and `app/layout.tsx` establish application routing/layout. Server entry points are App Router handlers, especially `app/api/analysis/route.ts` for the full pipeline and `app/api/evidence/route.ts` for fundamental evidence retrieval.

#### API and orchestration boundary
`app/api/analysis/route.ts` accepts `{ symbol, profile }`, validates/resolves the requested instrument through backend services, runs exactly three specialist agents concurrently, then performs synthesis and risk-profile adaptation. It returns both decision-oriented output and explainability data rather than exposing provider credentials or raw server implementation to the browser. Stock lookup and chart-data APIs are separated under `app/api/stocks/route.ts`, `app/api/stocks/[symbol]/route.ts`, and `app/api/stocks/[symbol]/history/route.ts`.

#### Market-data subsystem
The market layer provides a provider boundary around Yahoo Finance, with caching/client behavior in `market/marketDataClient.ts` and concrete provider access in `market/yahooFinanceProvider.ts`. It supplies snapshots and historical candles for stock APIs and technical analysis. Indicator computation is local and deterministic in `market/indicators.ts`, keeping RSI, MACD, EMA, momentum, volume, and support/resistance logic independent of external-provider response formats. Finnhub news access is isolated in `market/finnhubProvider.ts`.

#### Parallel specialist-agent stage
Three independently scoped agents consume distinct data sources and produce shared typed outputs:
- TECH-SPIDER: `agents/technicalAgent.ts`, using market history and indicators.
- FUND-SPIDER: `agents/fundamentalAgent.ts`, using RAG retrieval and source-grounded evidence.
- SENTI-SPIDER: `agents/sentimentAgent.ts`, using relevant Finnhub news.

Shared contracts in `agents/types.ts` normalize signals, confidence, evidence, availability, and failure/degraded states. The orchestration preserves unavailable states instead of inventing provider values, news, or document evidence.

#### Synthesis, personalization, and traceability
After the parallel agents finish, NEXUS combines their signals, confidence, and agreement/disagreement through `agents/synthesis.ts`. `agents/personalization.ts` reframes the result for conservative or aggressive profiles without replacing the underlying analysis. `agents/reasoningTrace.ts` records actual pipeline-stage status and latency; this trace is a first-class response artifact consumed by the dashboard.

#### RAG evidence pipeline
The fundamental-analysis boundary is a local, per-symbol document corpus backed by OpenAI embeddings. Ingestion flows through `rag/ingest.ts`, extraction/chunking, and `rag/vectorIndex.ts`; query-time semantic retrieval is handled by `rag/retrievalService.ts`. Document and evidence contracts live in `types/documents.ts` and `data/types.ts`. The evidence API and FUND-SPIDER must return unavailable/empty results when a symbol lacks corpus coverage, the index is absent, or embeddings cannot be generated.

#### Presentation and infrastructure
The browser dashboard composes analysis, evidence, charts, agent status, synthesis, and reasoning-trace views from `app/dashboard/page.tsx` and components such as `components/AskVantic.tsx`, `components/EvidencePanel.tsx`, and `components/ReasoningTrace.tsx`. The runtime is Next.js 15 App Router on Node.js with TypeScript. External services are Yahoo Finance (`yahoo-finance2`), Finnhub over `fetch`, and OpenAI Embeddings over `fetch`; secrets remain server-side via environment configuration.

Main entry points: [`app/api/analysis/route.ts`](https://github.com/abinav-kishore/vantic/blob/master/app/api/analysis/route.ts) (Analysis API), [`app/dashboard/page.tsx`](https://github.com/abinav-kishore/vantic/blob/master/app/dashboard/page.tsx) (Dashboard), [`market/marketDataClient.ts`](https://github.com/abinav-kishore/vantic/blob/master/market/marketDataClient.ts) (Market data client), [`agents/types.ts`](https://github.com/abinav-kishore/vantic/blob/master/agents/types.ts) (Agent contracts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser UI"]
  node_dashboard["Dashboard<br/>Next.js page<br/>[page.tsx]"]
  node_ask["Analysis interaction<br/>React component<br/>[AskVantic.tsx]"]
  node_evidence_panel["Evidence panel<br/>React component<br/>[EvidencePanel.tsx]"]
  node_trace_view["Reasoning trace view<br/>React component<br/>[ReasoningTrace.tsx]"]
end

subgraph group_api["App Router APIs"]
  node_analysis_api["Analysis API<br/>route handler<br/>[route.ts]"]
  node_evidence_api["Evidence API<br/>route handler<br/>[route.ts]"]
  node_stock_apis["Stock &amp; history APIs<br/>route handlers<br/>[route.ts]"]
end

subgraph group_agents["Analysis pipeline"]
  node_agent_contracts["Agent contracts<br/>shared types<br/>[types.ts]"]
  node_technical["TECH-SPIDER<br/>specialist agent<br/>[technicalAgent.ts]"]
  node_fundamental["FUND-SPIDER<br/>specialist agent"]
  node_sentiment["SENTI-SPIDER<br/>specialist agent<br/>[sentimentAgent.ts]"]
  node_synthesis["NEXUS synthesis<br/>signal combiner<br/>[synthesis.ts]"]
  node_personalization["Risk adaptation<br/>profile adapter<br/>[personalization.ts]"]
  node_trace["Pipeline trace<br/>trace builder<br/>[reasoningTrace.ts]"]
end

subgraph group_market["Market data"]
  node_market_client["Market data client<br/>provider boundary"]
  node_yahoo["Yahoo provider<br/>provider adapter"]
  node_indicators["Technical indicators<br/>deterministic computation<br/>[indicators.ts]"]
  node_finnhub["Finnhub provider<br/>news adapter<br/>[finnhubProvider.ts]"]
end

subgraph group_rag["Evidence RAG"]
  node_ingest["Corpus ingestion<br/>ingestion pipeline<br/>[ingest.ts]"]
  node_vector_index[("Vector index<br/>local semantic index<br/>[vectorIndex.ts]")]
  node_retrieval["Evidence retrieval<br/>semantic retrieval"]
end

node_openai{{"OpenAI embeddings<br/>external service"}}
node_yahoo_ext{{"Yahoo Finance<br/>external service"}}
node_finnhub_ext{{"Finnhub<br/>external service"}}

node_dashboard --> node_ask
node_dashboard --> node_evidence_panel
node_dashboard --> node_trace_view
node_ask -->|"analysis request"| node_analysis_api
node_evidence_panel -->|"evidence request"| node_evidence_api
node_dashboard -->|"quotes and charts"| node_stock_apis
node_analysis_api -->|"parallel"| node_technical
node_analysis_api -->|"parallel"| node_fundamental
node_analysis_api -->|"parallel"| node_sentiment
node_technical -->|"typed result"| node_agent_contracts
node_fundamental -->|"typed result"| node_agent_contracts
node_sentiment -->|"typed result"| node_agent_contracts
node_agent_contracts -->|"specialist outputs"| node_synthesis
node_synthesis -->|"base decision"| node_personalization
node_personalization -->|"response"| node_analysis_api
node_analysis_api -->|"stage status and latency"| node_trace
node_trace -->|"response artifact"| node_trace_view
node_technical -->|"history"| node_market_client
node_market_client -->|"provider access"| node_yahoo
node_yahoo --> node_yahoo_ext
node_market_client -->|"candles"| node_indicators
node_stock_apis -->|"snapshots and history"| node_market_client
node_sentiment -->|"relevant news"| node_finnhub
node_finnhub --> node_finnhub_ext
node_fundamental -->|"grounded evidence"| node_retrieval
node_evidence_api -->|"evidence query"| node_retrieval
node_retrieval -->|"semantic search"| node_vector_index
node_ingest -->|"chunks and embeddings"| node_vector_index
node_ingest -->|"generate embeddings"| node_openai

click node_dashboard "https://github.com/abinav-kishore/vantic/blob/master/app/dashboard/page.tsx"
click node_ask "https://github.com/abinav-kishore/vantic/blob/master/components/AskVantic.tsx"
click node_evidence_panel "https://github.com/abinav-kishore/vantic/blob/master/components/EvidencePanel.tsx"
click node_trace_view "https://github.com/abinav-kishore/vantic/blob/master/components/ReasoningTrace.tsx"
click node_analysis_api "https://github.com/abinav-kishore/vantic/blob/master/app/api/analysis/route.ts"
click node_evidence_api "https://github.com/abinav-kishore/vantic/blob/master/app/api/evidence/route.ts"
click node_stock_apis "https://github.com/abinav-kishore/vantic/blob/master/app/api/stocks/route.ts"
click node_agent_contracts "https://github.com/abinav-kishore/vantic/blob/master/agents/types.ts"
click node_technical "https://github.com/abinav-kishore/vantic/blob/master/agents/technicalAgent.ts"
click node_fundamental "https://github.com/abinav-kishore/vantic/blob/master/agents/fundamentalAgent.ts"
click node_sentiment "https://github.com/abinav-kishore/vantic/blob/master/agents/sentimentAgent.ts"
click node_synthesis "https://github.com/abinav-kishore/vantic/blob/master/agents/synthesis.ts"
click node_personalization "https://github.com/abinav-kishore/vantic/blob/master/agents/personalization.ts"
click node_trace "https://github.com/abinav-kishore/vantic/blob/master/agents/reasoningTrace.ts"
click node_market_client "https://github.com/abinav-kishore/vantic/blob/master/market/marketDataClient.ts"
click node_yahoo "https://github.com/abinav-kishore/vantic/blob/master/market/yahooFinanceProvider.ts"
click node_indicators "https://github.com/abinav-kishore/vantic/blob/master/market/indicators.ts"
click node_finnhub "https://github.com/abinav-kishore/vantic/blob/master/market/finnhubProvider.ts"
click node_ingest "https://github.com/abinav-kishore/vantic/blob/master/rag/ingest.ts"
click node_vector_index "https://github.com/abinav-kishore/vantic/blob/master/rag/vectorIndex.ts"
click node_retrieval "https://github.com/abinav-kishore/vantic/blob/master/rag/retrievalService.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_ask,node_evidence_panel,node_trace_view toneBlue
class node_analysis_api,node_evidence_api,node_stock_apis toneAmber
class node_agent_contracts,node_technical,node_fundamental,node_sentiment,node_synthesis,node_personalization,node_trace toneMint
class node_market_client,node_yahoo,node_indicators,node_finnhub toneRose
class node_ingest,node_vector_index,node_retrieval toneIndigo
class node_openai,node_yahoo_ext,node_finnhub_ext toneNeutral
```

## Components

### Browser UI

- [Dashboard](https://github.com/abinav-kishore/vantic/blob/master/app/dashboard/page.tsx): Next.js page · Composes analysis, evidence, charts, status, and trace views. · `app/dashboard/page.tsx`
- [Analysis interaction](https://github.com/abinav-kishore/vantic/blob/master/components/AskVantic.tsx): React component · `components/AskVantic.tsx`
- [Evidence panel](https://github.com/abinav-kishore/vantic/blob/master/components/EvidencePanel.tsx): React component · `components/EvidencePanel.tsx`
- [Reasoning trace view](https://github.com/abinav-kishore/vantic/blob/master/components/ReasoningTrace.tsx): React component · `components/ReasoningTrace.tsx`

### App Router APIs

- [Analysis API](https://github.com/abinav-kishore/vantic/blob/master/app/api/analysis/route.ts): route handler · Validates a symbol and returns decision output plus explainability artifacts. · `app/api/analysis/route.ts`
- [Evidence API](https://github.com/abinav-kishore/vantic/blob/master/app/api/evidence/route.ts): route handler · `app/api/evidence/route.ts`
- [Stock & history APIs](https://github.com/abinav-kishore/vantic/blob/master/app/api/stocks/route.ts): route handlers · Lookup, quote, and chart-data endpoints. · `app/api/stocks/route.ts`

### Analysis pipeline

- [Agent contracts](https://github.com/abinav-kishore/vantic/blob/master/agents/types.ts): shared types · Normalizes signals, confidence, evidence, and degraded states. · `agents/types.ts`
- [TECH-SPIDER](https://github.com/abinav-kishore/vantic/blob/master/agents/technicalAgent.ts): specialist agent · `agents/technicalAgent.ts`
- [FUND-SPIDER](https://github.com/abinav-kishore/vantic/blob/master/agents/fundamentalAgent.ts): specialist agent · `agents/fundamentalAgent.ts`
- [SENTI-SPIDER](https://github.com/abinav-kishore/vantic/blob/master/agents/sentimentAgent.ts): specialist agent · `agents/sentimentAgent.ts`
- [NEXUS synthesis](https://github.com/abinav-kishore/vantic/blob/master/agents/synthesis.ts): signal combiner · Combines confidence and cross-agent agreement or disagreement. · `agents/synthesis.ts`
- [Risk adaptation](https://github.com/abinav-kishore/vantic/blob/master/agents/personalization.ts): profile adapter · Reframes conclusions for conservative or aggressive profiles. · `agents/personalization.ts`
- [Pipeline trace](https://github.com/abinav-kishore/vantic/blob/master/agents/reasoningTrace.ts): trace builder · Records actual stage status and latency. · `agents/reasoningTrace.ts`

### Market data

- [Market data client](https://github.com/abinav-kishore/vantic/blob/master/market/marketDataClient.ts): provider boundary · Caching and normalized market-data access. · `market/marketDataClient.ts`
- [Yahoo provider](https://github.com/abinav-kishore/vantic/blob/master/market/yahooFinanceProvider.ts): provider adapter · `market/yahooFinanceProvider.ts`
- [Technical indicators](https://github.com/abinav-kishore/vantic/blob/master/market/indicators.ts): deterministic computation · Computes RSI, MACD, EMA, momentum, volume, and levels. · `market/indicators.ts`
- [Finnhub provider](https://github.com/abinav-kishore/vantic/blob/master/market/finnhubProvider.ts): news adapter · `market/finnhubProvider.ts`

### Evidence RAG

- [Corpus ingestion](https://github.com/abinav-kishore/vantic/blob/master/rag/ingest.ts): ingestion pipeline · Extracts and chunks per-symbol documents. · `rag/ingest.ts`
- [Vector index](https://github.com/abinav-kishore/vantic/blob/master/rag/vectorIndex.ts): local semantic index · Stores corpus embeddings per symbol. · `rag/vectorIndex.ts`
- [Evidence retrieval](https://github.com/abinav-kishore/vantic/blob/master/rag/retrievalService.ts): semantic retrieval · Returns empty or unavailable when corpus or embeddings are absent. · `rag/retrievalService.ts`

### Other components

- **OpenAI embeddings**: external service
- **Yahoo Finance**: external service
- **Finnhub**: external service

## Connections

- Dashboard → Analysis interaction
- Dashboard → Evidence panel
- Dashboard → Reasoning trace view
- Analysis interaction → Analysis API: analysis request
- Evidence panel → Evidence API: evidence request
- Dashboard → Stock & history APIs: quotes and charts
- Analysis API → TECH-SPIDER: parallel
- Analysis API → FUND-SPIDER: parallel
- Analysis API → SENTI-SPIDER: parallel
- TECH-SPIDER → Agent contracts: typed result
- FUND-SPIDER → Agent contracts: typed result
- SENTI-SPIDER → Agent contracts: typed result
- Agent contracts → NEXUS synthesis: specialist outputs
- NEXUS synthesis → Risk adaptation: base decision
- Risk adaptation → Analysis API: response
- Analysis API → Pipeline trace: stage status and latency
- Pipeline trace → Reasoning trace view: response artifact
- TECH-SPIDER → Market data client: history
- Market data client → Yahoo provider: provider access
- Yahoo provider → Yahoo Finance
- Market data client → Technical indicators: candles
- Stock & history APIs → Market data client: snapshots and history
- SENTI-SPIDER → Finnhub provider: relevant news
- Finnhub provider → Finnhub
- FUND-SPIDER → Evidence retrieval: grounded evidence
- Evidence API → Evidence retrieval: evidence query
- Evidence retrieval → Vector index: semantic search
- Corpus ingestion → Vector index: chunks and embeddings
- Corpus ingestion → OpenAI embeddings: generate embeddings
