# saifullahshafin/open-source-tradingview architecture

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

- Interactive diagram: https://gitdiagram.com/saifullahshafin/open-source-tradingview
- Repository: https://github.com/saifullahshafin/open-source-tradingview

## Overview

TradeX is a self-hosted, browser-based trading charting app. The main workflow is selecting a market and feed in the hub, requesting historical and live candles from the local server, and viewing them in a selected chart engine. Optional MT5 sources, Pine indicators, order-flow views, drawing tools, and backend health logs extend that workflow. The README documents product capabilities; sampled server and order-flow excerpts show some backend links. Other frontend wiring and unsampled server routes are not asserted where evidence is limited.

Main entry points: [`hub/hub.html`](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/hub.html) (Hub interface), [`hub/server.py`](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/server.py) (Hub server), [`hub/orderflow_charttypes.js`](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_charttypes.js) (Order-flow views), [`hub/orderflow_api.py`](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_api.py) (Order-flow API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market_data["Market data"]
  node_hub_server["Hub server<br/>[server.py]"]
  node_public_feeds["Free market feeds<br/>[server.py]"]
  node_local_mt5["Local MT5 feed<br/>[server.py]"]
  node_remote_bridge["Remote MT5 bridge<br/>[mt5_bridge.py]"]
  node_orderflow_api["Order-flow API<br/>[orderflow_api.py]"]
  node_trade_loader["Trade history loader"]
  node_daily_trade_cache[("Daily trade cache<br/>[orderflow.py]")]
end

subgraph group_charting["Charting"]
  node_hub_shell["Hub interface<br/>[hub.html]"]
  node_vela_engine["Vela engine<br/>[vela.bundle.js]"]
  node_lightweight_engine["Lightweight engine<br/>[lightweight.html]"]
  node_kline_engine["KLineChart engine<br/>[klinechart.html]"]
  node_drawing_favorites["Drawing favorites<br/>[drawing_favbar.js]"]
  node_theme_settings["Themes and settings<br/>[theme.js]"]
end

subgraph group_analysis_tools["Analysis tools"]
  node_pine_editor["Pine editor<br/>[pine_editor.js]"]
  node_pine_converter["Pine converter<br/>[pine_convert.js]"]
  node_indicators["Indicator tools<br/>[ind_core.js]"]
  node_indicator_dialog["Indicator dialog<br/>[ind_dialog.js]"]
  node_orderflow_ui["Order-flow views"]
  node_profile_view["Volume profile"]
  node_tpo_view["TPO chart"]
  node_delta_view["Delta indicator<br/>[orderflow_delta.js]"]
end

subgraph group_operations["Operations"]
  node_feed_monitor["Feed monitoring<br/>[feedlog.py]"]
  node_log_bus["Log bus<br/>[logbus.py]"]
  node_log_panel["Backend log panel<br/>[log_panel.js]"]
end

node_trader(("Trader"))

node_trader -->|"uses"| node_hub_shell
node_hub_shell -.->|"requests data"| node_hub_server
node_hub_server -->|"reads candles"| node_public_feeds
node_hub_server -->|"reads candles"| node_local_mt5
node_hub_server -->|"opens tunnel"| node_remote_bridge
node_hub_shell -->|"selects engine"| node_vela_engine
node_hub_shell -->|"selects engine"| node_lightweight_engine
node_hub_shell -->|"selects engine"| node_kline_engine
node_hub_shell -->|"opens editor"| node_pine_editor
node_pine_editor -->|"converts scripts"| node_pine_converter
node_indicator_dialog -.->|"selects indicators"| node_indicators
node_hub_shell -->|"opens dialog"| node_indicator_dialog
node_vela_engine -->|"hosts views"| node_orderflow_ui
node_orderflow_ui -->|"registers profile"| node_profile_view
node_orderflow_ui -->|"registers chart"| node_tpo_view
node_orderflow_ui -.->|"provides delta"| node_delta_view
node_profile_view -->|"requests profile"| node_orderflow_api
node_orderflow_api -->|"loads trades"| node_trade_loader
node_trade_loader -->|"fetches daily files"| node_daily_trade_cache
node_hub_shell -->|"shows favorites"| node_drawing_favorites
node_hub_shell -->|"configures charts"| node_theme_settings
node_hub_server -->|"wraps streams"| node_feed_monitor
node_feed_monitor -->|"records events"| node_log_bus
node_hub_server -->|"serves logs"| node_log_bus
node_log_panel -->|"polls logs"| node_hub_server

click node_hub_shell "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/hub.html"
click node_hub_server "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/server.py"
click node_public_feeds "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/server.py"
click node_local_mt5 "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/server.py"
click node_remote_bridge "https://github.com/saifullahshafin/open-source-tradingview/blob/main/bridge/mt5_bridge.py"
click node_vela_engine "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/vela.bundle.js"
click node_lightweight_engine "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/lightweight.html"
click node_kline_engine "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/klinechart.html"
click node_pine_editor "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/pine_editor.js"
click node_pine_converter "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/pine_convert.js"
click node_indicators "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/ind_core.js"
click node_indicator_dialog "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/ind_dialog.js"
click node_orderflow_ui "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_charttypes.js"
click node_profile_view "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_profile.js"
click node_tpo_view "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_tpo_type.js"
click node_delta_view "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_delta.js"
click node_orderflow_api "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_api.py"
click node_trade_loader "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_trades.py"
click node_daily_trade_cache "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow.py"
click node_drawing_favorites "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/drawing_favbar.js"
click node_theme_settings "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/theme.js"
click node_feed_monitor "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/feedlog.py"
click node_log_bus "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/logbus.py"
click node_log_panel "https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/log_panel.js"

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_hub_server,node_public_feeds,node_local_mt5,node_remote_bridge,node_orderflow_api,node_trade_loader,node_daily_trade_cache toneBlue
class node_hub_shell,node_vela_engine,node_lightweight_engine,node_kline_engine,node_drawing_favorites,node_theme_settings toneAmber
class node_pine_editor,node_pine_converter,node_indicators,node_indicator_dialog,node_orderflow_ui,node_profile_view,node_tpo_view,node_delta_view toneMint
class node_feed_monitor,node_log_bus,node_log_panel toneRose
class node_trader toneIndigo
```

## Components

### Market data

- [Hub server](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/server.py): `hub/server.py`
- [Free market feeds](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/server.py): `hub/server.py`
- [Local MT5 feed](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/server.py): `hub/server.py`
- [Remote MT5 bridge](https://github.com/saifullahshafin/open-source-tradingview/blob/main/bridge/mt5_bridge.py): `bridge/mt5_bridge.py`
- [Order-flow API](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_api.py): `hub/orderflow_api.py`
- [Trade history loader](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_trades.py): `hub/orderflow_trades.py`
- [Daily trade cache](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow.py): `hub/orderflow.py`

### Charting

- [Hub interface](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/hub.html): `hub/hub.html`
- [Vela engine](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/vela.bundle.js): `hub/vela.bundle.js`
- [Lightweight engine](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/lightweight.html): `hub/lightweight.html`
- [KLineChart engine](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/klinechart.html): `hub/klinechart.html`
- [Drawing favorites](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/drawing_favbar.js): `hub/drawing_favbar.js`
- [Themes and settings](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/theme.js): `hub/theme.js`

### Analysis tools

- [Pine editor](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/pine_editor.js): `hub/pine_editor.js`
- [Pine converter](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/pine_convert.js): `hub/pine_convert.js`
- [Indicator tools](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/ind_core.js): `hub/ind_core.js`
- [Indicator dialog](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/ind_dialog.js): `hub/ind_dialog.js`
- [Order-flow views](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_charttypes.js): `hub/orderflow_charttypes.js`
- [Volume profile](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_profile.js): `hub/orderflow_profile.js`
- [TPO chart](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_tpo_type.js): `hub/orderflow_tpo_type.js`
- [Delta indicator](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/orderflow_delta.js): `hub/orderflow_delta.js`

### Operations

- [Feed monitoring](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/feedlog.py): `hub/feedlog.py`
- [Log bus](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/logbus.py): `hub/logbus.py`
- [Backend log panel](https://github.com/saifullahshafin/open-source-tradingview/blob/main/hub/log_panel.js): `hub/log_panel.js`

### Other components

- **Trader**

## Connections

- Trader → Hub interface: uses (evidence: `README.md`)
- Hub interface → Hub server: requests data
- Hub server → Free market feeds: reads candles (evidence: `README.md`)
- Hub server → Local MT5 feed: reads candles (evidence: `README.md`)
- Hub server → Remote MT5 bridge: opens tunnel (evidence: `README.md`)
- Hub interface → Vela engine: selects engine (evidence: `README.md`)
- Hub interface → Lightweight engine: selects engine (evidence: `README.md`)
- Hub interface → KLineChart engine: selects engine (evidence: `README.md`)
- Hub interface → Pine editor: opens editor (evidence: `README.md`)
- Pine editor → Pine converter: converts scripts (evidence: `README.md`)
- Indicator dialog → Indicator tools: selects indicators
- Hub interface → Indicator dialog: opens dialog (evidence: `README.md`)
- Vela engine → Order-flow views: hosts views (evidence: `README.md`)
- Order-flow views → Volume profile: registers profile (evidence: `hub/orderflow_profile.js`)
- Order-flow views → TPO chart: registers chart (evidence: `hub/orderflow_tpo_type.js`)
- Order-flow views → Delta indicator: provides delta
- Volume profile → Order-flow API: requests profile (evidence: `hub/orderflow_profile.js`)
- Order-flow API → Trade history loader: loads trades (evidence: `hub/orderflow_api.py`)
- Trade history loader → Daily trade cache: fetches daily files (evidence: `hub/orderflow.py`)
- Hub interface → Drawing favorites: shows favorites (evidence: `README.md`)
- Hub interface → Themes and settings: configures charts (evidence: `README.md`)
- Hub server → Feed monitoring: wraps streams (evidence: `hub/server.py`)
- Feed monitoring → Log bus: records events (evidence: `hub/feedlog.py`)
- Hub server → Log bus: serves logs (evidence: `hub/server.py`)
- Backend log panel → Hub server: polls logs (evidence: `hub/log_panel.js`)
