# panghu11033/thsdk architecture

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

- Interactive diagram: https://gitdiagram.com/panghu11033/thsdk
- Repository: https://github.com/panghu11033/thsdk

## Overview

THSDK is a synchronous Python securities-data SDK. Users authenticate, call a convenience or standard API, and receive decoded results—often DataFrames—for analysis; account watchlist APIs also support remote writes. The facade adapts convenient inputs and results, while domain wrappers normalize requests through a shared base into a session and native runtime bridge. The README documents broad market, discovery, news, Wencai, ranking, and account capabilities. Some domain implementations were not sampled, so their relationships are shown only where imports or documentation support them.

Main entry points: [`src/thsdk/api.py`](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/api.py) (API facade), [`src/thsdk/_apis/_base.py`](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/_base.py) (Request normalization), [`src/thsdk/session.py`](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/session.py) (Session client), [`src/thsdk/_apis/account.py`](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/account.py) (Account APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public API"]
  node_facade["API facade<br/>[api.py]"]
  node_manifest["Method manifest"]
end

subgraph group_auth["Authentication"]
  node_session["Session client<br/>[session.py]"]
  node_qr["QR display<br/>[_qr_display.py]"]
  node_temporary["Temporary accounts"]
end

subgraph group_domain["Data Domains"]
  node_account["Account APIs<br/>[account.py]"]
  node_securities["Security directory<br/>[securities.py]"]
  node_market["Market data<br/>[market_data.py]"]
  node_news["News and events<br/>[news.py]"]
  node_wencai["Wencai queries<br/>[wencai.py]"]
  node_rankings["Rankings<br/>[rankings.py]"]
end

subgraph group_transport["Request Runtime"]
  node_base["Request normalization<br/>[_base.py]"]
  node_runtime["Native bridge<br/>[_runtime.py]"]
  node_errors["SDK errors<br/>[exceptions.py]"]
end

node_user(("Python user"))
node_native["THSDK runtime component"]

node_user -->|"calls"| node_facade
node_facade -->|"uses metadata"| node_manifest
node_facade -->|"exposes APIs"| node_account
node_facade -->|"exposes APIs"| node_securities
node_facade -->|"exposes APIs"| node_market
node_facade -->|"exposes APIs"| node_news
node_facade -->|"exposes APIs"| node_wencai
node_facade -->|"exposes APIs"| node_rankings
node_facade -->|"uses session"| node_session
node_account -->|"delegates requests"| node_base
node_securities -->|"delegates requests"| node_base
node_market -->|"delegates requests"| node_base
node_news -->|"delegates requests"| node_base
node_wencai -->|"delegates requests"| node_base
node_rankings -->|"delegates requests"| node_base
node_base -->|"sends request"| node_session
node_session -->|"calls bridge"| node_runtime
node_runtime -->|"calls ABI"| node_native
node_session -->|"displays challenge"| node_qr
node_session -->|"uses fallback"| node_temporary
node_session -->|"raises errors"| node_errors

click node_facade "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/api.py"
click node_manifest "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_method_manifest.py"
click node_session "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/session.py"
click node_qr "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_qr_display.py"
click node_temporary "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_temporary_accounts.py"
click node_account "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/account.py"
click node_securities "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/securities.py"
click node_market "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/market_data.py"
click node_news "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/news.py"
click node_wencai "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/wencai.py"
click node_rankings "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/rankings.py"
click node_base "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/_base.py"
click node_runtime "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_runtime.py"
click node_errors "https://github.com/panghu11033/thsdk/blob/main/src/thsdk/exceptions.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_facade,node_manifest,node_user toneBlue
class node_session,node_qr,node_temporary toneAmber
class node_account,node_securities,node_market,node_news,node_wencai,node_rankings toneMint
class node_base,node_runtime,node_errors toneRose
class node_native toneIndigo
```

## Components

### Public API

- [API facade](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/api.py): `src/thsdk/api.py`
- [Method manifest](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_method_manifest.py): `src/thsdk/_method_manifest.py`

### Authentication

- [Session client](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/session.py): `src/thsdk/session.py`
- [QR display](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_qr_display.py): `src/thsdk/_qr_display.py`
- [Temporary accounts](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_temporary_accounts.py): `src/thsdk/_temporary_accounts.py`

### Data Domains

- [Account APIs](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/account.py): `src/thsdk/_apis/account.py`
- [Security directory](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/securities.py): `src/thsdk/_apis/securities.py`
- [Market data](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/market_data.py): `src/thsdk/_apis/market_data.py`
- [News and events](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/news.py): `src/thsdk/_apis/news.py`
- [Wencai queries](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/wencai.py): `src/thsdk/_apis/wencai.py`
- [Rankings](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/rankings.py): `src/thsdk/_apis/rankings.py`

### Request Runtime

- [Request normalization](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_apis/_base.py): `src/thsdk/_apis/_base.py`
- [Native bridge](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/_runtime.py): `src/thsdk/_runtime.py`
- [SDK errors](https://github.com/panghu11033/thsdk/blob/main/src/thsdk/exceptions.py): `src/thsdk/exceptions.py`

### Other components

- **Python user**
- **THSDK runtime component**

## Connections

- Python user → API facade: calls (evidence: `README.md`)
- API facade → Method manifest: uses metadata (evidence: `src/thsdk/api.py`)
- API facade → Account APIs: exposes APIs
- API facade → Security directory: exposes APIs
- API facade → Market data: exposes APIs
- API facade → News and events: exposes APIs
- API facade → Wencai queries: exposes APIs
- API facade → Rankings: exposes APIs
- API facade → Session client: uses session (evidence: `src/thsdk/api.py`)
- Account APIs → Request normalization: delegates requests (evidence: `src/thsdk/_apis/account.py`)
- Security directory → Request normalization: delegates requests (evidence: `src/thsdk/_apis/securities.py`)
- Market data → Request normalization: delegates requests (evidence: `src/thsdk/_apis/market_data.py`)
- News and events → Request normalization: delegates requests (evidence: `src/thsdk/_apis/news.py`)
- Wencai queries → Request normalization: delegates requests (evidence: `src/thsdk/_apis/wencai.py`)
- Rankings → Request normalization: delegates requests (evidence: `src/thsdk/_apis/rankings.py`)
- Request normalization → Session client: sends request (evidence: `src/thsdk/_apis/_base.py`)
- Session client → Native bridge: calls bridge (evidence: `src/thsdk/session.py`)
- Native bridge → THSDK runtime component: calls ABI (evidence: `src/thsdk/_runtime.py`)
- Session client → QR display: displays challenge (evidence: `src/thsdk/session.py`)
- Session client → Temporary accounts: uses fallback (evidence: `src/thsdk/session.py`)
- Session client → SDK errors: raises errors (evidence: `src/thsdk/session.py`)
