# gbo0101/taiwan_stock_analysing_ai architecture

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

- Interactive diagram: https://gitdiagram.com/gbo0101/taiwan_stock_analysing_ai
- Repository: https://github.com/gbo0101/taiwan_stock_analysing_ai

## Overview

This is a Taiwan-stock natural-language query product that turns a question into structured scope, query classification, optional analytical sub-queries, stock or supply-chain results, and charts. The README documents a strict sequential pipeline and a browser/API and CLI experience. The graph includes the documented range and annual-report supply-chain branches alongside charting. Some links rely on README documentation or the SOURCE INDEX because the corresponding implementation excerpts were not provided; those limits are reflected by omitted or dashed edges.

Main entry points: [`classifier/pipeline.py`](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/pipeline.py) (Pipeline Runner), [`classifier/stock_enumeration.py`](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_enumeration.py) (Stock Enumeration), [`classifier/annual_report.py`](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/annual_report.py) (Annual Report Extraction), [`classifier/chart_renderer.py`](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/chart_renderer.py) (Chart Renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_web["Web Client<br/>[app.js]"]
  node_api["HTTP API<br/>[api.py]"]
  node_cli["CLI<br/>[cli.py]"]
end

subgraph group_query["Query Pipeline"]
  node_pipeline["Pipeline Runner<br/>[pipeline.py]"]
  node_boundary["Boundary Extraction<br/>[boundary.py]"]
  node_classification["Query Classification<br/>[classification.py]"]
  node_decomposition["Analysis Decomposition<br/>[decomposition.py]"]
  node_summary["Query Summary"]
end

subgraph group_stocks["Stock Intelligence"]
  node_enumeration["Stock Enumeration"]
  node_annual["Annual Report Extraction<br/>[annual_report.py]"]
  node_resolver["Stock Resolver<br/>[stock_resolver.py]"]
  node_isin["ISIN Listings<br/>[isin_client.py]"]
  node_doc_twse["TWSE Document Client<br/>[doc_twse_client.py]"]
end

subgraph group_charts["Market Data &amp; Charts"]
  node_chart_validation["Chart Requirements<br/>[chart_validator.py]"]
  node_chart_renderer["Chart Renderer<br/>[chart_renderer.py]"]
  node_data_fetcher["TWSE Data Fetcher<br/>[data_fetcher.py]"]
  node_finmind["FinMind Client<br/>[finmind_client.py]"]
end

subgraph group_shared["Shared Services"]
  node_llm["LLM Client<br/>[llm_client.py]"]
  node_prompts["Prompt Manager<br/>[prompts.py]"]
  node_models["Pipeline Contracts<br/>[models.py]"]
  node_cache[("TTL Cache<br/>[stock_cache.py]")]
end

node_user(("Investor"))
node_llm_service{{"OpenAI-Compatible LLM"}}
node_twse{{"TWSE Services"}}

node_user -->|"asks"| node_web
node_web -->|"calls API"| node_api
node_user -->|"submits query"| node_cli
node_api -->|"runs"| node_pipeline
node_cli -->|"runs"| node_pipeline
node_pipeline -->|"extracts scope"| node_boundary
node_pipeline -->|"classifies"| node_classification
node_pipeline -->|"decomposes analysis"| node_decomposition
node_pipeline -->|"enumerates stocks"| node_enumeration
node_pipeline -->|"builds summary"| node_summary
node_boundary -->|"derives requirements"| node_chart_validation
node_api -->|"renders chart"| node_chart_renderer
node_cli -->|"renders chart"| node_chart_renderer
node_chart_renderer -->|"fetches market data"| node_data_fetcher
node_chart_renderer -.->|"fetches revenue data"| node_finmind
node_enumeration -->|"gets listings"| node_isin
node_enumeration -->|"checks disclosures"| node_annual
node_enumeration -->|"validates stocks"| node_resolver
node_annual -->|"downloads reports"| node_doc_twse
node_annual -->|"extracts counterparties"| node_llm
node_annual -->|"resolves names"| node_resolver
node_isin -->|"uses cache"| node_cache
node_doc_twse -->|"uses cache"| node_cache
node_llm -->|"requests structured output"| node_llm_service
node_data_fetcher -.->|"fetches market data"| node_twse
node_isin -->|"fetches listings"| node_twse
node_doc_twse -->|"fetches reports"| node_twse

click node_web "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/frontend/app.js"
click node_api "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/api.py"
click node_cli "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/cli.py"
click node_pipeline "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/pipeline.py"
click node_boundary "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/boundary.py"
click node_classification "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/classification.py"
click node_decomposition "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/decomposition.py"
click node_summary "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_enumeration.py"
click node_enumeration "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_enumeration.py"
click node_annual "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/annual_report.py"
click node_resolver "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_resolver.py"
click node_isin "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/isin_client.py"
click node_doc_twse "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/doc_twse_client.py"
click node_chart_validation "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/chart_validator.py"
click node_chart_renderer "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/chart_renderer.py"
click node_data_fetcher "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/data_fetcher.py"
click node_finmind "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/finmind_client.py"
click node_llm "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/llm_client.py"
click node_prompts "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/prompts.py"
click node_models "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/models.py"
click node_cache "https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_cache.py"

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_cli toneBlue
class node_pipeline,node_boundary,node_classification,node_decomposition,node_summary toneAmber
class node_enumeration,node_annual,node_resolver,node_isin,node_doc_twse toneMint
class node_chart_validation,node_chart_renderer,node_data_fetcher,node_finmind toneRose
class node_llm,node_prompts,node_models,node_cache,node_user,node_llm_service,node_twse toneIndigo
```

## Components

### User Experience

- [Web Client](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/frontend/app.js): `frontend/app.js`
- [HTTP API](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/api.py): `classifier/api.py`
- [CLI](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/cli.py): `classifier/cli.py`

### Query Pipeline

- [Pipeline Runner](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/pipeline.py): `classifier/pipeline.py`
- [Boundary Extraction](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/boundary.py): `classifier/boundary.py`
- [Query Classification](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/classification.py): `classifier/classification.py`
- [Analysis Decomposition](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/decomposition.py): `classifier/decomposition.py`
- [Query Summary](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_enumeration.py): `classifier/stock_enumeration.py`

### Stock Intelligence

- [Stock Enumeration](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_enumeration.py): `classifier/stock_enumeration.py`
- [Annual Report Extraction](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/annual_report.py): `classifier/annual_report.py`
- [Stock Resolver](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_resolver.py): `classifier/stock_resolver.py`
- [ISIN Listings](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/isin_client.py): `classifier/isin_client.py`
- [TWSE Document Client](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/doc_twse_client.py): `classifier/doc_twse_client.py`

### Market Data & Charts

- [Chart Requirements](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/chart_validator.py): `classifier/chart_validator.py`
- [Chart Renderer](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/chart_renderer.py): `classifier/chart_renderer.py`
- [TWSE Data Fetcher](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/data_fetcher.py): `classifier/data_fetcher.py`
- [FinMind Client](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/finmind_client.py): `classifier/finmind_client.py`

### Shared Services

- [LLM Client](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/llm_client.py): `classifier/llm_client.py`
- [Prompt Manager](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/prompts.py): `classifier/prompts.py`
- [Pipeline Contracts](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/models.py): `classifier/models.py`
- [TTL Cache](https://github.com/gbo0101/taiwan_stock_analysing_ai/blob/master/classifier/stock_cache.py): `classifier/stock_cache.py`

### Other components

- **Investor**
- **OpenAI-Compatible LLM**
- **TWSE Services**

## Connections

- Investor → Web Client: asks (evidence: `README.md`)
- Web Client → HTTP API: calls API (evidence: `README.md`)
- Investor → CLI: submits query (evidence: `README.md`)
- HTTP API → Pipeline Runner: runs (evidence: `classifier/api.py`)
- CLI → Pipeline Runner: runs (evidence: `classifier/cli.py`)
- Pipeline Runner → Boundary Extraction: extracts scope (evidence: `classifier/pipeline.py`)
- Pipeline Runner → Query Classification: classifies (evidence: `classifier/pipeline.py`)
- Pipeline Runner → Analysis Decomposition: decomposes analysis (evidence: `README.md`)
- Pipeline Runner → Stock Enumeration: enumerates stocks (evidence: `classifier/pipeline.py`)
- Pipeline Runner → Query Summary: builds summary (evidence: `README.md`)
- Boundary Extraction → Chart Requirements: derives requirements (evidence: `classifier/boundary.py`)
- HTTP API → Chart Renderer: renders chart (evidence: `classifier/api.py`)
- CLI → Chart Renderer: renders chart (evidence: `classifier/cli.py`)
- Chart Renderer → TWSE Data Fetcher: fetches market data (evidence: `classifier/chart_renderer.py`)
- Chart Renderer → FinMind Client: fetches revenue data (evidence: `README.md`)
- Stock Enumeration → ISIN Listings: gets listings (evidence: `classifier/stock_enumeration.py`)
- Stock Enumeration → Annual Report Extraction: checks disclosures (evidence: `classifier/stock_enumeration.py`)
- Stock Enumeration → Stock Resolver: validates stocks (evidence: `classifier/stock_enumeration.py`)
- Annual Report Extraction → TWSE Document Client: downloads reports (evidence: `classifier/annual_report.py`)
- Annual Report Extraction → LLM Client: extracts counterparties (evidence: `classifier/annual_report.py`)
- Annual Report Extraction → Stock Resolver: resolves names (evidence: `classifier/annual_report.py`)
- ISIN Listings → TTL Cache: uses cache (evidence: `classifier/isin_client.py`)
- TWSE Document Client → TTL Cache: uses cache (evidence: `classifier/doc_twse_client.py`)
- LLM Client → OpenAI-Compatible LLM: requests structured output (evidence: `classifier/llm_client.py`)
- TWSE Data Fetcher → TWSE Services: fetches market data (evidence: `README.md`)
- ISIN Listings → TWSE Services: fetches listings (evidence: `classifier/isin_client.py`)
- TWSE Document Client → TWSE Services: fetches reports (evidence: `classifier/doc_twse_client.py`)
