# tradingview/charting-library-tutorial architecture

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

- Interactive diagram: https://gitdiagram.com/tradingview/charting-library-tutorial
- Repository: https://github.com/tradingview/charting-library-tutorial

## Overview

This repository is a browser example of TradingView charts backed by Binance, with a minimal Advanced Charts route and a richer Trading Platform route. Users open a chart, resolve/search symbols and load historical bars, then receive live updates; the Trading Platform route adds broker, market-depth, watchlist, quotes, news, alerts, and saved layouts. Source excerpts establish the chart bootstrapping, datafeed helpers, streaming, and UI adapters; several Trading Platform capabilities are documented in the README but their implementations are only partially sampled.

Main entry points: [`src/trading.js`](https://github.com/tradingview/charting-library-tutorial/blob/master/src/trading.js) (Trading Platform page), [`src/datafeed/datafeed.js`](https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/datafeed.js) (Binance datafeed), [`src/widget-options.js`](https://github.com/tradingview/charting-library-tutorial/blob/master/src/widget-options.js) (Widget options), [`src/main.js`](https://github.com/tradingview/charting-library-tutorial/blob/master/src/main.js) (Advanced Charts page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_charts["Chart experiences"]
  node_advanced["Advanced Charts page<br/>[main.js]"]
  node_platform_entry["Trading Platform page<br/>[trading.js]"]
  node_widget_config["Widget options<br/>[widget-options.js]"]
  node_tv_runtime["TradingView runtime"]
end

subgraph group_marketdata["Market data"]
  node_datafeed["Binance datafeed<br/>[datafeed.js]"]
  node_data_helpers["Symbol and API helpers<br/>[helpers.js]"]
  node_quote_stream["Quote streams<br/>[quotes.js]"]
  node_bar_stream["Bar streaming<br/>[streaming.js]"]
  node_binance_rest["Binance REST API"]
  node_binance_ws["Binance WebSocket"]
end

subgraph group_platform["Trading features"]
  node_broker_features["Broker and DOM<br/>[trading.js]"]
  node_alerts["Alerts and chart actions<br/>[trading.js]"]
  node_quotes_watchlist["Quotes and watchlist<br/>[datafeed.js]"]
  node_news["CoinDesk news<br/>[news.js]"]
  node_news_proxy["RSS proxy<br/>[server.mjs]"]
  node_save_load["Chart save and load"]
  node_local_storage[("Browser local storage")]
end

subgraph group_presentation["Chart presentation"]
  node_symbol_status["Feed status<br/>[symbol-status.js]"]
  node_toolbar["Toolbar controls<br/>[toolbar.js]"]
  node_theme["Theme and styles<br/>[theme.js]"]
end

node_visitor(("Chart user"))
node_coindesk["CoinDesk RSS"]

node_visitor -->|"opens /"| node_advanced
node_visitor -->|"opens /trading"| node_platform_entry
node_advanced -->|"builds options"| node_widget_config
node_advanced -->|"installs status"| node_symbol_status
node_advanced -->|"installs toolbar"| node_toolbar
node_platform_entry -->|"builds options"| node_widget_config
node_platform_entry -->|"configures broker"| node_broker_features
node_platform_entry -->|"installs alert actions"| node_alerts
node_platform_entry -->|"creates adapter"| node_save_load
node_platform_entry -->|"installs status"| node_symbol_status
node_platform_entry -->|"installs controls"| node_toolbar
node_widget_config -->|"configures feed"| node_datafeed
node_widget_config -->|"configures news"| node_news
node_widget_config -->|"uses theme settings"| node_theme
node_widget_config -->|"configures widget"| node_tv_runtime
node_datafeed -->|"uses helpers"| node_data_helpers
node_datafeed -->|"uses quote streams"| node_quote_stream
node_datafeed -->|"delegates bar updates"| node_bar_stream
node_datafeed -->|"requests symbols and bars"| node_binance_rest
node_bar_stream -->|"parses symbols"| node_data_helpers
node_bar_stream -->|"subscribes bars"| node_binance_ws
node_quote_stream -->|"parses symbols"| node_data_helpers
node_quote_stream -->|"subscribes quotes"| node_binance_ws
node_datafeed -->|"opens depth stream"| node_binance_ws
node_datafeed -->|"publishes resolved status"| node_symbol_status
node_save_load -->|"persists layouts"| node_local_storage
node_toolbar -->|"applies theme overrides"| node_theme
node_news -.->|"requests RSS proxy"| node_news_proxy
node_news_proxy -->|"fetches RSS"| node_coindesk
node_broker_features -.->|"uses platform APIs"| node_tv_runtime
node_tv_runtime -.->|"requests quotes and depth"| node_quotes_watchlist

click node_advanced "https://github.com/tradingview/charting-library-tutorial/blob/master/src/main.js"
click node_platform_entry "https://github.com/tradingview/charting-library-tutorial/blob/master/src/trading.js"
click node_widget_config "https://github.com/tradingview/charting-library-tutorial/blob/master/src/widget-options.js"
click node_datafeed "https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/datafeed.js"
click node_data_helpers "https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/helpers.js"
click node_quote_stream "https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/quotes.js"
click node_bar_stream "https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/streaming.js"
click node_broker_features "https://github.com/tradingview/charting-library-tutorial/blob/master/src/trading.js"
click node_alerts "https://github.com/tradingview/charting-library-tutorial/blob/master/src/trading.js"
click node_quotes_watchlist "https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/datafeed.js"
click node_news "https://github.com/tradingview/charting-library-tutorial/blob/master/src/news.js"
click node_news_proxy "https://github.com/tradingview/charting-library-tutorial/blob/master/server.mjs"
click node_save_load "https://github.com/tradingview/charting-library-tutorial/blob/master/src/save-load-adapter.js"
click node_symbol_status "https://github.com/tradingview/charting-library-tutorial/blob/master/src/symbol-status.js"
click node_toolbar "https://github.com/tradingview/charting-library-tutorial/blob/master/src/toolbar.js"
click node_theme "https://github.com/tradingview/charting-library-tutorial/blob/master/src/theme.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_advanced,node_platform_entry,node_widget_config,node_tv_runtime,node_visitor toneBlue
class node_datafeed,node_data_helpers,node_quote_stream,node_bar_stream,node_binance_rest,node_binance_ws toneAmber
class node_broker_features,node_alerts,node_quotes_watchlist,node_news,node_news_proxy,node_save_load,node_local_storage toneMint
class node_symbol_status,node_toolbar,node_theme toneRose
class node_coindesk toneIndigo
```

## Components

### Chart experiences

- [Advanced Charts page](https://github.com/tradingview/charting-library-tutorial/blob/master/src/main.js): `src/main.js`
- [Trading Platform page](https://github.com/tradingview/charting-library-tutorial/blob/master/src/trading.js): `src/trading.js`
- [Widget options](https://github.com/tradingview/charting-library-tutorial/blob/master/src/widget-options.js): `src/widget-options.js`
- **TradingView runtime**

### Market data

- [Binance datafeed](https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/datafeed.js): `src/datafeed/datafeed.js`
- [Symbol and API helpers](https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/helpers.js): `src/datafeed/helpers.js`
- [Quote streams](https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/quotes.js): `src/datafeed/quotes.js`
- [Bar streaming](https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/streaming.js): `src/datafeed/streaming.js`
- **Binance REST API**
- **Binance WebSocket**

### Trading features

- [Broker and DOM](https://github.com/tradingview/charting-library-tutorial/blob/master/src/trading.js): `src/trading.js`
- [Alerts and chart actions](https://github.com/tradingview/charting-library-tutorial/blob/master/src/trading.js): `src/trading.js`
- [Quotes and watchlist](https://github.com/tradingview/charting-library-tutorial/blob/master/src/datafeed/datafeed.js): `src/datafeed/datafeed.js`
- [CoinDesk news](https://github.com/tradingview/charting-library-tutorial/blob/master/src/news.js): `src/news.js`
- [RSS proxy](https://github.com/tradingview/charting-library-tutorial/blob/master/server.mjs): `server.mjs`
- [Chart save and load](https://github.com/tradingview/charting-library-tutorial/blob/master/src/save-load-adapter.js): `src/save-load-adapter.js`
- **Browser local storage**

### Chart presentation

- [Feed status](https://github.com/tradingview/charting-library-tutorial/blob/master/src/symbol-status.js): `src/symbol-status.js`
- [Toolbar controls](https://github.com/tradingview/charting-library-tutorial/blob/master/src/toolbar.js): `src/toolbar.js`
- [Theme and styles](https://github.com/tradingview/charting-library-tutorial/blob/master/src/theme.js): `src/theme.js`

### Other components

- **Chart user**
- **CoinDesk RSS**

## Connections

- Chart user → Advanced Charts page: opens / (evidence: `README.md`)
- Chart user → Trading Platform page: opens /trading (evidence: `README.md`)
- Advanced Charts page → Widget options: builds options (evidence: `src/main.js`)
- Advanced Charts page → Feed status: installs status (evidence: `src/main.js`)
- Advanced Charts page → Toolbar controls: installs toolbar (evidence: `src/main.js`)
- Trading Platform page → Widget options: builds options (evidence: `src/trading.js`)
- Trading Platform page → Broker and DOM: configures broker (evidence: `src/trading.js`)
- Trading Platform page → Alerts and chart actions: installs alert actions (evidence: `src/trading.js`)
- Trading Platform page → Chart save and load: creates adapter (evidence: `src/trading.js`)
- Trading Platform page → Feed status: installs status (evidence: `src/trading.js`)
- Trading Platform page → Toolbar controls: installs controls (evidence: `src/trading.js`)
- Widget options → Binance datafeed: configures feed (evidence: `src/widget-options.js`)
- Widget options → CoinDesk news: configures news (evidence: `src/widget-options.js`)
- Widget options → Theme and styles: uses theme settings (evidence: `src/widget-options.js`)
- Widget options → TradingView runtime: configures widget (evidence: `src/widget-options.js`)
- Binance datafeed → Symbol and API helpers: uses helpers (evidence: `src/datafeed/datafeed.js`)
- Binance datafeed → Quote streams: uses quote streams (evidence: `src/datafeed/datafeed.js`)
- Binance datafeed → Bar streaming: delegates bar updates (evidence: `src/datafeed/datafeed.js`)
- Binance datafeed → Binance REST API: requests symbols and bars (evidence: `src/datafeed/datafeed.js`)
- Bar streaming → Symbol and API helpers: parses symbols (evidence: `src/datafeed/streaming.js`)
- Bar streaming → Binance WebSocket: subscribes bars (evidence: `src/datafeed/streaming.js`)
- Quote streams → Symbol and API helpers: parses symbols (evidence: `src/datafeed/quotes.js`)
- Quote streams → Binance WebSocket: subscribes quotes (evidence: `src/datafeed/quotes.js`)
- Binance datafeed → Binance WebSocket: opens depth stream (evidence: `src/datafeed/datafeed.js`)
- Binance datafeed → Feed status: publishes resolved status (evidence: `src/datafeed/datafeed.js`)
- Chart save and load → Browser local storage: persists layouts (evidence: `src/save-load-adapter.js`)
- Toolbar controls → Theme and styles: applies theme overrides (evidence: `src/toolbar.js`)
- CoinDesk news → RSS proxy: requests RSS proxy (evidence: `README.md`)
- RSS proxy → CoinDesk RSS: fetches RSS (evidence: `README.md`)
- Broker and DOM → TradingView runtime: uses platform APIs (evidence: `README.md`)
- TradingView runtime → Quotes and watchlist: requests quotes and depth (evidence: `README.md`)
