# ryanbusby/forexstream-gcp architecture

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

- Interactive diagram: https://gitdiagram.com/ryanbusby/forexstream-gcp
- Repository: https://github.com/ryanbusby/forexstream-gcp

## Overview

Streaming Forex Data is a Flask application that presents live forex rates, OHLC charts, and historical returns. A separate scraper process fetches market data from Forex.com and persists rate and OHLC records in PostgreSQL; web routes then query that store through chart builders and return rendered pages or chart data. The graph captures the documented visualization modes, but template-level asset wiring and some scraper internals were not sampled, so those relationships are not asserted.

Main entry points: [`main.py`](https://github.com/ryanbusby/forexstream-gcp/blob/main/main.py) (Flask Routes), [`models.py`](https://github.com/ryanbusby/forexstream-gcp/blob/main/models.py) (PostgreSQL Market Data), [`cg_scraper.py`](https://github.com/ryanbusby/forexstream-gcp/blob/main/cg_scraper.py) (Forex Scraper), [`high_charts_builder.py`](https://github.com/ryanbusby/forexstream-gcp/blob/main/high_charts_builder.py) (Highcharts Data Builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Market Ingestion"]
  node_scraper["Forex Scraper<br/>[cg_scraper.py]"]
  node_market_config["Market Definitions<br/>[market_dicts.py]"]
end

subgraph group_storage["Market Storage"]
  node_market_store[("PostgreSQL Market Data<br/>[models.py]")]
end

subgraph group_web["Web Application"]
  node_web_routes["Flask Routes<br/>[main.py]"]
  node_page_templates["Chart Pages<br/>[index.html]"]
end

subgraph group_charts["Chart Generation"]
  node_hc_builder["Highcharts Data Builder"]
  node_bokeh_builder["Bokeh Plot Builder"]
end

subgraph group_browser["Browser Visualization"]
  node_highstock["Highstock Runtime<br/>[highstock.js]"]
  node_bokeh_runtime["Bokeh Runtime<br/>[bokeh-2_3_0min.js]"]
end

node_operator(("Viewer or Operator"))
node_forex_api{{"Forex.com API"}}

node_operator -->|"requests pages"| node_web_routes
node_forex_api -->|"provides market data"| node_scraper
node_scraper -->|"writes records"| node_market_store
node_scraper -->|"uses market definitions"| node_market_config
node_web_routes -->|"renders pages"| node_page_templates
node_web_routes -->|"requests chart data"| node_hc_builder
node_web_routes -->|"builds plot components"| node_bokeh_builder
node_hc_builder -->|"queries records"| node_market_store
node_bokeh_builder -->|"reads records"| node_market_store
node_web_routes -->|"queries rate history"| node_market_store
node_web_routes -->|"returns pages and JSON"| node_operator

click node_scraper "https://github.com/ryanbusby/forexstream-gcp/blob/main/cg_scraper.py"
click node_market_config "https://github.com/ryanbusby/forexstream-gcp/blob/main/market_dicts.py"
click node_market_store "https://github.com/ryanbusby/forexstream-gcp/blob/main/models.py"
click node_web_routes "https://github.com/ryanbusby/forexstream-gcp/blob/main/main.py"
click node_page_templates "https://github.com/ryanbusby/forexstream-gcp/blob/main/templates/index.html"
click node_hc_builder "https://github.com/ryanbusby/forexstream-gcp/blob/main/high_charts_builder.py"
click node_bokeh_builder "https://github.com/ryanbusby/forexstream-gcp/blob/main/bokeh_plots_builder.py"
click node_highstock "https://github.com/ryanbusby/forexstream-gcp/blob/main/static/js/highstock.js"
click node_bokeh_runtime "https://github.com/ryanbusby/forexstream-gcp/blob/main/static/js/bokeh-2_3_0min.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_scraper,node_market_config,node_operator toneBlue
class node_market_store toneAmber
class node_web_routes,node_page_templates,node_forex_api toneMint
class node_hc_builder,node_bokeh_builder toneRose
class node_highstock,node_bokeh_runtime toneIndigo
```

## Components

### Market Ingestion

- [Forex Scraper](https://github.com/ryanbusby/forexstream-gcp/blob/main/cg_scraper.py): `cg_scraper.py`
- [Market Definitions](https://github.com/ryanbusby/forexstream-gcp/blob/main/market_dicts.py): `market_dicts.py`

### Market Storage

- [PostgreSQL Market Data](https://github.com/ryanbusby/forexstream-gcp/blob/main/models.py): `models.py`

### Web Application

- [Flask Routes](https://github.com/ryanbusby/forexstream-gcp/blob/main/main.py): `main.py`
- [Chart Pages](https://github.com/ryanbusby/forexstream-gcp/blob/main/templates/index.html): `templates/index.html`

### Chart Generation

- [Highcharts Data Builder](https://github.com/ryanbusby/forexstream-gcp/blob/main/high_charts_builder.py): `high_charts_builder.py`
- [Bokeh Plot Builder](https://github.com/ryanbusby/forexstream-gcp/blob/main/bokeh_plots_builder.py): `bokeh_plots_builder.py`

### Browser Visualization

- [Highstock Runtime](https://github.com/ryanbusby/forexstream-gcp/blob/main/static/js/highstock.js): `static/js/highstock.js`
- [Bokeh Runtime](https://github.com/ryanbusby/forexstream-gcp/blob/main/static/js/bokeh-2_3_0min.js): `static/js/bokeh-2_3_0min.js`

### Other components

- **Viewer or Operator**
- **Forex.com API**

## Connections

- Viewer or Operator → Flask Routes: requests pages (evidence: `main.py`)
- Forex.com API → Forex Scraper: provides market data (evidence: `README.md`)
- Forex Scraper → PostgreSQL Market Data: writes records (evidence: `cg_scraper.py`)
- Forex Scraper → Market Definitions: uses market definitions (evidence: `cg_scraper.py`)
- Flask Routes → Chart Pages: renders pages (evidence: `main.py`)
- Flask Routes → Highcharts Data Builder: requests chart data (evidence: `main.py`)
- Flask Routes → Bokeh Plot Builder: builds plot components (evidence: `main.py`)
- Highcharts Data Builder → PostgreSQL Market Data: queries records (evidence: `high_charts_builder.py`)
- Bokeh Plot Builder → PostgreSQL Market Data: reads records (evidence: `bokeh_plots_builder.py`)
- Flask Routes → PostgreSQL Market Data: queries rate history (evidence: `main.py`)
- Flask Routes → Viewer or Operator: returns pages and JSON (evidence: `main.py`)
