# ericpang/stockanalysis architecture

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

- Interactive diagram: https://gitdiagram.com/ericpang/stockanalysis
- Repository: https://github.com/ericpang/stockanalysis

## Overview

DayTrade is a multi-market stock research web application for US, China A-share, and Hong Kong equities. A user opens the analysis terminal, selects or searches a ticker, and receives a stock profile that drives quick or deeper views: fundamentals, technical charts, statements, peer benchmarks, valuation, and reports. The dashboard coordinates these analysis stages; an API route and Yahoo Finance adapter supply live data, while the analysis engine computes indicators and valuations. Several feature components are documented in the README and SOURCE INDEX, but their full implementations were not sampled, so only documented or indexed relationships are shown.

Main entry points: [`src/components/DayTradeDashboard.tsx`](https://github.com/ericpang/stockanalysis/blob/main/src/components/DayTradeDashboard.tsx) (Analysis dashboard), [`src/lib/api/yahooFinance.ts`](https://github.com/ericpang/stockanalysis/blob/main/src/lib/api/yahooFinance.ts) (Yahoo adapter), [`src/lib/analysis/engine.ts`](https://github.com/ericpang/stockanalysis/blob/main/src/lib/analysis/engine.ts) (Analysis engine), [`src/app/page.tsx`](https://github.com/ericpang/stockanalysis/blob/main/src/app/page.tsx) (Page loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App entry"]
  node_page["Page loader<br/>[page.tsx]"]
  node_dashboard["Analysis dashboard"]
  node_stock_api["Stock API<br/>[route.ts]"]
end

subgraph group_market["Market data"]
  node_catalog["Market catalog<br/>[stocks.ts]"]
  node_yahoo["Yahoo adapter<br/>[yahooFinance.ts]"]
end

subgraph group_analysis["Analysis views"]
  node_technical["Technical charts<br/>[TechnicalChart.tsx]"]
  node_fundamentals["Fundamental metrics"]
  node_statements["Financial statements"]
  node_valuation["Intrinsic valuation"]
  node_peers["Peer comparison"]
  node_reports["Investment reports"]
  node_custom["Custom analyzer"]
  node_news["Top news<br/>[TopNewsPanel.tsx]"]
end

subgraph group_core["Analysis core"]
  node_types["Stock types<br/>[stock.ts]"]
  node_engine["Analysis engine<br/>[engine.ts]"]
end

node_user(("Investor"))
node_yahoo_service{{"Yahoo Finance"}}

node_user -->|"opens"| node_page
node_page -->|"renders"| node_dashboard
node_page -->|"loads profiles"| node_yahoo
node_page -->|"loads catalog"| node_catalog
node_dashboard -->|"fetches profiles"| node_yahoo
node_dashboard -->|"renders"| node_fundamentals
node_dashboard -->|"renders"| node_technical
node_dashboard -->|"renders"| node_peers
node_dashboard -->|"renders"| node_reports
node_dashboard -->|"renders"| node_custom
node_dashboard -->|"renders"| node_statements
node_dashboard -->|"renders"| node_valuation
node_dashboard -->|"renders"| node_news
node_stock_api -->|"requests data"| node_yahoo
node_stock_api -->|"loads catalog"| node_catalog
node_yahoo -->|"fetches market data"| node_yahoo_service
node_yahoo -->|"computes indicators"| node_engine
node_yahoo -->|"uses baseline"| node_catalog
node_catalog -->|"generates history"| node_engine
node_technical -->|"loads intervals"| node_yahoo
node_technical -->|"uses indicators"| node_engine
node_statements -->|"loads statements"| node_yahoo
node_statements -->|"builds fallback"| node_engine
node_valuation -->|"computes value"| node_engine
node_custom -->|"rates input"| node_engine
node_fundamentals -->|"evaluates metrics"| node_engine
node_reports -->|"uses analysis"| node_engine
node_news -.->|"uses market adapter"| node_yahoo

click node_page "https://github.com/ericpang/stockanalysis/blob/main/src/app/page.tsx"
click node_dashboard "https://github.com/ericpang/stockanalysis/blob/main/src/components/DayTradeDashboard.tsx"
click node_stock_api "https://github.com/ericpang/stockanalysis/blob/main/src/app/api/stock/route.ts"
click node_catalog "https://github.com/ericpang/stockanalysis/blob/main/src/lib/data/stocks.ts"
click node_yahoo "https://github.com/ericpang/stockanalysis/blob/main/src/lib/api/yahooFinance.ts"
click node_types "https://github.com/ericpang/stockanalysis/blob/main/src/lib/types/stock.ts"
click node_engine "https://github.com/ericpang/stockanalysis/blob/main/src/lib/analysis/engine.ts"
click node_technical "https://github.com/ericpang/stockanalysis/blob/main/src/components/charts/TechnicalChart.tsx"
click node_fundamentals "https://github.com/ericpang/stockanalysis/blob/main/src/components/metrics/FundamentalBreakdown.tsx"
click node_statements "https://github.com/ericpang/stockanalysis/blob/main/src/components/statements/FinancialStatementsView.tsx"
click node_valuation "https://github.com/ericpang/stockanalysis/blob/main/src/components/valuation/IntrinsicValueView.tsx"
click node_peers "https://github.com/ericpang/stockanalysis/blob/main/src/components/peers/PeerComparisonView.tsx"
click node_reports "https://github.com/ericpang/stockanalysis/blob/main/src/components/reports/InvestmentReportView.tsx"
click node_custom "https://github.com/ericpang/stockanalysis/blob/main/src/components/custom/CustomStockAnalyzer.tsx"
click node_news "https://github.com/ericpang/stockanalysis/blob/main/src/components/news/TopNewsPanel.tsx"

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_page,node_dashboard,node_stock_api toneBlue
class node_catalog,node_yahoo toneAmber
class node_technical,node_fundamentals,node_statements,node_valuation,node_peers,node_reports,node_custom,node_news toneMint
class node_types,node_engine toneRose
class node_user,node_yahoo_service toneIndigo
```

## Components

### App entry

- [Page loader](https://github.com/ericpang/stockanalysis/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Analysis dashboard](https://github.com/ericpang/stockanalysis/blob/main/src/components/DayTradeDashboard.tsx): `src/components/DayTradeDashboard.tsx`
- [Stock API](https://github.com/ericpang/stockanalysis/blob/main/src/app/api/stock/route.ts): `src/app/api/stock/route.ts`

### Market data

- [Market catalog](https://github.com/ericpang/stockanalysis/blob/main/src/lib/data/stocks.ts): `src/lib/data/stocks.ts`
- [Yahoo adapter](https://github.com/ericpang/stockanalysis/blob/main/src/lib/api/yahooFinance.ts): `src/lib/api/yahooFinance.ts`

### Analysis views

- [Technical charts](https://github.com/ericpang/stockanalysis/blob/main/src/components/charts/TechnicalChart.tsx): `src/components/charts/TechnicalChart.tsx`
- [Fundamental metrics](https://github.com/ericpang/stockanalysis/blob/main/src/components/metrics/FundamentalBreakdown.tsx): `src/components/metrics/FundamentalBreakdown.tsx`
- [Financial statements](https://github.com/ericpang/stockanalysis/blob/main/src/components/statements/FinancialStatementsView.tsx): `src/components/statements/FinancialStatementsView.tsx`
- [Intrinsic valuation](https://github.com/ericpang/stockanalysis/blob/main/src/components/valuation/IntrinsicValueView.tsx): `src/components/valuation/IntrinsicValueView.tsx`
- [Peer comparison](https://github.com/ericpang/stockanalysis/blob/main/src/components/peers/PeerComparisonView.tsx): `src/components/peers/PeerComparisonView.tsx`
- [Investment reports](https://github.com/ericpang/stockanalysis/blob/main/src/components/reports/InvestmentReportView.tsx): `src/components/reports/InvestmentReportView.tsx`
- [Custom analyzer](https://github.com/ericpang/stockanalysis/blob/main/src/components/custom/CustomStockAnalyzer.tsx): `src/components/custom/CustomStockAnalyzer.tsx`
- [Top news](https://github.com/ericpang/stockanalysis/blob/main/src/components/news/TopNewsPanel.tsx): `src/components/news/TopNewsPanel.tsx`

### Analysis core

- [Stock types](https://github.com/ericpang/stockanalysis/blob/main/src/lib/types/stock.ts): `src/lib/types/stock.ts`
- [Analysis engine](https://github.com/ericpang/stockanalysis/blob/main/src/lib/analysis/engine.ts): `src/lib/analysis/engine.ts`

### Other components

- **Investor**
- **Yahoo Finance**

## Connections

- Investor → Page loader: opens (evidence: `README.md`)
- Page loader → Analysis dashboard: renders (evidence: `src/app/page.tsx`)
- Page loader → Yahoo adapter: loads profiles (evidence: `src/app/page.tsx`)
- Page loader → Market catalog: loads catalog (evidence: `src/app/page.tsx`)
- Analysis dashboard → Yahoo adapter: fetches profiles (evidence: `src/components/DayTradeDashboard.tsx`)
- Analysis dashboard → Fundamental metrics: renders (evidence: `src/components/DayTradeDashboard.tsx`)
- Analysis dashboard → Technical charts: renders (evidence: `src/components/DayTradeDashboard.tsx`)
- Analysis dashboard → Peer comparison: renders (evidence: `src/components/DayTradeDashboard.tsx`)
- Analysis dashboard → Investment reports: renders (evidence: `src/components/DayTradeDashboard.tsx`)
- Analysis dashboard → Custom analyzer: renders (evidence: `src/components/DayTradeDashboard.tsx`)
- Analysis dashboard → Financial statements: renders (evidence: `src/components/DayTradeDashboard.tsx`)
- Analysis dashboard → Intrinsic valuation: renders (evidence: `src/components/DayTradeDashboard.tsx`)
- Analysis dashboard → Top news: renders (evidence: `src/components/DayTradeDashboard.tsx`)
- Stock API → Yahoo adapter: requests data (evidence: `src/app/api/stock/route.ts`)
- Stock API → Market catalog: loads catalog (evidence: `src/app/api/stock/route.ts`)
- Yahoo adapter → Yahoo Finance: fetches market data (evidence: `README.md`)
- Yahoo adapter → Analysis engine: computes indicators (evidence: `src/lib/api/yahooFinance.ts`)
- Yahoo adapter → Market catalog: uses baseline (evidence: `src/lib/api/yahooFinance.ts`)
- Market catalog → Analysis engine: generates history (evidence: `src/lib/data/stocks.ts`)
- Technical charts → Yahoo adapter: loads intervals (evidence: `src/components/charts/TechnicalChart.tsx`)
- Technical charts → Analysis engine: uses indicators (evidence: `src/components/charts/TechnicalChart.tsx`)
- Financial statements → Yahoo adapter: loads statements (evidence: `src/components/statements/FinancialStatementsView.tsx`)
- Financial statements → Analysis engine: builds fallback (evidence: `src/components/statements/FinancialStatementsView.tsx`)
- Intrinsic valuation → Analysis engine: computes value (evidence: `src/components/valuation/IntrinsicValueView.tsx`)
- Custom analyzer → Analysis engine: rates input (evidence: `src/components/custom/CustomStockAnalyzer.tsx`)
- Fundamental metrics → Analysis engine: evaluates metrics (evidence: `src/components/metrics/FundamentalBreakdown.tsx`)
- Investment reports → Analysis engine: uses analysis (evidence: `src/components/reports/InvestmentReportView.tsx`)
- Top news → Yahoo adapter: uses market adapter (evidence: `src/components/news/TopNewsPanel.tsx`)
