# omarkhaled4418/binance_bot_v2 architecture

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

- Interactive diagram: https://gitdiagram.com/omarkhaled4418/binance_bot_v2
- Repository: https://github.com/omarkhaled4418/binance_bot_v2

## Overview

This repository is a Binance trading bot operated through a live dashboard. A user configures a symbol, target, and trade size in the browser; the Flask API creates a Binance client and starts a price monitor. Price updates reach the dashboard, while a target trigger calls the sell-order logic. On price drops, the API can optionally scan for a top 4-hour gainer, convert the position, and resume monitoring; it can also send an optional n8n webhook. The README is empty, so capabilities and links here rely on the supplied source excerpts and index; unshown dashboard and monitor internals are not inferred.

Main entry points: [`dashboard/app.py`](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/dashboard/app.py) (Flask API), [`bot/binance_client.py`](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/binance_client.py) (Binance client), [`bot/price_monitor.py`](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/price_monitor.py) (Price monitor), [`bot/order_manager.py`](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/order_manager.py) (Order manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_web_ui["Web interface<br/>[app.js]"]
  node_api["Flask API<br/>[app.py]"]
end

subgraph group_control["Bot control"]
  node_settings["Settings<br/>[settings.py]"]
end

subgraph group_trading["Trading engine"]
  node_client["Binance client<br/>[binance_client.py]"]
  node_monitor["Price monitor<br/>[price_monitor.py]"]
  node_orders["Order manager<br/>[order_manager.py]"]
  node_strategy["Gainer scanner<br/>[strategy.py]"]
end

subgraph group_integrations["External services"]
  node_binance{{"Binance"}}
  node_n8n{{"n8n webhook"}}
end

node_user(("Trader"))

node_user -->|"configures"| node_web_ui
node_web_ui -->|"calls API"| node_api
node_api -->|"reads defaults"| node_settings
node_api -->|"creates client"| node_client
node_api -->|"starts monitor"| node_monitor
node_api -->|"places sells"| node_orders
node_api -->|"scans gainers"| node_strategy
node_monitor -->|"gets client"| node_client
node_orders -->|"gets symbol info"| node_client
node_client -->|"reads credentials"| node_settings
node_client -->|"requests market data"| node_binance
node_monitor -->|"streams prices"| node_binance
node_orders -->|"submits orders"| node_binance
node_strategy -->|"scans market"| node_binance
node_api -.->|"posts webhook"| node_n8n

click node_web_ui "https://github.com/omarkhaled4418/binance_bot_v2/blob/master/dashboard/static/js/app.js"
click node_api "https://github.com/omarkhaled4418/binance_bot_v2/blob/master/dashboard/app.py"
click node_settings "https://github.com/omarkhaled4418/binance_bot_v2/blob/master/config/settings.py"
click node_client "https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/binance_client.py"
click node_monitor "https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/price_monitor.py"
click node_orders "https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/order_manager.py"
click node_strategy "https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/strategy.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_web_ui,node_api toneBlue
class node_settings toneAmber
class node_client,node_monitor,node_orders,node_strategy toneMint
class node_binance,node_n8n toneRose
class node_user toneIndigo
```

## Components

### Dashboard

- [Web interface](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/dashboard/static/js/app.js): `dashboard/static/js/app.js`
- [Flask API](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/dashboard/app.py): `dashboard/app.py`

### Bot control

- [Settings](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/config/settings.py): `config/settings.py`

### Trading engine

- [Binance client](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/binance_client.py): `bot/binance_client.py`
- [Price monitor](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/price_monitor.py): `bot/price_monitor.py`
- [Order manager](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/order_manager.py): `bot/order_manager.py`
- [Gainer scanner](https://github.com/omarkhaled4418/binance_bot_v2/blob/master/bot/strategy.py): `bot/strategy.py`

### External services

- **Binance**
- **n8n webhook**

### Other components

- **Trader**

## Connections

- Trader → Web interface: configures (evidence: `dashboard/static/js/app.js`)
- Web interface → Flask API: calls API (evidence: `dashboard/static/js/app.js`)
- Flask API → Settings: reads defaults (evidence: `dashboard/app.py`)
- Flask API → Binance client: creates client (evidence: `dashboard/app.py`)
- Flask API → Price monitor: starts monitor (evidence: `dashboard/app.py`)
- Flask API → Order manager: places sells (evidence: `dashboard/app.py`)
- Flask API → Gainer scanner: scans gainers (evidence: `dashboard/app.py`)
- Price monitor → Binance client: gets client (evidence: `bot/price_monitor.py`)
- Order manager → Binance client: gets symbol info (evidence: `bot/order_manager.py`)
- Binance client → Settings: reads credentials (evidence: `bot/binance_client.py`)
- Binance client → Binance: requests market data (evidence: `bot/binance_client.py`)
- Price monitor → Binance: streams prices (evidence: `bot/price_monitor.py`)
- Order manager → Binance: submits orders (evidence: `bot/order_manager.py`)
- Gainer scanner → Binance: scans market (evidence: `bot/strategy.py`)
- Flask API → n8n webhook: posts webhook (evidence: `dashboard/app.py`)
