# rodrigo-brito/ninjabot architecture

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

- Interactive diagram: https://gitdiagram.com/rodrigo-brito/ninjabot
- Repository: https://github.com/rodrigo-brito/ninjabot

## Overview

Ninjabot is a Go cryptocurrency trading framework for running custom strategies against historical or live spot/futures markets, with paper trading, order management, and a web dashboard. The main workflow is market data into strategy evaluation, then broker orders and persistence; users can also download historical candles and review results. The README documents additional dashboard controls, indicators, notifications, storage options, and trading tools. Several runtime paths are unsampled, so those subsystem links are documented rather than inferred from file names.

Main entry points: [`order/controller.go`](https://github.com/rodrigo-brito/ninjabot/blob/main/order/controller.go) (Order controller), [`web/src/App.tsx`](https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/App.tsx) (Dashboard app), [`ninjabot.go`](https://github.com/rodrigo-brito/ninjabot/blob/main/ninjabot.go) (Bot orchestrator), [`strategy/controller.go`](https://github.com/rodrigo-brito/ninjabot/blob/main/strategy/controller.go) (Strategy controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_bot["Bot orchestrator<br/>[ninjabot.go]"]
  node_models["Trading models<br/>[model.go]"]
end

subgraph group_markets["Market and orders"]
  node_market_data["Market data feed<br/>[exchange.go]"]
  node_binance["Binance spot<br/>[binance.go]"]
  node_futures["Binance futures<br/>[binance_future.go]"]
  node_csv["CSV feed<br/>[csvfeed.go]"]
  node_paper["Paper wallet<br/>[paperwallet.go]"]
  node_orders["Order controller<br/>[controller.go]"]
  node_storage[("Order storage<br/>[storage.go]")]
end

subgraph group_analytics["Strategy and results"]
  node_strategy["Strategy controller<br/>[controller.go]"]
  node_indicators["Indicators<br/>[talib.go]"]
  node_summary["Backtest results<br/>[controller.go]"]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard_server["Dashboard server<br/>[server.go]"]
  node_dashboard_api["Dashboard API client<br/>[client.ts]"]
  node_app["Dashboard app<br/>[App.tsx]"]
  node_controls["Control panel<br/>[ControlPanel.tsx]"]
  node_charts["Charts and stats<br/>[PriceChart.tsx]"]
  node_orders_view["Orders table<br/>[OrdersTable.tsx]"]
end

subgraph group_support["User capabilities"]
  node_downloader["Candle downloader<br/>[download.go]"]
  node_cli["Download CLI<br/>[ninjabot.go]"]
  node_notifier["Notifications<br/>[telegram.go]"]
  node_mail["Email notifications<br/>[mail.go]"]
end

node_trader(("Trader"))
node_exchange_service{{"Exchange service"}}

node_trader -->|"configures"| node_bot
node_bot -.->|"starts feed"| node_market_data
node_market_data -.->|"delivers candles"| node_strategy
node_strategy -.->|"calculates"| node_indicators
node_strategy -.->|"requests trades"| node_orders
node_orders -->|"places orders"| node_exchange_service
node_orders -->|"persists orders"| node_storage
node_orders -->|"tracks results"| node_summary
node_bot -->|"configures"| node_strategy
node_binance -.->|"implements"| node_exchange_service
node_futures -.->|"implements"| node_exchange_service
node_paper -->|"simulates trading"| node_exchange_service
node_csv -.->|"provides candles"| node_market_data
node_cli -->|"invokes"| node_downloader
node_downloader -->|"fetches history"| node_exchange_service
node_bot -->|"configures"| node_notifier
node_trader -->|"uses dashboard"| node_dashboard_server
node_app -->|"requests data"| node_dashboard_api
node_app -->|"renders"| node_controls
node_app -->|"renders"| node_charts
node_app -->|"renders"| node_orders_view
node_dashboard_api -->|"calls HTTP API"| node_dashboard_server
node_dashboard_server -.->|"controls bot"| node_orders
node_dashboard_server -.->|"serves wallet data"| node_paper

click node_bot "https://github.com/rodrigo-brito/ninjabot/blob/main/ninjabot.go"
click node_market_data "https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/exchange.go"
click node_binance "https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/binance.go"
click node_futures "https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/binance_future.go"
click node_csv "https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/csvfeed.go"
click node_paper "https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/paperwallet.go"
click node_strategy "https://github.com/rodrigo-brito/ninjabot/blob/main/strategy/controller.go"
click node_indicators "https://github.com/rodrigo-brito/ninjabot/blob/main/indicator/talib.go"
click node_orders "https://github.com/rodrigo-brito/ninjabot/blob/main/order/controller.go"
click node_storage "https://github.com/rodrigo-brito/ninjabot/blob/main/storage/storage.go"
click node_models "https://github.com/rodrigo-brito/ninjabot/blob/main/model/model.go"
click node_summary "https://github.com/rodrigo-brito/ninjabot/blob/main/order/controller.go"
click node_downloader "https://github.com/rodrigo-brito/ninjabot/blob/main/download/download.go"
click node_cli "https://github.com/rodrigo-brito/ninjabot/blob/main/cmd/ninjabot/ninjabot.go"
click node_notifier "https://github.com/rodrigo-brito/ninjabot/blob/main/notification/telegram.go"
click node_mail "https://github.com/rodrigo-brito/ninjabot/blob/main/notification/mail.go"
click node_dashboard_server "https://github.com/rodrigo-brito/ninjabot/blob/main/ui/server.go"
click node_dashboard_api "https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/api/client.ts"
click node_app "https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/App.tsx"
click node_controls "https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/components/ControlPanel.tsx"
click node_charts "https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/components/PriceChart.tsx"
click node_orders_view "https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/components/OrdersTable.tsx"

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_bot,node_models toneBlue
class node_market_data,node_binance,node_futures,node_csv,node_paper,node_orders,node_storage toneAmber
class node_strategy,node_indicators,node_summary toneMint
class node_dashboard_server,node_dashboard_api,node_app,node_controls,node_charts,node_orders_view toneRose
class node_downloader,node_cli,node_notifier,node_mail,node_trader,node_exchange_service toneIndigo
```

## Components

### Bot runtime

- [Bot orchestrator](https://github.com/rodrigo-brito/ninjabot/blob/main/ninjabot.go): `ninjabot.go`
- [Trading models](https://github.com/rodrigo-brito/ninjabot/blob/main/model/model.go): `model/model.go`

### Market and orders

- [Market data feed](https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/exchange.go): `exchange/exchange.go`
- [Binance spot](https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/binance.go): `exchange/binance.go`
- [Binance futures](https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/binance_future.go): `exchange/binance_future.go`
- [CSV feed](https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/csvfeed.go): `exchange/csvfeed.go`
- [Paper wallet](https://github.com/rodrigo-brito/ninjabot/blob/main/exchange/paperwallet.go): `exchange/paperwallet.go`
- [Order controller](https://github.com/rodrigo-brito/ninjabot/blob/main/order/controller.go): `order/controller.go`
- [Order storage](https://github.com/rodrigo-brito/ninjabot/blob/main/storage/storage.go): `storage/storage.go`

### Strategy and results

- [Strategy controller](https://github.com/rodrigo-brito/ninjabot/blob/main/strategy/controller.go): `strategy/controller.go`
- [Indicators](https://github.com/rodrigo-brito/ninjabot/blob/main/indicator/talib.go): `indicator/talib.go`
- [Backtest results](https://github.com/rodrigo-brito/ninjabot/blob/main/order/controller.go): `order/controller.go`

### Dashboard

- [Dashboard server](https://github.com/rodrigo-brito/ninjabot/blob/main/ui/server.go): `ui/server.go`
- [Dashboard API client](https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/api/client.ts): `web/src/api/client.ts`
- [Dashboard app](https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Control panel](https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/components/ControlPanel.tsx): `web/src/components/ControlPanel.tsx`
- [Charts and stats](https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/components/PriceChart.tsx): `web/src/components/PriceChart.tsx`
- [Orders table](https://github.com/rodrigo-brito/ninjabot/blob/main/web/src/components/OrdersTable.tsx): `web/src/components/OrdersTable.tsx`

### User capabilities

- [Candle downloader](https://github.com/rodrigo-brito/ninjabot/blob/main/download/download.go): `download/download.go`
- [Download CLI](https://github.com/rodrigo-brito/ninjabot/blob/main/cmd/ninjabot/ninjabot.go): `cmd/ninjabot/ninjabot.go`
- [Notifications](https://github.com/rodrigo-brito/ninjabot/blob/main/notification/telegram.go): `notification/telegram.go`
- [Email notifications](https://github.com/rodrigo-brito/ninjabot/blob/main/notification/mail.go): `notification/mail.go`

### Other components

- **Trader**
- **Exchange service**

## Connections

- Trader → Bot orchestrator: configures
- Bot orchestrator → Market data feed: starts feed
- Market data feed → Strategy controller: delivers candles
- Strategy controller → Indicators: calculates
- Strategy controller → Order controller: requests trades
- Order controller → Exchange service: places orders (evidence: `order/controller.go`)
- Order controller → Order storage: persists orders (evidence: `order/controller.go`)
- Order controller → Backtest results: tracks results (evidence: `order/controller.go`)
- Bot orchestrator → Strategy controller: configures (evidence: `ninjabot.go`)
- Binance spot → Exchange service: implements
- Binance futures → Exchange service: implements
- Paper wallet → Exchange service: simulates trading (evidence: `exchange/paperwallet.go`)
- CSV feed → Market data feed: provides candles
- Download CLI → Candle downloader: invokes (evidence: `cmd/ninjabot/ninjabot.go`)
- Candle downloader → Exchange service: fetches history (evidence: `download/download.go`)
- Bot orchestrator → Notifications: configures (evidence: `ninjabot.go`)
- Trader → Dashboard server: uses dashboard
- Dashboard app → Dashboard API client: requests data (evidence: `web/src/App.tsx`)
- Dashboard app → Control panel: renders (evidence: `web/src/App.tsx`)
- Dashboard app → Charts and stats: renders (evidence: `web/src/App.tsx`)
- Dashboard app → Orders table: renders (evidence: `web/src/App.tsx`)
- Dashboard API client → Dashboard server: calls HTTP API
- Dashboard server → Order controller: controls bot
- Dashboard server → Paper wallet: serves wallet data
