# luxalgo/pinets architecture

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

- Interactive diagram: https://gitdiagram.com/luxalgo/pinets
- Repository: https://github.com/luxalgo/pinets

## Overview

PineTS is a TypeScript Pine Script runtime. The documented workflow is to provide Pine Script (or PineTS-style code) and OHLCV data, run it through the transpiler and bar-by-bar runtime, then consume plot series; providers and streaming support extend that workflow. The graph reflects README claims and the supplied source index/excerpts. Several API families are represented by their directory paths because their implementation details were not sampled.

Main entry points: [`src/PineTS.class.ts`](https://github.com/luxalgo/pinets/blob/main/src/PineTS.class.ts) (PineTS engine), [`src/Context.class.ts`](https://github.com/luxalgo/pinets/blob/main/src/Context.class.ts) (Execution context), [`src/transpiler/index.ts`](https://github.com/luxalgo/pinets/blob/main/src/transpiler/index.ts) (Transpiler orchestration), [`src/Indicator/Indicator.class.ts`](https://github.com/luxalgo/pinets/blob/main/src/Indicator/Indicator.class.ts) (Indicator preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Inputs and market data"]
  node_providers["Market providers"]
  node_providerbase["Provider aggregation<br/>[BaseProvider.ts]"]
  node_aggregation["Candle aggregation<br/>[aggregation.ts]"]
  node_timeframe["Timeframe rules<br/>[timeframe.ts]"]
end

subgraph group_compilation["Pine compilation"]
  node_indicator["Indicator preparation<br/>[Indicator.class.ts]"]
  node_inputscan["Input declarations<br/>[scanInputs.ts]"]
  node_transpiler["Transpiler orchestration<br/>[index.ts]"]
  node_parser["Pine parser and codegen"]
  node_analysis["Scope and analysis"]
  node_transformers["AST transformations"]
end

subgraph group_runtime["Execution runtime"]
  node_pine["PineTS engine<br/>[PineTS.class.ts]"]
  node_context["Execution context<br/>[Context.class.ts]"]
  node_series["Time series<br/>[Series.ts]"]
  node_stream["Live bar updates<br/>[PineTS.class.ts]"]
end

subgraph group_api["Pine API and outputs"]
  node_ta["Technical analysis"]
  node_request["Cross-series requests"]
  node_strategy["Strategy simulation"]
  node_structures["Pine data structures"]
  node_charting["Chart and drawing APIs<br/>[Plots.ts]"]
  node_plots["Plot series"]
end

node_developer(("Script author"))
node_ohlcv["OHLCV data"]

node_developer -->|"runs script"| node_pine
node_ohlcv -->|"provides bars"| node_pine
node_pine -.->|"uses providers"| node_providers
node_pine -->|"initializes context"| node_context
node_pine -->|"prepares indicator"| node_indicator
node_indicator -->|"transpiles source"| node_transpiler
node_indicator -->|"scans inputs"| node_inputscan
node_transpiler -->|"parses source"| node_parser
node_transpiler -->|"runs analysis"| node_analysis
node_transpiler -->|"transforms AST"| node_transformers
node_context -->|"uses series"| node_series
node_providerbase -->|"aggregates candles"| node_aggregation
node_providerbase -->|"normalizes intervals"| node_timeframe
node_pine -->|"parses intervals"| node_timeframe
node_context -->|"exposes namespace"| node_ta
node_context -->|"exposes namespace"| node_request
node_context -->|"exposes namespace"| node_strategy
node_context -->|"exposes namespace"| node_structures
node_context -.->|"exposes plot API"| node_charting
node_pine -->|"returns plot series"| node_plots
node_pine -->|"streams updates"| node_stream

click node_pine "https://github.com/luxalgo/pinets/blob/main/src/PineTS.class.ts"
click node_context "https://github.com/luxalgo/pinets/blob/main/src/Context.class.ts"
click node_series "https://github.com/luxalgo/pinets/blob/main/src/Series.ts"
click node_indicator "https://github.com/luxalgo/pinets/blob/main/src/Indicator/Indicator.class.ts"
click node_inputscan "https://github.com/luxalgo/pinets/blob/main/src/Indicator/scanInputs.ts"
click node_transpiler "https://github.com/luxalgo/pinets/blob/main/src/transpiler/index.ts"
click node_parser "https://github.com/luxalgo/pinets/tree/main/src/transpiler/pineToJS"
click node_analysis "https://github.com/luxalgo/pinets/tree/main/src/transpiler/analysis"
click node_transformers "https://github.com/luxalgo/pinets/tree/main/src/transpiler/transformers"
click node_providers "https://github.com/luxalgo/pinets/tree/main/src/marketData"
click node_providerbase "https://github.com/luxalgo/pinets/blob/main/src/marketData/BaseProvider.ts"
click node_aggregation "https://github.com/luxalgo/pinets/blob/main/src/marketData/aggregation.ts"
click node_timeframe "https://github.com/luxalgo/pinets/blob/main/src/timeframe.ts"
click node_ta "https://github.com/luxalgo/pinets/tree/main/src/namespaces/ta"
click node_request "https://github.com/luxalgo/pinets/tree/main/src/namespaces/request"
click node_strategy "https://github.com/luxalgo/pinets/tree/main/src/namespaces/strategy"
click node_structures "https://github.com/luxalgo/pinets/tree/main/src/namespaces/array"
click node_charting "https://github.com/luxalgo/pinets/blob/main/src/namespaces/Plots.ts"
click node_stream "https://github.com/luxalgo/pinets/blob/main/src/PineTS.class.ts"

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_providers,node_providerbase,node_aggregation,node_timeframe toneBlue
class node_indicator,node_inputscan,node_transpiler,node_parser,node_analysis,node_transformers toneAmber
class node_pine,node_context,node_series,node_stream toneMint
class node_ta,node_request,node_strategy,node_structures,node_charting,node_plots toneRose
class node_developer,node_ohlcv toneIndigo
```

## Components

### Inputs and market data

- [Market providers](https://github.com/luxalgo/pinets/tree/main/src/marketData): `src/marketData`
- [Provider aggregation](https://github.com/luxalgo/pinets/blob/main/src/marketData/BaseProvider.ts): `src/marketData/BaseProvider.ts`
- [Candle aggregation](https://github.com/luxalgo/pinets/blob/main/src/marketData/aggregation.ts): `src/marketData/aggregation.ts`
- [Timeframe rules](https://github.com/luxalgo/pinets/blob/main/src/timeframe.ts): `src/timeframe.ts`

### Pine compilation

- [Indicator preparation](https://github.com/luxalgo/pinets/blob/main/src/Indicator/Indicator.class.ts): `src/Indicator/Indicator.class.ts`
- [Input declarations](https://github.com/luxalgo/pinets/blob/main/src/Indicator/scanInputs.ts): `src/Indicator/scanInputs.ts`
- [Transpiler orchestration](https://github.com/luxalgo/pinets/blob/main/src/transpiler/index.ts): `src/transpiler/index.ts`
- [Pine parser and codegen](https://github.com/luxalgo/pinets/tree/main/src/transpiler/pineToJS): `src/transpiler/pineToJS`
- [Scope and analysis](https://github.com/luxalgo/pinets/tree/main/src/transpiler/analysis): `src/transpiler/analysis`
- [AST transformations](https://github.com/luxalgo/pinets/tree/main/src/transpiler/transformers): `src/transpiler/transformers`

### Execution runtime

- [PineTS engine](https://github.com/luxalgo/pinets/blob/main/src/PineTS.class.ts): `src/PineTS.class.ts`
- [Execution context](https://github.com/luxalgo/pinets/blob/main/src/Context.class.ts): `src/Context.class.ts`
- [Time series](https://github.com/luxalgo/pinets/blob/main/src/Series.ts): `src/Series.ts`
- [Live bar updates](https://github.com/luxalgo/pinets/blob/main/src/PineTS.class.ts): `src/PineTS.class.ts`

### Pine API and outputs

- [Technical analysis](https://github.com/luxalgo/pinets/tree/main/src/namespaces/ta): `src/namespaces/ta`
- [Cross-series requests](https://github.com/luxalgo/pinets/tree/main/src/namespaces/request): `src/namespaces/request`
- [Strategy simulation](https://github.com/luxalgo/pinets/tree/main/src/namespaces/strategy): `src/namespaces/strategy`
- [Pine data structures](https://github.com/luxalgo/pinets/tree/main/src/namespaces/array): `src/namespaces/array`
- [Chart and drawing APIs](https://github.com/luxalgo/pinets/blob/main/src/namespaces/Plots.ts): `src/namespaces/Plots.ts`
- **Plot series**

### Other components

- **Script author**
- **OHLCV data**

## Connections

- Script author → PineTS engine: runs script
- OHLCV data → PineTS engine: provides bars
- PineTS engine → Market providers: uses providers (evidence: `src/PineTS.class.ts`)
- PineTS engine → Execution context: initializes context (evidence: `src/PineTS.class.ts`)
- PineTS engine → Indicator preparation: prepares indicator (evidence: `src/PineTS.class.ts`)
- Indicator preparation → Transpiler orchestration: transpiles source (evidence: `src/Indicator/Indicator.class.ts`)
- Indicator preparation → Input declarations: scans inputs (evidence: `src/Indicator/Indicator.class.ts`)
- Transpiler orchestration → Pine parser and codegen: parses source (evidence: `src/transpiler/index.ts`)
- Transpiler orchestration → Scope and analysis: runs analysis (evidence: `src/transpiler/index.ts`)
- Transpiler orchestration → AST transformations: transforms AST (evidence: `src/transpiler/index.ts`)
- Execution context → Time series: uses series (evidence: `src/Context.class.ts`)
- Provider aggregation → Candle aggregation: aggregates candles (evidence: `src/marketData/BaseProvider.ts`)
- Provider aggregation → Timeframe rules: normalizes intervals (evidence: `src/marketData/BaseProvider.ts`)
- PineTS engine → Timeframe rules: parses intervals (evidence: `src/PineTS.class.ts`)
- Execution context → Technical analysis: exposes namespace (evidence: `src/Context.class.ts`)
- Execution context → Cross-series requests: exposes namespace (evidence: `src/Context.class.ts`)
- Execution context → Strategy simulation: exposes namespace (evidence: `src/Context.class.ts`)
- Execution context → Pine data structures: exposes namespace (evidence: `src/Context.class.ts`)
- Execution context → Chart and drawing APIs: exposes plot API (evidence: `src/Context.class.ts`)
- PineTS engine → Plot series: returns plot series
- PineTS engine → Live bar updates: streams updates (evidence: `src/PineTS.class.ts`)
