# scybl/newsanalysis architecture

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

- Interactive diagram: https://gitdiagram.com/scybl/newsanalysis
- Repository: https://github.com/scybl/newsanalysis

## Overview

ValueScope DataHub collects and organizes stock, market, and news data, then exposes it through an administrative web console for users and downstream ValueScope analysis. The main stock path is collection, package construction, and hot/cold storage; the news crawler is a separate service that writes standardized news data for DataHub to display. Governance, task operations, and access controls support the platform. Relationships use README statements and SOURCE INDEX references; unsampled implementation details are not assumed.

Main entry points: [`stock_pipeline/stock_storage.py`](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/stock_storage.py) (Stock packages), [`stock_pipeline/web.py`](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/web.py) (Web API), [`stock_pipeline/collector.py`](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/collector.py) (Stock collector), [`NewsCrawler/src/news_crawler/executor.py`](https://github.com/scybl/newsanalysis/blob/main/NewsCrawler/src/news_crawler/executor.py) (Crawl executor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_admin_ui["Admin console<br/>[app.js]"]
  node_web_api["Web API<br/>[web.py]"]
end

subgraph group_stock["Stock data"]
  node_stock_search["Stock search<br/>[stock_search.py]"]
  node_collector["Stock collector<br/>[collector.py]"]
  node_dossier["Stock dossier<br/>[dossier.py]"]
  node_stock_storage["Stock packages<br/>[stock_storage.py]"]
end

subgraph group_market["Market data"]
  node_data_sources["Market data clients<br/>[data_sources.py]"]
  node_tushare["Tushare client<br/>[tushare_client.py]"]
  node_market_dimensions["Market collections"]
  node_minute_storage["Minute storage<br/>[minute_storage.py]"]
  node_cold_storage["Cold archive"]
end

subgraph group_news["News collection"]
  node_news_search["News search<br/>[news_search.py]"]
  node_crawl_pipeline["Crawl pipeline<br/>[pipeline.py]"]
  node_crawl_executor["Crawl executor<br/>[executor.py]"]
  node_news_providers["News providers"]
  node_news_mongo[("News repository")]
end

subgraph group_platform["Governance and storage"]
  node_auth["Access policy<br/>[auth_policy.py]"]
  node_mongo_data[("Mongo data access")]
  node_task_queue["Background tasks<br/>[task_queue.py]"]
  node_quality["Data quality<br/>[data_quality.py]"]
end

node_user(("Data user"))
node_baidu["Baidu Netdisk"]
node_news_db[("MongoDB news")]

node_user -->|"uses"| node_admin_ui
node_admin_ui -->|"requests data"| node_web_api
node_web_api -->|"enforces access"| node_auth
node_web_api -.->|"serves lookup"| node_stock_search
node_web_api -.->|"serves stock data"| node_stock_storage
node_collector -->|"queries"| node_tushare
node_collector -.->|"uses sources"| node_data_sources
node_collector -.->|"builds package data"| node_dossier
node_stock_storage -->|"collects data"| node_collector
node_stock_storage -->|"builds dossier"| node_dossier
node_stock_storage -->|"syncs packages"| node_mongo_data
node_mongo_data -->|"uses collections"| node_market_dimensions
node_stock_storage -->|"reads minute data"| node_minute_storage
node_minute_storage -->|"reads archive"| node_cold_storage
node_cold_storage -->|"archives history"| node_baidu
node_task_queue -.->|"schedules collection"| node_collector
node_quality -.->|"checks integrity"| node_stock_storage
node_crawl_pipeline -->|"dispatches"| node_crawl_executor
node_crawl_executor -->|"fetches articles"| node_news_providers
node_crawl_executor -->|"stores articles"| node_news_mongo
node_news_mongo -->|"writes news"| node_news_db
node_web_api -.->|"serves news"| node_news_search
node_news_search -.->|"reads news"| node_news_db

click node_admin_ui "https://github.com/scybl/newsanalysis/blob/main/frontend/admin/app.js"
click node_web_api "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/web.py"
click node_auth "https://github.com/scybl/newsanalysis/blob/main/backend/auth_policy.py"
click node_stock_search "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/stock_search.py"
click node_collector "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/collector.py"
click node_data_sources "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/data_sources.py"
click node_tushare "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/tushare_client.py"
click node_dossier "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/dossier.py"
click node_stock_storage "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/stock_storage.py"
click node_mongo_data "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/local_data_mongo.py"
click node_market_dimensions "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/market_dimensions.py"
click node_minute_storage "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/minute_storage.py"
click node_cold_storage "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/minute_cold_storage.py"
click node_task_queue "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/task_queue.py"
click node_quality "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/data_quality.py"
click node_news_search "https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/news_search.py"
click node_crawl_pipeline "https://github.com/scybl/newsanalysis/blob/main/NewsCrawler/src/news_crawler/pipeline.py"
click node_crawl_executor "https://github.com/scybl/newsanalysis/blob/main/NewsCrawler/src/news_crawler/executor.py"
click node_news_providers "https://github.com/scybl/newsanalysis/tree/main/NewsCrawler/src/news_crawler/providers"
click node_news_mongo "https://github.com/scybl/newsanalysis/blob/main/NewsCrawler/src/news_crawler/mongo_repository.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_admin_ui,node_web_api,node_user toneBlue
class node_stock_search,node_collector,node_dossier,node_stock_storage,node_news_db toneAmber
class node_data_sources,node_tushare,node_market_dimensions,node_minute_storage,node_cold_storage toneMint
class node_news_search,node_crawl_pipeline,node_crawl_executor,node_news_providers,node_news_mongo toneRose
class node_auth,node_mongo_data,node_task_queue,node_quality,node_baidu toneIndigo
```

## Components

### Web experience

- [Admin console](https://github.com/scybl/newsanalysis/blob/main/frontend/admin/app.js): `frontend/admin/app.js`
- [Web API](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/web.py): `stock_pipeline/web.py`

### Stock data

- [Stock search](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/stock_search.py): `stock_pipeline/stock_search.py`
- [Stock collector](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/collector.py): `stock_pipeline/collector.py`
- [Stock dossier](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/dossier.py): `stock_pipeline/dossier.py`
- [Stock packages](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/stock_storage.py): `stock_pipeline/stock_storage.py`

### Market data

- [Market data clients](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/data_sources.py): `stock_pipeline/data_sources.py`
- [Tushare client](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/tushare_client.py): `stock_pipeline/tushare_client.py`
- [Market collections](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/market_dimensions.py): `stock_pipeline/market_dimensions.py`
- [Minute storage](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/minute_storage.py): `stock_pipeline/minute_storage.py`
- [Cold archive](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/minute_cold_storage.py): `stock_pipeline/minute_cold_storage.py`

### News collection

- [News search](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/news_search.py): `stock_pipeline/news_search.py`
- [Crawl pipeline](https://github.com/scybl/newsanalysis/blob/main/NewsCrawler/src/news_crawler/pipeline.py): `NewsCrawler/src/news_crawler/pipeline.py`
- [Crawl executor](https://github.com/scybl/newsanalysis/blob/main/NewsCrawler/src/news_crawler/executor.py): `NewsCrawler/src/news_crawler/executor.py`
- [News providers](https://github.com/scybl/newsanalysis/tree/main/NewsCrawler/src/news_crawler/providers): `NewsCrawler/src/news_crawler/providers`
- [News repository](https://github.com/scybl/newsanalysis/blob/main/NewsCrawler/src/news_crawler/mongo_repository.py): `NewsCrawler/src/news_crawler/mongo_repository.py`

### Governance and storage

- [Access policy](https://github.com/scybl/newsanalysis/blob/main/backend/auth_policy.py): `backend/auth_policy.py`
- [Mongo data access](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/local_data_mongo.py): `stock_pipeline/local_data_mongo.py`
- [Background tasks](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/task_queue.py): `stock_pipeline/task_queue.py`
- [Data quality](https://github.com/scybl/newsanalysis/blob/main/stock_pipeline/data_quality.py): `stock_pipeline/data_quality.py`

### Other components

- **Data user**
- **Baidu Netdisk**
- **MongoDB news**

## Connections

- Data user → Admin console: uses (evidence: `README.md`)
- Admin console → Web API: requests data (evidence: `README.md`)
- Web API → Access policy: enforces access (evidence: `README.md`)
- Web API → Stock search: serves lookup
- Web API → Stock packages: serves stock data
- Stock collector → Tushare client: queries (evidence: `stock_pipeline/collector.py`)
- Stock collector → Market data clients: uses sources
- Stock collector → Stock dossier: builds package data
- Stock packages → Stock collector: collects data (evidence: `stock_pipeline/stock_storage.py`)
- Stock packages → Stock dossier: builds dossier (evidence: `stock_pipeline/stock_storage.py`)
- Stock packages → Mongo data access: syncs packages (evidence: `stock_pipeline/stock_storage.py`)
- Mongo data access → Market collections: uses collections (evidence: `stock_pipeline/local_data_mongo.py`)
- Stock packages → Minute storage: reads minute data (evidence: `stock_pipeline/stock_storage.py`)
- Minute storage → Cold archive: reads archive (evidence: `stock_pipeline/minute_storage.py`)
- Cold archive → Baidu Netdisk: archives history (evidence: `README.md`)
- Background tasks → Stock collector: schedules collection
- Data quality → Stock packages: checks integrity
- Crawl pipeline → Crawl executor: dispatches (evidence: `NewsCrawler/src/news_crawler/pipeline.py`)
- Crawl executor → News providers: fetches articles (evidence: `NewsCrawler/src/news_crawler/executor.py`)
- Crawl executor → News repository: stores articles (evidence: `NewsCrawler/src/news_crawler/executor.py`)
- News repository → MongoDB news: writes news (evidence: `README.md`)
- Web API → News search: serves news
- News search → MongoDB news: reads news (evidence: `README.md`)
