# rich-hyun/check_bit architecture

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

- Interactive diagram: https://gitdiagram.com/rich-hyun/check_bit
- Repository: https://github.com/rich-hyun/check_bit

## Overview

check_bit is a small Bitcoin market-data collector with a FastAPI control and status API and a browser dashboard. The workflow is: an operator starts collection in the dashboard, the API launches the collector, and Upbit trade and order-book messages are combined into CSV rows; the dashboard polls status and can stop collection or request a download. The README documents no additional capabilities. The excerpts show the start path, but stop only clears the API flag and does not stop the WebSocket loop.

Main entry points: [`main.py`](https://github.com/rich-hyun/check_bit/blob/main/main.py) (FastAPI routes), [`collector.py`](https://github.com/rich-hyun/check_bit/blob/main/collector.py) (Message handler), [`app.js`](https://github.com/rich-hyun/check_bit/blob/main/app.js) (Dashboard controls), [`btc_anomaly_dataset.csv`](https://github.com/rich-hyun/check_bit/blob/main/btc_anomaly_dataset.csv) (BTC dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_dashboard_ui["Dashboard controls<br/>[app.js]"]
end

subgraph group_api["Control API"]
  node_api_app["FastAPI routes<br/>[main.py]"]
  node_collector_thread["Collector thread<br/>[main.py]"]
  node_download_response["CSV download<br/>[main.py]"]
end

subgraph group_collection["Market collection"]
  node_upbit["Upbit WebSocket"]
  node_ws_handler["Message handler<br/>[collector.py]"]
  node_orderbook_state["Latest order book<br/>[collector.py]"]
  node_trade_writer["Trade row writer<br/>[collector.py]"]
end

subgraph group_data["Dataset"]
  node_csv_dataset[("BTC dataset")]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_dashboard_ui
node_dashboard_ui -->|"requests status"| node_api_app
node_dashboard_ui -->|"starts collector"| node_api_app
node_dashboard_ui -->|"stops collector"| node_api_app
node_api_app -->|"spawns thread"| node_collector_thread
node_collector_thread -->|"starts collection"| node_ws_handler
node_ws_handler -->|"subscribes to"| node_upbit
node_upbit -->|"sends messages"| node_ws_handler
node_ws_handler -->|"updates order book"| node_orderbook_state
node_ws_handler -->|"saves trades"| node_trade_writer
node_trade_writer -->|"reads snapshot"| node_orderbook_state
node_trade_writer -->|"appends rows"| node_csv_dataset
node_api_app -->|"counts rows"| node_csv_dataset
node_api_app -->|"serves file"| node_download_response
node_download_response -->|"reads CSV"| node_csv_dataset

click node_dashboard_ui "https://github.com/rich-hyun/check_bit/blob/main/app.js"
click node_api_app "https://github.com/rich-hyun/check_bit/blob/main/main.py"
click node_collector_thread "https://github.com/rich-hyun/check_bit/blob/main/main.py"
click node_ws_handler "https://github.com/rich-hyun/check_bit/blob/main/collector.py"
click node_orderbook_state "https://github.com/rich-hyun/check_bit/blob/main/collector.py"
click node_trade_writer "https://github.com/rich-hyun/check_bit/blob/main/collector.py"
click node_csv_dataset "https://github.com/rich-hyun/check_bit/blob/main/btc_anomaly_dataset.csv"
click node_download_response "https://github.com/rich-hyun/check_bit/blob/main/main.py"

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_dashboard_ui toneBlue
class node_api_app,node_collector_thread,node_download_response toneAmber
class node_upbit,node_ws_handler,node_orderbook_state,node_trade_writer toneMint
class node_csv_dataset toneRose
class node_operator toneIndigo
```

## Components

### Dashboard

- [Dashboard controls](https://github.com/rich-hyun/check_bit/blob/main/app.js): `app.js`

### Control API

- [FastAPI routes](https://github.com/rich-hyun/check_bit/blob/main/main.py): `main.py`
- [Collector thread](https://github.com/rich-hyun/check_bit/blob/main/main.py): `main.py`
- [CSV download](https://github.com/rich-hyun/check_bit/blob/main/main.py): `main.py`

### Market collection

- **Upbit WebSocket**
- [Message handler](https://github.com/rich-hyun/check_bit/blob/main/collector.py): `collector.py`
- [Latest order book](https://github.com/rich-hyun/check_bit/blob/main/collector.py): `collector.py`
- [Trade row writer](https://github.com/rich-hyun/check_bit/blob/main/collector.py): `collector.py`

### Dataset

- [BTC dataset](https://github.com/rich-hyun/check_bit/blob/main/btc_anomaly_dataset.csv): `btc_anomaly_dataset.csv`

### Other components

- **Operator**

## Connections

- Operator → Dashboard controls: uses (evidence: `app.js`)
- Dashboard controls → FastAPI routes: requests status (evidence: `app.js`)
- Dashboard controls → FastAPI routes: starts collector (evidence: `app.js`)
- Dashboard controls → FastAPI routes: stops collector (evidence: `app.js`)
- FastAPI routes → Collector thread: spawns thread (evidence: `main.py`)
- Collector thread → Message handler: starts collection (evidence: `main.py`)
- Message handler → Upbit WebSocket: subscribes to (evidence: `collector.py`)
- Upbit WebSocket → Message handler: sends messages (evidence: `collector.py`)
- Message handler → Latest order book: updates order book (evidence: `collector.py`)
- Message handler → Trade row writer: saves trades (evidence: `collector.py`)
- Trade row writer → Latest order book: reads snapshot (evidence: `collector.py`)
- Trade row writer → BTC dataset: appends rows (evidence: `collector.py`)
- FastAPI routes → BTC dataset: counts rows (evidence: `main.py`)
- FastAPI routes → CSV download: serves file (evidence: `main.py`)
- CSV download → BTC dataset: reads CSV (evidence: `main.py`)
