# yhansol145/stock architecture

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

- Interactive diagram: https://gitdiagram.com/yhansol145/stock
- Repository: https://github.com/yhansol145/stock

## Overview

This is a NestJS REST API and web dashboard for Korean stock analysis. The main user workflow is to request stock lists, search, or ticker details; stock data is fetched from Yahoo Finance, cached and analyzed into technical indicators and trading signals, then returned through the API for the dashboard. Separate branches provide market indices, news, AI recommendations, and per-stock AI analysis, with a cron endpoint refreshing cached stock data. The graph follows documented routes and SOURCE INDEX references; unsampled implementations are represented only where README capabilities support them.

Main entry points: [`src/stock/services/stock-cache.service.ts`](https://github.com/yhansol145/stock/blob/master/src/stock/services/stock-cache.service.ts) (Stock cache), [`src/app.module.ts`](https://github.com/yhansol145/stock/blob/master/src/app.module.ts) (Application modules), [`src/stock/stock.controller.ts`](https://github.com/yhansol145/stock/blob/master/src/stock/stock.controller.ts) (Stock routes), [`src/stock/usecases/get-stock-detail.usecase.ts`](https://github.com/yhansol145/stock/blob/master/src/stock/usecases/get-stock-detail.usecase.ts) (Stock detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_web["Web dashboard<br/>[app.js]"]
  node_api["Vercel API entry<br/>[index.ts]"]
  node_appmodule["Application modules<br/>[app.module.ts]"]
  node_cron["Cache refresh route<br/>[cron.controller.ts]"]
end

subgraph group_stocks["Stock Analysis"]
  node_stockctl["Stock routes"]
  node_stocklist["Stock list"]
  node_stockdetail["Stock detail"]
  node_stocksearch["Stock search"]
  node_universe["Tracked stocks"]
  node_cache[("Stock cache")]
  node_yahoo["Yahoo Finance client"]
  node_indicators["Technical indicators"]
end

subgraph group_market["Market Data"]
  node_marketctl["Market routes"]
  node_marketoverview["Market overview"]
  node_marketdata["Index data"]
end

subgraph group_news["News"]
  node_gnews["GNews client<br/>[gnews.service.ts]"]
  node_newsctl["News routes<br/>[news.controller.ts]"]
  node_getnews["News retrieval"]
  node_translate["News translation"]
end

subgraph group_ai["AI Insights"]
  node_stockai["Stock AI analysis"]
  node_recctl["Recommendation routes"]
  node_recommend["AI recommendations"]
  node_groq["Groq language model<br/>[groq.service.ts]"]
end

node_user(("Dashboard user"))
node_yahooext["Yahoo Finance"]
node_redis[("Upstash Redis")]
node_gnewsext["GNews API"]
node_groqext["Groq API"]

node_user -->|"uses"| node_web
node_web -.->|"requests data"| node_api
node_api -->|"loads"| node_appmodule
node_appmodule -->|"registers"| node_stockctl
node_appmodule -->|"registers"| node_marketctl
node_appmodule -->|"registers"| node_newsctl
node_appmodule -->|"registers"| node_recctl
node_appmodule -->|"registers"| node_cron
node_stockctl -->|"executes"| node_stocklist
node_stockctl -->|"executes"| node_stockdetail
node_stockctl -->|"executes"| node_stocksearch
node_stockctl -->|"executes"| node_stockai
node_stocklist -->|"reads cache"| node_cache
node_stockdetail -->|"reads details"| node_cache
node_stockdetail -->|"fetches quotes"| node_yahoo
node_stockdetail -->|"calculates indicators"| node_indicators
node_stocksearch -->|"searches"| node_universe
node_cache -->|"loads tickers"| node_universe
node_cache -->|"fetches prices"| node_yahoo
node_cache -->|"calculates signals"| node_indicators
node_cache -->|"reads and writes"| node_redis
node_yahoo -->|"requests data"| node_yahooext
node_marketctl -->|"executes"| node_marketoverview
node_marketoverview -->|"gets indices"| node_marketdata
node_marketdata -->|"requests indices"| node_yahooext
node_newsctl -->|"executes"| node_getnews
node_newsctl -->|"executes"| node_translate
node_getnews -->|"fetches articles"| node_gnews
node_gnews -->|"requests news"| node_gnewsext
node_translate -->|"generates translation"| node_groq
node_recctl -->|"executes"| node_recommend
node_recommend -->|"uses stock list"| node_stocklist
node_recommend -->|"fetches news"| node_gnews
node_recommend -->|"generates picks"| node_groq
node_stockai -->|"generates analysis"| node_groq
node_groq -->|"sends prompt"| node_groqext
node_cron -->|"refreshes"| node_cache

click node_web "https://github.com/yhansol145/stock/blob/master/public/js/app.js"
click node_api "https://github.com/yhansol145/stock/blob/master/api/index.ts"
click node_appmodule "https://github.com/yhansol145/stock/blob/master/src/app.module.ts"
click node_stockctl "https://github.com/yhansol145/stock/blob/master/src/stock/stock.controller.ts"
click node_stocklist "https://github.com/yhansol145/stock/blob/master/src/stock/usecases/get-stock-list.usecase.ts"
click node_stockdetail "https://github.com/yhansol145/stock/blob/master/src/stock/usecases/get-stock-detail.usecase.ts"
click node_stocksearch "https://github.com/yhansol145/stock/blob/master/src/stock/usecases/search-stocks.usecase.ts"
click node_stockai "https://github.com/yhansol145/stock/blob/master/src/stock/usecases/get-stock-ai-analysis.usecase.ts"
click node_universe "https://github.com/yhansol145/stock/blob/master/src/stock/constants/kr-stocks.constant.ts"
click node_cache "https://github.com/yhansol145/stock/blob/master/src/stock/services/stock-cache.service.ts"
click node_yahoo "https://github.com/yhansol145/stock/blob/master/src/stock/services/yahoo-finance.service.ts"
click node_indicators "https://github.com/yhansol145/stock/blob/master/src/stock/services/technical-indicator.service.ts"
click node_marketctl "https://github.com/yhansol145/stock/blob/master/src/market/market.controller.ts"
click node_marketoverview "https://github.com/yhansol145/stock/blob/master/src/market/usecases/get-market-overview.usecase.ts"
click node_marketdata "https://github.com/yhansol145/stock/blob/master/src/market/services/market-data.service.ts"
click node_gnews "https://github.com/yhansol145/stock/blob/master/src/news/services/gnews.service.ts"
click node_newsctl "https://github.com/yhansol145/stock/blob/master/src/news/news.controller.ts"
click node_getnews "https://github.com/yhansol145/stock/blob/master/src/news/usecases/get-news.usecase.ts"
click node_translate "https://github.com/yhansol145/stock/blob/master/src/news/usecases/translate-news.usecase.ts"
click node_recctl "https://github.com/yhansol145/stock/blob/master/src/recommendation/recommendation.controller.ts"
click node_recommend "https://github.com/yhansol145/stock/blob/master/src/recommendation/usecases/get-recommendations.usecase.ts"
click node_groq "https://github.com/yhansol145/stock/blob/master/src/recommendation/services/groq.service.ts"
click node_cron "https://github.com/yhansol145/stock/blob/master/src/cron/cron.controller.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_web,node_api,node_appmodule,node_cron,node_user toneBlue
class node_stockctl,node_stocklist,node_stockdetail,node_stocksearch,node_universe,node_cache,node_yahoo,node_indicators,node_redis toneAmber
class node_marketctl,node_marketoverview,node_marketdata,node_gnewsext,node_groqext toneMint
class node_gnews,node_newsctl,node_getnews,node_translate toneRose
class node_stockai,node_recctl,node_recommend,node_groq,node_yahooext toneIndigo
```

## Components

### Application

- [Web dashboard](https://github.com/yhansol145/stock/blob/master/public/js/app.js): `public/js/app.js`
- [Vercel API entry](https://github.com/yhansol145/stock/blob/master/api/index.ts): `api/index.ts`
- [Application modules](https://github.com/yhansol145/stock/blob/master/src/app.module.ts): `src/app.module.ts`
- [Cache refresh route](https://github.com/yhansol145/stock/blob/master/src/cron/cron.controller.ts): `src/cron/cron.controller.ts`

### Stock Analysis

- [Stock routes](https://github.com/yhansol145/stock/blob/master/src/stock/stock.controller.ts): `src/stock/stock.controller.ts`
- [Stock list](https://github.com/yhansol145/stock/blob/master/src/stock/usecases/get-stock-list.usecase.ts): `src/stock/usecases/get-stock-list.usecase.ts`
- [Stock detail](https://github.com/yhansol145/stock/blob/master/src/stock/usecases/get-stock-detail.usecase.ts): `src/stock/usecases/get-stock-detail.usecase.ts`
- [Stock search](https://github.com/yhansol145/stock/blob/master/src/stock/usecases/search-stocks.usecase.ts): `src/stock/usecases/search-stocks.usecase.ts`
- [Tracked stocks](https://github.com/yhansol145/stock/blob/master/src/stock/constants/kr-stocks.constant.ts): `src/stock/constants/kr-stocks.constant.ts`
- [Stock cache](https://github.com/yhansol145/stock/blob/master/src/stock/services/stock-cache.service.ts): `src/stock/services/stock-cache.service.ts`
- [Yahoo Finance client](https://github.com/yhansol145/stock/blob/master/src/stock/services/yahoo-finance.service.ts): `src/stock/services/yahoo-finance.service.ts`
- [Technical indicators](https://github.com/yhansol145/stock/blob/master/src/stock/services/technical-indicator.service.ts): `src/stock/services/technical-indicator.service.ts`

### Market Data

- [Market routes](https://github.com/yhansol145/stock/blob/master/src/market/market.controller.ts): `src/market/market.controller.ts`
- [Market overview](https://github.com/yhansol145/stock/blob/master/src/market/usecases/get-market-overview.usecase.ts): `src/market/usecases/get-market-overview.usecase.ts`
- [Index data](https://github.com/yhansol145/stock/blob/master/src/market/services/market-data.service.ts): `src/market/services/market-data.service.ts`

### News

- [GNews client](https://github.com/yhansol145/stock/blob/master/src/news/services/gnews.service.ts): `src/news/services/gnews.service.ts`
- [News routes](https://github.com/yhansol145/stock/blob/master/src/news/news.controller.ts): `src/news/news.controller.ts`
- [News retrieval](https://github.com/yhansol145/stock/blob/master/src/news/usecases/get-news.usecase.ts): `src/news/usecases/get-news.usecase.ts`
- [News translation](https://github.com/yhansol145/stock/blob/master/src/news/usecases/translate-news.usecase.ts): `src/news/usecases/translate-news.usecase.ts`

### AI Insights

- [Stock AI analysis](https://github.com/yhansol145/stock/blob/master/src/stock/usecases/get-stock-ai-analysis.usecase.ts): `src/stock/usecases/get-stock-ai-analysis.usecase.ts`
- [Recommendation routes](https://github.com/yhansol145/stock/blob/master/src/recommendation/recommendation.controller.ts): `src/recommendation/recommendation.controller.ts`
- [AI recommendations](https://github.com/yhansol145/stock/blob/master/src/recommendation/usecases/get-recommendations.usecase.ts): `src/recommendation/usecases/get-recommendations.usecase.ts`
- [Groq language model](https://github.com/yhansol145/stock/blob/master/src/recommendation/services/groq.service.ts): `src/recommendation/services/groq.service.ts`

### Other components

- **Dashboard user**
- **Yahoo Finance**
- **Upstash Redis**
- **GNews API**
- **Groq API**

## Connections

- Dashboard user → Web dashboard: uses (evidence: `README.md`)
- Web dashboard → Vercel API entry: requests data
- Vercel API entry → Application modules: loads (evidence: `api/index.ts`)
- Application modules → Stock routes: registers (evidence: `src/app.module.ts`)
- Application modules → Market routes: registers (evidence: `src/app.module.ts`)
- Application modules → News routes: registers (evidence: `src/app.module.ts`)
- Application modules → Recommendation routes: registers (evidence: `src/app.module.ts`)
- Application modules → Cache refresh route: registers (evidence: `src/app.module.ts`)
- Stock routes → Stock list: executes (evidence: `src/stock/stock.controller.ts`)
- Stock routes → Stock detail: executes (evidence: `src/stock/stock.controller.ts`)
- Stock routes → Stock search: executes (evidence: `src/stock/stock.controller.ts`)
- Stock routes → Stock AI analysis: executes (evidence: `src/stock/stock.controller.ts`)
- Stock list → Stock cache: reads cache (evidence: `src/stock/usecases/get-stock-list.usecase.ts`)
- Stock detail → Stock cache: reads details (evidence: `src/stock/usecases/get-stock-detail.usecase.ts`)
- Stock detail → Yahoo Finance client: fetches quotes (evidence: `src/stock/usecases/get-stock-detail.usecase.ts`)
- Stock detail → Technical indicators: calculates indicators (evidence: `src/stock/usecases/get-stock-detail.usecase.ts`)
- Stock search → Tracked stocks: searches (evidence: `src/stock/usecases/search-stocks.usecase.ts`)
- Stock cache → Tracked stocks: loads tickers (evidence: `src/stock/services/stock-cache.service.ts`)
- Stock cache → Yahoo Finance client: fetches prices (evidence: `src/stock/services/stock-cache.service.ts`)
- Stock cache → Technical indicators: calculates signals (evidence: `src/stock/services/stock-cache.service.ts`)
- Stock cache → Upstash Redis: reads and writes (evidence: `README.md`)
- Yahoo Finance client → Yahoo Finance: requests data (evidence: `src/stock/services/yahoo-finance.service.ts`)
- Market routes → Market overview: executes (evidence: `src/market/market.controller.ts`)
- Market overview → Index data: gets indices (evidence: `src/market/usecases/get-market-overview.usecase.ts`)
- Index data → Yahoo Finance: requests indices (evidence: `src/market/services/market-data.service.ts`)
- News routes → News retrieval: executes (evidence: `src/news/news.controller.ts`)
- News routes → News translation: executes (evidence: `src/news/news.controller.ts`)
- News retrieval → GNews client: fetches articles (evidence: `src/news/usecases/get-news.usecase.ts`)
- GNews client → GNews API: requests news (evidence: `src/news/services/gnews.service.ts`)
- News translation → Groq language model: generates translation (evidence: `src/news/usecases/translate-news.usecase.ts`)
- Recommendation routes → AI recommendations: executes (evidence: `src/recommendation/recommendation.controller.ts`)
- AI recommendations → Stock list: uses stock list (evidence: `src/recommendation/usecases/get-recommendations.usecase.ts`)
- AI recommendations → GNews client: fetches news (evidence: `src/recommendation/usecases/get-recommendations.usecase.ts`)
- AI recommendations → Groq language model: generates picks (evidence: `src/recommendation/usecases/get-recommendations.usecase.ts`)
- Stock AI analysis → Groq language model: generates analysis (evidence: `src/stock/usecases/get-stock-ai-analysis.usecase.ts`)
- Groq language model → Groq API: sends prompt (evidence: `src/recommendation/services/groq.service.ts`)
- Cache refresh route → Stock cache: refreshes (evidence: `src/cron/cron.controller.ts`)
