# bevry-trading/automated-trading architecture

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

- Interactive diagram: https://gitdiagram.com/bevry-trading/automated-trading
- Repository: https://github.com/bevry-trading/automated-trading

## Overview

This is a paused automated-trading setup: TradingView strategies generate alerts that reach Firebase Functions, which parse orders and dispatch them to supported exchange APIs. The runtime also manages user and exchange-service records and can fetch CoinMarketCap data. The README documents the TradingView/SMS/Twilio path; sampled function source shows Firebase routing, persistence, and exchange calls. The documented alert delivery and TradingView setup are not implemented in the sampled functions.

Main entry points: [`firebase/functions/index.js`](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/index.js) (Alert Parser), [`firebase/functions/cryptomarketcap.js`](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/cryptomarketcap.js) (Market Data Fetch), [`tradingview/bal--alice--strategy.pine`](https://github.com/bevry-trading/automated-trading/blob/master/tradingview/bal--alice--strategy.pine) (Trading Strategies), [`firebase/functions/util.js`](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/util.js) (Service Lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_signals["TradingView Signals"]
  node_strategies["Trading Strategies"]
  node_studies["Alert Studies"]
end

subgraph group_runtime["Firebase Runtime"]
  node_functions["HTTP Functions<br/>[index.js]"]
  node_orderparse["Alert Parser<br/>[index.js]"]
  node_serviceutil["Service Lookup<br/>[util.js]"]
end

subgraph group_integrations["Market Integrations"]
  node_bitfinex["Bitfinex Adapter<br/>[bitfinex.js]"]
  node_itbit["itBit Adapter<br/>[itbit.js]"]
  node_drivewealth["DriveWealth Adapter<br/>[drivewealth.js]"]
  node_marketfetch["Market Data Fetch<br/>[cryptomarketcap.js]"]
end

subgraph group_state["Persistent Data"]
  node_firestore[("Firestore")]
end

node_trader(("Strategy Operator"))
node_tradingview(("TradingView"))
node_sms["SMS Alerts"]
node_twilio["Twilio Webhook"]
node_exchangeapis["Exchange APIs"]
node_coinmarketcap["CoinMarketCap API"]

node_trader -->|"configures"| node_strategies
node_strategies -->|"backtests on"| node_tradingview
node_studies -->|"creates alerts"| node_tradingview
node_tradingview -->|"sends alerts"| node_sms
node_sms -->|"delivers message"| node_twilio
node_twilio -->|"webhook request"| node_functions
node_functions -->|"routes parse"| node_orderparse
node_orderparse -->|"loads services"| node_serviceutil
node_serviceutil -->|"reads services"| node_firestore
node_orderparse -->|"dispatches orders"| node_bitfinex
node_orderparse -->|"dispatches orders"| node_itbit
node_orderparse -->|"dispatches orders"| node_drivewealth
node_bitfinex -->|"calls API"| node_exchangeapis
node_itbit -->|"calls API"| node_exchangeapis
node_drivewealth -->|"calls API"| node_exchangeapis
node_orderparse -->|"stores orders"| node_firestore
node_functions -->|"routes fetch"| node_marketfetch
node_marketfetch -->|"fetches data"| node_coinmarketcap
node_marketfetch -->|"stores market data"| node_firestore

click node_strategies "https://github.com/bevry-trading/automated-trading/blob/master/tradingview/bal--alice--strategy.pine"
click node_studies "https://github.com/bevry-trading/automated-trading/blob/master/tradingview/bal--alice--study.pine"
click node_functions "https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/index.js"
click node_orderparse "https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/index.js"
click node_serviceutil "https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/util.js"
click node_bitfinex "https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/bitfinex.js"
click node_itbit "https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/itbit.js"
click node_drivewealth "https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/drivewealth.js"
click node_marketfetch "https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/cryptomarketcap.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_strategies,node_studies,node_tradingview toneBlue
class node_functions,node_orderparse,node_serviceutil toneAmber
class node_bitfinex,node_itbit,node_drivewealth,node_marketfetch,node_twilio,node_exchangeapis,node_coinmarketcap toneMint
class node_firestore toneRose
class node_trader,node_sms toneIndigo
```

## Components

### TradingView Signals

- [Trading Strategies](https://github.com/bevry-trading/automated-trading/blob/master/tradingview/bal--alice--strategy.pine): `tradingview/bal--alice--strategy.pine`
- [Alert Studies](https://github.com/bevry-trading/automated-trading/blob/master/tradingview/bal--alice--study.pine): `tradingview/bal--alice--study.pine`

### Firebase Runtime

- [HTTP Functions](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/index.js): `firebase/functions/index.js`
- [Alert Parser](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/index.js): `firebase/functions/index.js`
- [Service Lookup](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/util.js): `firebase/functions/util.js`

### Market Integrations

- [Bitfinex Adapter](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/bitfinex.js): `firebase/functions/bitfinex.js`
- [itBit Adapter](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/itbit.js): `firebase/functions/itbit.js`
- [DriveWealth Adapter](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/drivewealth.js): `firebase/functions/drivewealth.js`
- [Market Data Fetch](https://github.com/bevry-trading/automated-trading/blob/master/firebase/functions/cryptomarketcap.js): `firebase/functions/cryptomarketcap.js`

### Persistent Data

- **Firestore**

### Other components

- **Strategy Operator**
- **TradingView**
- **SMS Alerts**
- **Twilio Webhook**
- **Exchange APIs**
- **CoinMarketCap API**

## Connections

- Strategy Operator → Trading Strategies: configures (evidence: `README.md`)
- Trading Strategies → TradingView: backtests on (evidence: `README.md`)
- Alert Studies → TradingView: creates alerts (evidence: `README.md`)
- TradingView → SMS Alerts: sends alerts (evidence: `README.md`)
- SMS Alerts → Twilio Webhook: delivers message (evidence: `README.md`)
- Twilio Webhook → HTTP Functions: webhook request (evidence: `README.md`)
- HTTP Functions → Alert Parser: routes parse (evidence: `firebase/functions/index.js`)
- Alert Parser → Service Lookup: loads services (evidence: `firebase/functions/index.js`)
- Service Lookup → Firestore: reads services (evidence: `firebase/functions/util.js`)
- Alert Parser → Bitfinex Adapter: dispatches orders (evidence: `firebase/functions/index.js`)
- Alert Parser → itBit Adapter: dispatches orders (evidence: `firebase/functions/index.js`)
- Alert Parser → DriveWealth Adapter: dispatches orders (evidence: `firebase/functions/index.js`)
- Bitfinex Adapter → Exchange APIs: calls API (evidence: `firebase/functions/bitfinex.js`)
- itBit Adapter → Exchange APIs: calls API (evidence: `firebase/functions/itbit.js`)
- DriveWealth Adapter → Exchange APIs: calls API (evidence: `firebase/functions/drivewealth.js`)
- Alert Parser → Firestore: stores orders (evidence: `firebase/functions/index.js`)
- HTTP Functions → Market Data Fetch: routes fetch (evidence: `firebase/functions/index.js`)
- Market Data Fetch → CoinMarketCap API: fetches data (evidence: `firebase/functions/cryptomarketcap.js`)
- Market Data Fetch → Firestore: stores market data (evidence: `firebase/functions/cryptomarketcap.js`)
