# zhysh3/a-share-monitor architecture

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

- Interactive diagram: https://gitdiagram.com/zhysh3/a-share-monitor
- Repository: https://github.com/zhysh3/a-share-monitor

## Overview

A-RISK/MONITOR is a locally served A-share market-risk dashboard. After market close, scheduled checks can invoke the updater, which fetches and normalizes daily and monthly indicators, preserves prior values as stale on failures, and writes a JSON snapshot. The dashboard presents valuation, macro, trading, flows, sectors, and a two-stage-funnel position recommendation; its browser can also use the local proxy for intraday requests and optional MX queries. Dashboard and feature wiring is based on the README because the HTML source was not sampled.

Main entry points: [`arisk_monitor_local.html`](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html) (Risk dashboard), [`update_arisk_data.py`](https://github.com/zhysh3/a-share-monitor/blob/main/update_arisk_data.py) (Snapshot updater), [`proxy.py`](https://github.com/zhysh3/a-share-monitor/blob/main/proxy.py) (Local proxy), [`arisk_data.json`](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_data.json) (Risk data snapshot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_dashboard_page["Risk dashboard"]
  node_valuation["Valuation metrics"]
  node_macro["Macro signals"]
  node_market_activity["Market activity"]
  node_flows["Fund flows"]
  node_sectors["Sector heatmap"]
  node_decision["Position model"]
end

subgraph group_collection["Data collection"]
  node_updater["Snapshot updater"]
  node_snapshot[("Risk data snapshot<br/>[arisk_data.json]")]
  node_backtest["ERP backtest<br/>[backtest_erp.py]"]
end

subgraph group_delivery["Local delivery"]
  node_proxy["Local proxy<br/>[proxy.py]"]
end

subgraph group_automation["Daily automation"]
  node_scheduler(("Daily scheduler"))
  node_update_check["Freshness check"]
end

subgraph group_sources["External data"]
  node_market_sources["Market data sources"]
  node_pboc["PBoC data"]
  node_mx["MX API"]
end

node_investor(("Investor"))
node_browser(("Browser"))

node_investor -->|"views"| node_dashboard_page
node_dashboard_page -->|"presents"| node_valuation
node_dashboard_page -->|"presents"| node_macro
node_dashboard_page -->|"presents"| node_market_activity
node_dashboard_page -->|"presents"| node_flows
node_dashboard_page -->|"presents"| node_sectors
node_dashboard_page -->|"computes"| node_decision
node_dashboard_page -->|"loads"| node_snapshot
node_scheduler -->|"runs"| node_update_check
node_update_check -->|"invokes if stale"| node_updater
node_updater -->|"fetches indicators"| node_market_sources
node_updater -->|"fetches credit data"| node_pboc
node_updater -.->|"fallback query"| node_mx
node_updater -->|"writes snapshot"| node_snapshot
node_backtest -->|"fetches history"| node_market_sources
node_browser -->|"requests data"| node_proxy
node_dashboard_page -->|"requests live data"| node_proxy
node_proxy -->|"reads snapshot"| node_snapshot
node_proxy -->|"forwards requests"| node_market_sources
node_proxy -.->|"forwards queries"| node_mx

click node_dashboard_page "https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html"
click node_valuation "https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html"
click node_macro "https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html"
click node_market_activity "https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html"
click node_flows "https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html"
click node_sectors "https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html"
click node_decision "https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html"
click node_updater "https://github.com/zhysh3/a-share-monitor/blob/main/update_arisk_data.py"
click node_snapshot "https://github.com/zhysh3/a-share-monitor/blob/main/arisk_data.json"
click node_backtest "https://github.com/zhysh3/a-share-monitor/blob/main/backtest_erp.py"
click node_proxy "https://github.com/zhysh3/a-share-monitor/blob/main/proxy.py"
click node_update_check "https://github.com/zhysh3/a-share-monitor/blob/main/check_and_update.sh"

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_page,node_valuation,node_macro,node_market_activity,node_flows,node_sectors,node_decision,node_browser toneBlue
class node_updater,node_snapshot,node_backtest toneAmber
class node_proxy toneMint
class node_scheduler,node_update_check toneRose
class node_market_sources,node_pboc,node_mx,node_investor toneIndigo
```

## Components

### Dashboard

- [Risk dashboard](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html): `arisk_monitor_local.html`
- [Valuation metrics](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html): `arisk_monitor_local.html`
- [Macro signals](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html): `arisk_monitor_local.html`
- [Market activity](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html): `arisk_monitor_local.html`
- [Fund flows](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html): `arisk_monitor_local.html`
- [Sector heatmap](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html): `arisk_monitor_local.html`
- [Position model](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_monitor_local.html): `arisk_monitor_local.html`

### Data collection

- [Snapshot updater](https://github.com/zhysh3/a-share-monitor/blob/main/update_arisk_data.py): `update_arisk_data.py`
- [Risk data snapshot](https://github.com/zhysh3/a-share-monitor/blob/main/arisk_data.json): `arisk_data.json`
- [ERP backtest](https://github.com/zhysh3/a-share-monitor/blob/main/backtest_erp.py): `backtest_erp.py`

### Local delivery

- [Local proxy](https://github.com/zhysh3/a-share-monitor/blob/main/proxy.py): `proxy.py`

### Daily automation

- **Daily scheduler**
- [Freshness check](https://github.com/zhysh3/a-share-monitor/blob/main/check_and_update.sh): `check_and_update.sh`

### External data

- **Market data sources**
- **PBoC data**
- **MX API**

### Other components

- **Investor**
- **Browser**

## Connections

- Investor → Risk dashboard: views
- Risk dashboard → Valuation metrics: presents
- Risk dashboard → Macro signals: presents
- Risk dashboard → Market activity: presents
- Risk dashboard → Fund flows: presents
- Risk dashboard → Sector heatmap: presents
- Risk dashboard → Position model: computes
- Risk dashboard → Risk data snapshot: loads
- Daily scheduler → Freshness check: runs
- Freshness check → Snapshot updater: invokes if stale
- Snapshot updater → Market data sources: fetches indicators
- Snapshot updater → PBoC data: fetches credit data
- Snapshot updater → MX API: fallback query
- Snapshot updater → Risk data snapshot: writes snapshot
- ERP backtest → Market data sources: fetches history
- Browser → Local proxy: requests data
- Risk dashboard → Local proxy: requests live data
- Local proxy → Risk data snapshot: reads snapshot
- Local proxy → Market data sources: forwards requests
- Local proxy → MX API: forwards queries
