# j-sravani15/crypto-trading-system architecture

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

- Interactive diagram: https://gitdiagram.com/j-sravani15/crypto-trading-system
- Repository: https://github.com/j-sravani15/crypto-trading-system

## Overview

CTP·BOT is a React dashboard backed by a FastAPI crypto-trading service for Binance Spot Testnet. A user authenticates, views market data and EMA/RSI signals, then can place or automate test orders; resulting trades are stored in SQLite. Separate capabilities cover account/order management, background polling, multi-symbol scanning, risk checks, Gemini chat and AI analysis, and per-user settings. The graph uses README-described flows where route implementations were not excerpted; those relationships are cited to the README rather than treated as source inspection.

Main entry points: [`backend/main.py`](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/main.py) (FastAPI app), [`ui/src/App.jsx`](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/App.jsx) (App shell), [`ui/src/api.js`](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/api.js) (API client), [`backend/services/trader_service.py`](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/trader_service.py) (Order execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard UI"]
  node_app["App shell<br/>[App.jsx]"]
  node_authctx["Auth context<br/>[AuthContext.jsx]"]
  node_apiclient["API client<br/>[api.js]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_tradingui["Trading view<br/>[Trading.jsx]"]
  node_automationui["Automation view<br/>[Automation.jsx]"]
  node_assistantui["AI assistant<br/>[Assistant.jsx]"]
  node_settingsui["Settings<br/>[Settings.jsx]"]
end

subgraph group_api["HTTP API"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_authapi["Auth routes<br/>[auth.py]"]
  node_marketapi["Market routes<br/>[market.py]"]
  node_tradingapi["Trading routes<br/>[trading.py]"]
  node_accountapi["Account routes<br/>[account.py]"]
  node_automationapi["Automation routes<br/>[automation.py]"]
  node_pollerapi["Poller routes<br/>[poller.py]"]
  node_chatapi["Chat routes<br/>[chat.py]"]
end

subgraph group_trading["Trading services"]
  node_exchange["Exchange client<br/>[exchange_client.py]"]
  node_strategy["EMA RSI strategy"]
  node_trader["Order execution<br/>[trader_service.py]"]
  node_poller["Background poller<br/>[poller.py]"]
end

subgraph group_identity["Identity and state"]
  node_authservice["Auth service<br/>[auth_service.py]"]
  node_db[("SQLite database<br/>[db.py]")]
end

node_browser(("User browser"))
node_binance["Binance Testnet"]
node_gemini["Google Gemini"]

node_browser -->|"uses"| node_app
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_tradingui
node_app -->|"renders"| node_automationui
node_app -->|"renders"| node_assistantui
node_app -->|"renders"| node_settingsui
node_app -->|"reads session"| node_authctx
node_authctx -->|"calls auth"| node_apiclient
node_dashboard -->|"requests data"| node_apiclient
node_tradingui -->|"requests trades"| node_apiclient
node_automationui -->|"requests automation"| node_apiclient
node_assistantui -->|"sends questions"| node_apiclient
node_settingsui -->|"manages settings"| node_apiclient
node_apiclient -->|"HTTP requests"| node_fastapi
node_fastapi -->|"routes to"| node_authapi
node_fastapi -->|"routes to"| node_marketapi
node_fastapi -->|"routes to"| node_tradingapi
node_fastapi -->|"routes to"| node_accountapi
node_fastapi -->|"routes to"| node_automationapi
node_fastapi -->|"routes to"| node_pollerapi
node_fastapi -->|"routes to"| node_chatapi
node_fastapi -->|"initializes"| node_db
node_authapi -->|"uses"| node_authservice
node_authapi -->|"reads and writes"| node_db
node_authservice -->|"queries users"| node_db
node_marketapi -->|"fetches market data"| node_exchange
node_marketapi -->|"gets signal"| node_strategy
node_tradingapi -->|"runs trades"| node_trader
node_tradingapi -->|"gets signal"| node_strategy
node_trader -->|"fetches and orders"| node_exchange
node_trader -->|"calculates signal"| node_strategy
node_trader -->|"saves trades"| node_db
node_accountapi -->|"manages account"| node_exchange
node_automationapi -->|"scans signals"| node_strategy
node_automationapi -->|"executes automation"| node_trader
node_pollerapi -->|"controls"| node_poller
node_poller -->|"fetches klines"| node_exchange
node_poller -->|"checks signals"| node_strategy
node_chatapi -->|"generates answers"| node_gemini
node_automationapi -.->|"requests AI analysis"| node_gemini
node_exchange -->|"calls API"| node_binance

click node_app "https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/App.jsx"
click node_authctx "https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/context/AuthContext.jsx"
click node_apiclient "https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/api.js"
click node_dashboard "https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Dashboard.jsx"
click node_tradingui "https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Trading.jsx"
click node_automationui "https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Automation.jsx"
click node_assistantui "https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Assistant.jsx"
click node_settingsui "https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Settings.jsx"
click node_fastapi "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/main.py"
click node_authapi "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/auth.py"
click node_marketapi "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/market.py"
click node_tradingapi "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/trading.py"
click node_accountapi "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/account.py"
click node_automationapi "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/automation.py"
click node_pollerapi "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/poller.py"
click node_chatapi "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/chat.py"
click node_exchange "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/exchange_client.py"
click node_strategy "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/strategy_service.py"
click node_trader "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/trader_service.py"
click node_poller "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/poller.py"
click node_authservice "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/auth_service.py"
click node_db "https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/models/db.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_app,node_authctx,node_apiclient,node_dashboard,node_tradingui,node_automationui,node_assistantui,node_settingsui,node_browser toneBlue
class node_fastapi,node_authapi,node_marketapi,node_tradingapi,node_accountapi,node_automationapi,node_pollerapi,node_chatapi toneAmber
class node_exchange,node_strategy,node_trader,node_poller toneMint
class node_authservice,node_db toneRose
class node_binance,node_gemini toneIndigo
```

## Components

### Dashboard UI

- [App shell](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/App.jsx): `ui/src/App.jsx`
- [Auth context](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/context/AuthContext.jsx): `ui/src/context/AuthContext.jsx`
- [API client](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/api.js): `ui/src/api.js`
- [Dashboard](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Dashboard.jsx): `ui/src/components/Dashboard.jsx`
- [Trading view](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Trading.jsx): `ui/src/components/Trading.jsx`
- [Automation view](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Automation.jsx): `ui/src/components/Automation.jsx`
- [AI assistant](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Assistant.jsx): `ui/src/components/Assistant.jsx`
- [Settings](https://github.com/j-sravani15/crypto-trading-system/blob/main/ui/src/components/Settings.jsx): `ui/src/components/Settings.jsx`

### HTTP API

- [FastAPI app](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/main.py): `backend/main.py`
- [Auth routes](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/auth.py): `backend/api/auth.py`
- [Market routes](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/market.py): `backend/api/market.py`
- [Trading routes](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/trading.py): `backend/api/trading.py`
- [Account routes](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/account.py): `backend/api/account.py`
- [Automation routes](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/automation.py): `backend/api/automation.py`
- [Poller routes](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/poller.py): `backend/api/poller.py`
- [Chat routes](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/api/chat.py): `backend/api/chat.py`

### Trading services

- [Exchange client](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/exchange_client.py): `backend/services/exchange_client.py`
- [EMA RSI strategy](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/strategy_service.py): `backend/services/strategy_service.py`
- [Order execution](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/trader_service.py): `backend/services/trader_service.py`
- [Background poller](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/poller.py): `backend/services/poller.py`

### Identity and state

- [Auth service](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/services/auth_service.py): `backend/services/auth_service.py`
- [SQLite database](https://github.com/j-sravani15/crypto-trading-system/blob/main/backend/models/db.py): `backend/models/db.py`

### Other components

- **User browser**
- **Binance Testnet**
- **Google Gemini**

## Connections

- User browser → App shell: uses
- App shell → Dashboard: renders (evidence: `ui/src/App.jsx`)
- App shell → Trading view: renders (evidence: `ui/src/App.jsx`)
- App shell → Automation view: renders (evidence: `ui/src/App.jsx`)
- App shell → AI assistant: renders (evidence: `ui/src/App.jsx`)
- App shell → Settings: renders (evidence: `ui/src/App.jsx`)
- App shell → Auth context: reads session (evidence: `ui/src/App.jsx`)
- Auth context → API client: calls auth (evidence: `ui/src/context/AuthContext.jsx`)
- Dashboard → API client: requests data (evidence: `ui/src/components/Dashboard.jsx`)
- Trading view → API client: requests trades (evidence: `ui/src/components/Trading.jsx`)
- Automation view → API client: requests automation (evidence: `ui/src/components/Automation.jsx`)
- AI assistant → API client: sends questions (evidence: `ui/src/components/Assistant.jsx`)
- Settings → API client: manages settings (evidence: `ui/src/components/Settings.jsx`)
- API client → FastAPI app: HTTP requests
- FastAPI app → Auth routes: routes to (evidence: `backend/main.py`)
- FastAPI app → Market routes: routes to (evidence: `backend/main.py`)
- FastAPI app → Trading routes: routes to (evidence: `backend/main.py`)
- FastAPI app → Account routes: routes to (evidence: `backend/main.py`)
- FastAPI app → Automation routes: routes to (evidence: `backend/main.py`)
- FastAPI app → Poller routes: routes to (evidence: `backend/main.py`)
- FastAPI app → Chat routes: routes to (evidence: `backend/main.py`)
- FastAPI app → SQLite database: initializes (evidence: `backend/main.py`)
- Auth routes → Auth service: uses (evidence: `backend/api/auth.py`)
- Auth routes → SQLite database: reads and writes (evidence: `backend/api/auth.py`)
- Auth service → SQLite database: queries users (evidence: `backend/services/auth_service.py`)
- Market routes → Exchange client: fetches market data
- Market routes → EMA RSI strategy: gets signal (evidence: `backend/api/market.py`)
- Trading routes → Order execution: runs trades (evidence: `backend/api/trading.py`)
- Trading routes → EMA RSI strategy: gets signal (evidence: `backend/api/trading.py`)
- Order execution → Exchange client: fetches and orders (evidence: `backend/services/trader_service.py`)
- Order execution → EMA RSI strategy: calculates signal (evidence: `backend/services/trader_service.py`)
- Order execution → SQLite database: saves trades (evidence: `backend/services/trader_service.py`)
- Account routes → Exchange client: manages account
- Automation routes → EMA RSI strategy: scans signals (evidence: `backend/api/automation.py`)
- Automation routes → Order execution: executes automation (evidence: `backend/api/automation.py`)
- Poller routes → Background poller: controls
- Background poller → Exchange client: fetches klines
- Background poller → EMA RSI strategy: checks signals (evidence: `backend/services/poller.py`)
- Chat routes → Google Gemini: generates answers
- Automation routes → Google Gemini: requests AI analysis
- Exchange client → Binance Testnet: calls API
