# cbyn/bitpredict architecture

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

- Interactive diagram: https://gitdiagram.com/cbyn/bitpredict
- Repository: https://github.com/cbyn/bitpredict

## Overview

bitpredict collects Bitfinex order-book and trade snapshots, engineers microstructure features, trains and evaluates prediction models, then runs threshold-based theoretical trading and presents prediction/performance charts. The graph follows documented workflows and sampled calls; unsampled runtime details are omitted, and uncertain training-to-live model handoff is shown as unverified.

Main entry points: [`model/features.py`](https://github.com/cbyn/bitpredict/blob/master/model/features.py) (Feature Engineering), [`model/model.py`](https://github.com/cbyn/bitpredict/blob/master/model/model.py) (Model Training), [`app/predict.py`](https://github.com/cbyn/bitpredict/blob/master/app/predict.py) (Live Prediction), [`collect-data/collect_books.py`](https://github.com/cbyn/bitpredict/blob/master/collect-data/collect_books.py) (Book Collector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Market Data"]
  node_collect_books["Book Collector<br/>[collect_books.py]"]
  node_collect_trades["Trade Collector<br/>[collect_trades.py]"]
  node_market_db[("Market MongoDB")]
  node_aggregation["Trade Aggregation<br/>[group_ltc.js]"]
end

subgraph group_analytics["Prediction Analytics"]
  node_features["Feature Engineering<br/>[features.py]"]
  node_model_fit["Model Training<br/>[model.py]"]
  node_backtest["Strategy Backtest<br/>[strategy.py]"]
end

subgraph group_live["Live Trading"]
  node_live_predict["Live Prediction<br/>[predict.py]"]
  node_prediction_db[("Prediction MongoDB")]
  node_prediction_check["Prediction Checks<br/>[check_preds.py]"]
  node_performance["Performance Analysis<br/>[performance.py]"]
end

subgraph group_presentation["Web Presentation"]
  node_charts["Live Charts<br/>[run_charts.py]"]
  node_extended_charts["Extended Charts"]
  node_performance_charts["Performance Charts"]
  node_flask["Flask App<br/>[app.py]"]
  node_templates["Chart Pages"]
end

subgraph group_browser["Browser Libraries"]
  node_jquery["jQuery<br/>[jquery.js]"]
  node_bootstrap["Bootstrap<br/>[bootstrap.js]"]
end

node_user(("User"))
node_bitfinex{{"Bitfinex API"}}

node_collect_books -->|"fetches books"| node_bitfinex
node_collect_trades -->|"fetches trades"| node_bitfinex
node_collect_books -->|"writes snapshots"| node_market_db
node_collect_trades -->|"writes trades"| node_market_db
node_features -->|"reads market data"| node_market_db
node_aggregation -->|"aggregates trades"| node_market_db
node_features -->|"engineers model inputs"| node_model_fit
node_model_fit -.->|"supports strategy evaluation"| node_backtest
node_features -->|"builds live features"| node_live_predict
node_model_fit -.->|"supplies trained model"| node_live_predict
node_live_predict -->|"writes predictions"| node_prediction_db
node_prediction_check -.->|"checks predictions"| node_prediction_db
node_performance -.->|"analyzes results"| node_prediction_db
node_charts -->|"reads chart data"| node_prediction_db
node_extended_charts -->|"reads chart data"| node_prediction_db
node_performance_charts -.->|"reads chart data"| node_prediction_db
node_user -->|"requests pages"| node_flask
node_flask -->|"renders pages"| node_templates
node_bootstrap -->|"requires"| node_jquery

click node_collect_books "https://github.com/cbyn/bitpredict/blob/master/collect-data/collect_books.py"
click node_collect_trades "https://github.com/cbyn/bitpredict/blob/master/collect-data/collect_trades.py"
click node_aggregation "https://github.com/cbyn/bitpredict/blob/master/mongo-queries/group_ltc.js"
click node_features "https://github.com/cbyn/bitpredict/blob/master/model/features.py"
click node_model_fit "https://github.com/cbyn/bitpredict/blob/master/model/model.py"
click node_backtest "https://github.com/cbyn/bitpredict/blob/master/model/strategy.py"
click node_live_predict "https://github.com/cbyn/bitpredict/blob/master/app/predict.py"
click node_prediction_check "https://github.com/cbyn/bitpredict/blob/master/app/check_preds.py"
click node_performance "https://github.com/cbyn/bitpredict/blob/master/app/performance.py"
click node_charts "https://github.com/cbyn/bitpredict/blob/master/app/run_charts.py"
click node_extended_charts "https://github.com/cbyn/bitpredict/blob/master/app/run_charts_extended.py"
click node_performance_charts "https://github.com/cbyn/bitpredict/blob/master/app/run_charts_performance.py"
click node_flask "https://github.com/cbyn/bitpredict/blob/master/app/app.py"
click node_templates "https://github.com/cbyn/bitpredict/tree/master/app/templates"
click node_jquery "https://github.com/cbyn/bitpredict/blob/master/app/static/js/jquery.js"
click node_bootstrap "https://github.com/cbyn/bitpredict/blob/master/app/static/js/bootstrap.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_collect_books,node_collect_trades,node_market_db,node_aggregation,node_user toneBlue
class node_features,node_model_fit,node_backtest toneAmber
class node_live_predict,node_prediction_db,node_prediction_check,node_performance,node_bitfinex toneMint
class node_charts,node_extended_charts,node_performance_charts,node_flask,node_templates toneRose
class node_jquery,node_bootstrap toneIndigo
```

## Components

### Market Data

- [Book Collector](https://github.com/cbyn/bitpredict/blob/master/collect-data/collect_books.py): `collect-data/collect_books.py`
- [Trade Collector](https://github.com/cbyn/bitpredict/blob/master/collect-data/collect_trades.py): `collect-data/collect_trades.py`
- **Market MongoDB**
- [Trade Aggregation](https://github.com/cbyn/bitpredict/blob/master/mongo-queries/group_ltc.js): `mongo-queries/group_ltc.js`

### Prediction Analytics

- [Feature Engineering](https://github.com/cbyn/bitpredict/blob/master/model/features.py): `model/features.py`
- [Model Training](https://github.com/cbyn/bitpredict/blob/master/model/model.py): `model/model.py`
- [Strategy Backtest](https://github.com/cbyn/bitpredict/blob/master/model/strategy.py): `model/strategy.py`

### Live Trading

- [Live Prediction](https://github.com/cbyn/bitpredict/blob/master/app/predict.py): `app/predict.py`
- **Prediction MongoDB**
- [Prediction Checks](https://github.com/cbyn/bitpredict/blob/master/app/check_preds.py): `app/check_preds.py`
- [Performance Analysis](https://github.com/cbyn/bitpredict/blob/master/app/performance.py): `app/performance.py`

### Web Presentation

- [Live Charts](https://github.com/cbyn/bitpredict/blob/master/app/run_charts.py): `app/run_charts.py`
- [Extended Charts](https://github.com/cbyn/bitpredict/blob/master/app/run_charts_extended.py): `app/run_charts_extended.py`
- [Performance Charts](https://github.com/cbyn/bitpredict/blob/master/app/run_charts_performance.py): `app/run_charts_performance.py`
- [Flask App](https://github.com/cbyn/bitpredict/blob/master/app/app.py): `app/app.py`
- [Chart Pages](https://github.com/cbyn/bitpredict/tree/master/app/templates): `app/templates`

### Browser Libraries

- [jQuery](https://github.com/cbyn/bitpredict/blob/master/app/static/js/jquery.js): `app/static/js/jquery.js`
- [Bootstrap](https://github.com/cbyn/bitpredict/blob/master/app/static/js/bootstrap.js): `app/static/js/bootstrap.js`

### Other components

- **User**
- **Bitfinex API**

## Connections

- Book Collector → Bitfinex API: fetches books (evidence: `collect-data/collect_books.py`)
- Trade Collector → Bitfinex API: fetches trades (evidence: `collect-data/collect_trades.py`)
- Book Collector → Market MongoDB: writes snapshots (evidence: `collect-data/collect_books.py`)
- Trade Collector → Market MongoDB: writes trades (evidence: `collect-data/collect_trades.py`)
- Feature Engineering → Market MongoDB: reads market data (evidence: `model/features.py`)
- Trade Aggregation → Market MongoDB: aggregates trades (evidence: `mongo-queries/group_ltc.js`)
- Feature Engineering → Model Training: engineers model inputs (evidence: `README.md`)
- Model Training → Strategy Backtest: supports strategy evaluation
- Feature Engineering → Live Prediction: builds live features (evidence: `app/predict.py`)
- Model Training → Live Prediction: supplies trained model
- Live Prediction → Prediction MongoDB: writes predictions (evidence: `app/predict.py`)
- Prediction Checks → Prediction MongoDB: checks predictions
- Performance Analysis → Prediction MongoDB: analyzes results
- Live Charts → Prediction MongoDB: reads chart data (evidence: `app/run_charts.py`)
- Extended Charts → Prediction MongoDB: reads chart data (evidence: `app/run_charts_extended.py`)
- Performance Charts → Prediction MongoDB: reads chart data
- User → Flask App: requests pages (evidence: `app/app.py`)
- Flask App → Chart Pages: renders pages (evidence: `app/app.py`)
- Bootstrap → jQuery: requires (evidence: `app/static/js/bootstrap.js`)
