# drager/tradingview architecture

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

- Interactive diagram: https://gitdiagram.com/drager/tradingview
- Repository: https://github.com/drager/tradingview

## Overview

##### Project Type and Purpose
- This is an open-source Rust library that provides bindings to interact with TradingView functionalities. It enables Rust applications to fetch financial data (like historical data and instruments) and subscribe to realtime data via TradingView.
- The primary goal is to abstract the complexity of communicating with TradingView, offering a simple API for data retrieval and realtime updates.

##### File Structure
- Top-level Files and Folders:
– The Cargo.toml, Cargo.lock, and src folder indicate this is a standard Rust library.
– The examples folder shows how the library is used. Each example (fetch_historical_data.rs, fetch_instruments.rs, realtime.rs) demonstrates different features.
– The .github folder with workflows (including a Rust CI workflow) indicates that continuous integration is part of the project.
- Inside src:
– lib.rs: Likely contains the core functionality and public API.
– websocket.rs: Suggests that realtime communication (probably over secure websockets using native-tls) is handled separately, representing a lower-level module that deals with persistent connections.

##### Insights from the README
- The README highlights that the library supports both historical data fetching and realtime subscriptions using secure TLS connections (enabled with the "native-tls" feature).

##### Final Advice
- Don’t over-complicate: While it's good to capture all critical elements, focus on clarity and readability.
- Including notes that describe the CI/CD integration, as it plays a role in ensuring the stability and quality of the library.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Application / Examples"
        Example1["Fetch Historical Data Example"]:::client
        Example2["Fetch Instruments Example"]:::client
        Example3["Realtime Data Example"]:::client
    end

    CoreAPI["TradingView Library (lib.rs - Core API)"]:::core
    RealtimeModule["Realtime Module (websocket.rs)"]:::realtime
    TradingViewService["TradingView API/Service"]:::external
    CICD["CI/CD Pipeline (GitHub Actions)"]:::cicd

    Example1 -->|"calls"| CoreAPI
    Example2 -->|"calls"| CoreAPI
    Example3 -->|"calls"| CoreAPI
    CoreAPI -->|"routesRealtime"| RealtimeModule
    RealtimeModule -->|"connectsSecureTLS"| TradingViewService
    CICD -->|"CIbuilds"| CoreAPI

    click Example1 "https://github.com/drager/tradingview/blob/main/examples/fetch_historical_data.rs"
    click Example2 "https://github.com/drager/tradingview/blob/main/examples/fetch_instruments.rs"
    click Example3 "https://github.com/drager/tradingview/blob/main/examples/realtime.rs"
    click CoreAPI "https://github.com/drager/tradingview/blob/main/src/lib.rs"
    click RealtimeModule "https://github.com/drager/tradingview/blob/main/src/websocket.rs"
    click CICD "https://github.com/drager/tradingview/tree/main/.github/workflows"

    classDef client fill:#ccf,stroke:#333,stroke-width:2px;
    classDef core fill:#cfc,stroke:#333,stroke-width:2px;
    classDef realtime fill:#fcf,stroke:#333,stroke-width:2px;
    classDef external fill:#ffc,stroke:#333,stroke-width:2px;
    classDef cicd fill:#cff,stroke:#333,stroke-width:2px;
```
