# deedop/tpscraper architecture

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

- Interactive diagram: https://gitdiagram.com/deedop/tpscraper
- Repository: https://github.com/deedop/tpscraper

## Overview

tpscraper is a local TakeProfit market-data collector and JSON/SSE service. The main workflow is: authorize a user’s account, select instruments, collect quotes and candle/order-flow data, maintain freshness-aware state, then expose it to a local dashboard or client. The graph preserves documented catalog, analytics, history, and browser-renewal capabilities. Some implementation files were not excerpted, so uncertain internal links are omitted; dashed links indicate documented or unverified integrations.

Main entry points: [`tpscraper/dashboard.py`](https://github.com/deedop/tpscraper/blob/main/tpscraper/dashboard.py) (HTTP and SSE service), [`tpscraper/native_collect.py`](https://github.com/deedop/tpscraper/blob/main/tpscraper/native_collect.py) (Native collector), [`tpscraper/native_state.py`](https://github.com/deedop/tpscraper/blob/main/tpscraper/native_state.py) (Native market state), [`tpscraper/local_chrome.py`](https://github.com/deedop/tpscraper/blob/main/tpscraper/local_chrome.py) (Chrome authorization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and authorization"]
  node_cli["CLI entry<br/>[__main__.py]"]
  node_auth["Token authorization<br/>[auth.py]"]
  node_chromeauth["Chrome authorization<br/>[local_chrome.py]"]
  node_renew["Browser renewal bridge<br/>[browser_renew.py]"]
  node_credentials[("Credential storage")]
end

subgraph group_collection["Collection and decoding"]
  node_instruments["Instrument selection<br/>[instruments.py]"]
  node_workspace["Workspace settings<br/>[workspace.py]"]
  node_catalog[("Instrument catalog<br/>[catalog.py]")]
  node_collector["Native collector<br/>[native_collect.py]"]
  node_probe["Native probe<br/>[native_probe.py]"]
  node_protocol["gRPC-Web framing<br/>[protocol.py]"]
  node_schema["Native message schema<br/>[native_schema.py]"]
  node_quoteschema["Quote schema<br/>[quote_schema.py]"]
  node_extended["Extended data schema<br/>[extended_schema.py]"]
  node_symbols["Symbol handling<br/>[symbols.py]"]
end

subgraph group_market["Market data state"]
  node_state["Native market state<br/>[native_state.py]"]
  node_dashstate["Dashboard state<br/>[dashboard_state.py]"]
  node_flow["Order-flow state<br/>[flow_state.py]"]
  node_history[("History cache<br/>[history_cache.py]")]
  node_capabilities["Capability tracking<br/>[capabilities.py]"]
  node_analytics["Market analytics<br/>[analytics.py]"]
  node_feed["Feed utilities<br/>[feed.py]"]
  node_flowrecord["Flow records<br/>[flow_record.py]"]
end

subgraph group_service["Local API and clients"]
  node_dashboard["HTTP and SSE service<br/>[dashboard.py]"]
  node_webui["Browser dashboard<br/>[dashboard.html]"]
end

node_user(("Local user"))
node_client(("Local API client"))
node_takeprofit["TakeProfit"]

node_user -.->|"starts service"| node_cli
node_cli -->|"dispatches"| node_dashboard
node_user -.->|"authorizes account"| node_chromeauth
node_chromeauth -.->|"uses storage"| node_credentials
node_renew -->|"extends authorization"| node_chromeauth
node_auth -->|"renews token"| node_takeprofit
node_dashboard -.->|"uses authorization"| node_auth
node_dashboard -.->|"starts collection"| node_collector
node_dashboard -.->|"configures instruments"| node_instruments
node_dashboard -->|"serves search"| node_catalog
node_workspace -->|"loads selections"| node_instruments
node_collector -->|"builds subscriptions"| node_schema
node_collector -->|"ingests quotes"| node_state
node_collector -.->|"streams market data"| node_takeprofit
node_probe -->|"decodes requests"| node_schema
node_probe -->|"decodes frames"| node_protocol
node_collector -.->|"uses framing"| node_protocol
node_schema -->|"uses quote types"| node_quoteschema
node_collector -.->|"requests extended data"| node_extended
node_state -->|"updates flow state"| node_flow
node_state -->|"tracks support"| node_capabilities
node_state -->|"computes metrics"| node_analytics
node_state -->|"uses shared state"| node_dashstate
node_dashstate -.->|"writes candles"| node_history
node_dashboard -.->|"reads snapshots"| node_state
node_dashboard -.->|"serves retained bars"| node_history
node_client -->|"requests JSON or SSE"| node_dashboard
node_dashboard -->|"serves dashboard"| node_webui

click node_cli "https://github.com/deedop/tpscraper/blob/main/tpscraper/__main__.py"
click node_auth "https://github.com/deedop/tpscraper/blob/main/tpscraper/auth.py"
click node_chromeauth "https://github.com/deedop/tpscraper/blob/main/tpscraper/local_chrome.py"
click node_renew "https://github.com/deedop/tpscraper/blob/main/tpscraper/browser_renew.py"
click node_credentials "https://github.com/deedop/tpscraper/blob/main/tpscraper/credential_store.py"
click node_instruments "https://github.com/deedop/tpscraper/blob/main/tpscraper/instruments.py"
click node_workspace "https://github.com/deedop/tpscraper/blob/main/tpscraper/workspace.py"
click node_catalog "https://github.com/deedop/tpscraper/blob/main/tpscraper/catalog.py"
click node_collector "https://github.com/deedop/tpscraper/blob/main/tpscraper/native_collect.py"
click node_probe "https://github.com/deedop/tpscraper/blob/main/tpscraper/native_probe.py"
click node_protocol "https://github.com/deedop/tpscraper/blob/main/tpscraper/protocol.py"
click node_schema "https://github.com/deedop/tpscraper/blob/main/tpscraper/native_schema.py"
click node_quoteschema "https://github.com/deedop/tpscraper/blob/main/tpscraper/quote_schema.py"
click node_extended "https://github.com/deedop/tpscraper/blob/main/tpscraper/extended_schema.py"
click node_state "https://github.com/deedop/tpscraper/blob/main/tpscraper/native_state.py"
click node_dashstate "https://github.com/deedop/tpscraper/blob/main/tpscraper/dashboard_state.py"
click node_flow "https://github.com/deedop/tpscraper/blob/main/tpscraper/flow_state.py"
click node_history "https://github.com/deedop/tpscraper/blob/main/tpscraper/history_cache.py"
click node_capabilities "https://github.com/deedop/tpscraper/blob/main/tpscraper/capabilities.py"
click node_analytics "https://github.com/deedop/tpscraper/blob/main/tpscraper/analytics.py"
click node_feed "https://github.com/deedop/tpscraper/blob/main/tpscraper/feed.py"
click node_flowrecord "https://github.com/deedop/tpscraper/blob/main/tpscraper/flow_record.py"
click node_dashboard "https://github.com/deedop/tpscraper/blob/main/tpscraper/dashboard.py"
click node_webui "https://github.com/deedop/tpscraper/blob/main/tpscraper/static/dashboard.html"
click node_symbols "https://github.com/deedop/tpscraper/blob/main/tpscraper/symbols.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_cli,node_auth,node_chromeauth,node_renew,node_credentials,node_user,node_client toneBlue
class node_instruments,node_workspace,node_catalog,node_collector,node_probe,node_protocol,node_schema,node_quoteschema,node_extended,node_symbols toneAmber
class node_state,node_dashstate,node_flow,node_history,node_capabilities,node_analytics,node_feed,node_flowrecord toneMint
class node_dashboard,node_webui toneRose
class node_takeprofit toneIndigo
```

## Components

### Entry and authorization

- [CLI entry](https://github.com/deedop/tpscraper/blob/main/tpscraper/__main__.py): `tpscraper/__main__.py`
- [Token authorization](https://github.com/deedop/tpscraper/blob/main/tpscraper/auth.py): `tpscraper/auth.py`
- [Chrome authorization](https://github.com/deedop/tpscraper/blob/main/tpscraper/local_chrome.py): `tpscraper/local_chrome.py`
- [Browser renewal bridge](https://github.com/deedop/tpscraper/blob/main/tpscraper/browser_renew.py): `tpscraper/browser_renew.py`
- [Credential storage](https://github.com/deedop/tpscraper/blob/main/tpscraper/credential_store.py): `tpscraper/credential_store.py`

### Collection and decoding

- [Instrument selection](https://github.com/deedop/tpscraper/blob/main/tpscraper/instruments.py): `tpscraper/instruments.py`
- [Workspace settings](https://github.com/deedop/tpscraper/blob/main/tpscraper/workspace.py): `tpscraper/workspace.py`
- [Instrument catalog](https://github.com/deedop/tpscraper/blob/main/tpscraper/catalog.py): `tpscraper/catalog.py`
- [Native collector](https://github.com/deedop/tpscraper/blob/main/tpscraper/native_collect.py): `tpscraper/native_collect.py`
- [Native probe](https://github.com/deedop/tpscraper/blob/main/tpscraper/native_probe.py): `tpscraper/native_probe.py`
- [gRPC-Web framing](https://github.com/deedop/tpscraper/blob/main/tpscraper/protocol.py): `tpscraper/protocol.py`
- [Native message schema](https://github.com/deedop/tpscraper/blob/main/tpscraper/native_schema.py): `tpscraper/native_schema.py`
- [Quote schema](https://github.com/deedop/tpscraper/blob/main/tpscraper/quote_schema.py): `tpscraper/quote_schema.py`
- [Extended data schema](https://github.com/deedop/tpscraper/blob/main/tpscraper/extended_schema.py): `tpscraper/extended_schema.py`
- [Symbol handling](https://github.com/deedop/tpscraper/blob/main/tpscraper/symbols.py): `tpscraper/symbols.py`

### Market data state

- [Native market state](https://github.com/deedop/tpscraper/blob/main/tpscraper/native_state.py): `tpscraper/native_state.py`
- [Dashboard state](https://github.com/deedop/tpscraper/blob/main/tpscraper/dashboard_state.py): `tpscraper/dashboard_state.py`
- [Order-flow state](https://github.com/deedop/tpscraper/blob/main/tpscraper/flow_state.py): `tpscraper/flow_state.py`
- [History cache](https://github.com/deedop/tpscraper/blob/main/tpscraper/history_cache.py): `tpscraper/history_cache.py`
- [Capability tracking](https://github.com/deedop/tpscraper/blob/main/tpscraper/capabilities.py): `tpscraper/capabilities.py`
- [Market analytics](https://github.com/deedop/tpscraper/blob/main/tpscraper/analytics.py): `tpscraper/analytics.py`
- [Feed utilities](https://github.com/deedop/tpscraper/blob/main/tpscraper/feed.py): `tpscraper/feed.py`
- [Flow records](https://github.com/deedop/tpscraper/blob/main/tpscraper/flow_record.py): `tpscraper/flow_record.py`

### Local API and clients

- [HTTP and SSE service](https://github.com/deedop/tpscraper/blob/main/tpscraper/dashboard.py): `tpscraper/dashboard.py`
- [Browser dashboard](https://github.com/deedop/tpscraper/blob/main/tpscraper/static/dashboard.html): `tpscraper/static/dashboard.html`

### Other components

- **Local user**
- **Local API client**
- **TakeProfit**

## Connections

- Local user → CLI entry: starts service (evidence: `README.md`)
- CLI entry → HTTP and SSE service: dispatches (evidence: `tpscraper/__main__.py`)
- Local user → Chrome authorization: authorizes account (evidence: `README.md`)
- Chrome authorization → Credential storage: uses storage (evidence: `tpscraper/local_chrome.py`)
- Browser renewal bridge → Chrome authorization: extends authorization (evidence: `tpscraper/browser_renew.py`)
- Token authorization → TakeProfit: renews token (evidence: `tpscraper/auth.py`)
- HTTP and SSE service → Token authorization: uses authorization (evidence: `tpscraper/dashboard.py`)
- HTTP and SSE service → Native collector: starts collection (evidence: `tpscraper/dashboard.py`)
- HTTP and SSE service → Instrument selection: configures instruments (evidence: `tpscraper/dashboard.py`)
- HTTP and SSE service → Instrument catalog: serves search (evidence: `tpscraper/dashboard.py`)
- Workspace settings → Instrument selection: loads selections (evidence: `tpscraper/workspace.py`)
- Native collector → Native message schema: builds subscriptions (evidence: `tpscraper/native_collect.py`)
- Native collector → Native market state: ingests quotes (evidence: `tpscraper/native_collect.py`)
- Native collector → TakeProfit: streams market data (evidence: `README.md`)
- Native probe → Native message schema: decodes requests (evidence: `tpscraper/native_probe.py`)
- Native probe → gRPC-Web framing: decodes frames (evidence: `tpscraper/native_probe.py`)
- Native collector → gRPC-Web framing: uses framing (evidence: `tpscraper/native_collect.py`)
- Native message schema → Quote schema: uses quote types (evidence: `tpscraper/native_schema.py`)
- Native collector → Extended data schema: requests extended data (evidence: `tpscraper/native_collect.py`)
- Native market state → Order-flow state: updates flow state (evidence: `tpscraper/native_state.py`)
- Native market state → Capability tracking: tracks support (evidence: `tpscraper/native_state.py`)
- Native market state → Market analytics: computes metrics (evidence: `tpscraper/native_state.py`)
- Native market state → Dashboard state: uses shared state (evidence: `tpscraper/native_state.py`)
- Dashboard state → History cache: writes candles (evidence: `tpscraper/dashboard_state.py`)
- HTTP and SSE service → Native market state: reads snapshots (evidence: `tpscraper/dashboard.py`)
- HTTP and SSE service → History cache: serves retained bars (evidence: `tpscraper/dashboard.py`)
- Local API client → HTTP and SSE service: requests JSON or SSE (evidence: `README.md`)
- HTTP and SSE service → Browser dashboard: serves dashboard (evidence: `tpscraper/dashboard.py`)
