# suriyanandhimalai555-prog/dex_bot architecture

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

- Interactive diagram: https://gitdiagram.com/suriyanandhimalai555-prog/dex_bot
- Repository: https://github.com/suriyanandhimalai555-prog/dex_bot

## Overview

DEX Bot Platform lets traders manage encrypted wallets and wallet groups, configure bots, and run scheduled BSC trades; admins manage traders, audit activity, and approve trade-limit increases. The workflow runs from the React panels through the Express API, bot scheduling and Redis-backed workers to DEX execution, with transaction updates streamed back to the UI. The README documents the major capabilities and deployment roles; several controller, worker, and integration internals are unsampled, so their links are limited to documented relationships.

Main entry points: [`backend/src/index.ts`](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/index.ts) (Express API), [`backend/src/workers/execution.worker.ts`](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/workers/execution.worker.ts) (Execution Worker), [`backend/src/controllers/bot.controller.ts`](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/bot.controller.ts) (Bot Controls), [`frontend/src/App.tsx`](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/frontend/src/App.tsx) (App Routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Trader and Admin UI"]
  node_panels["Role Panels"]
  node_app_routes["App Routing<br/>[App.tsx]"]
  node_api_client["API Client<br/>[client.ts]"]
  node_live_ui["Live Transaction UI<br/>[useSocket.ts]"]
end

subgraph group_api["API and Accounts"]
  node_api_server["Express API<br/>[index.ts]"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_wallets["Wallet Management"]
end

subgraph group_trading["Bot Trading"]
  node_bot_api["Bot Controls<br/>[bot.controller.ts]"]
  node_scheduler["Bot Scheduler"]
end

subgraph group_operations["Limits and Insights"]
  node_limit_requests["Trade Limit Requests"]
  node_admin_limits["Admin Limit Review"]
  node_analytics["Analytics and Audit"]
  node_bnb_price["BNB Price Service"]
end

subgraph group_runtime["Execution Runtime"]
  node_execution_queue["Execution Queue<br/>[queues.ts]"]
  node_execution_worker["Execution Worker"]
  node_executor["Trade Executor"]
  node_tx_stream["Transaction Stream<br/>[txStream.ts]"]
end

node_trader(("Trader"))
node_admin(("Admin"))
node_bsc_dex{{"BSC DEX"}}
node_postgres[("PostgreSQL")]
node_redis[("Redis")]
node_telegram{{"Telegram"}}

node_trader -->|"uses panels"| node_app_routes
node_admin -->|"uses panels"| node_app_routes
node_app_routes -->|"routes to"| node_panels
node_panels -.->|"requests data"| node_api_client
node_api_client -->|"calls API"| node_api_server
node_api_server -->|"routes auth"| node_auth
node_api_server -->|"routes bots"| node_bot_api
node_api_server -->|"routes wallets"| node_wallets
node_api_server -->|"routes requests"| node_limit_requests
node_api_server -->|"routes admin"| node_admin_limits
node_bot_api -->|"schedules runs"| node_scheduler
node_scheduler -.->|"queues jobs"| node_execution_queue
node_execution_worker -->|"consumes jobs"| node_execution_queue
node_execution_worker -->|"runs trades"| node_executor
node_executor -->|"executes swaps"| node_bsc_dex
node_bot_api -->|"stores bots"| node_postgres
node_execution_worker -->|"connects queue"| node_redis
node_execution_worker -->|"emits updates"| node_tx_stream
node_tx_stream -.->|"streams events"| node_live_ui
node_limit_requests -.->|"submits for review"| node_admin_limits
node_admin_limits -->|"converts limits"| node_bnb_price
node_analytics -.->|"reads metrics"| node_postgres
node_bot_api -->|"sends alerts"| node_telegram
node_auth -->|"stores accounts"| node_postgres

click node_panels "https://github.com/suriyanandhimalai555-prog/dex_bot/tree/main/frontend/src/pages"
click node_app_routes "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/frontend/src/api/client.ts"
click node_live_ui "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/frontend/src/hooks/useSocket.ts"
click node_api_server "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/index.ts"
click node_auth "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/services/auth.service.ts"
click node_wallets "https://github.com/suriyanandhimalai555-prog/dex_bot/tree/main/backend/src/controllers"
click node_bot_api "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/bot.controller.ts"
click node_scheduler "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/services/scheduler.service.ts"
click node_execution_queue "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/config/queues.ts"
click node_execution_worker "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/workers/execution.worker.ts"
click node_executor "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/services/executor.service.ts"
click node_tx_stream "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/socket/txStream.ts"
click node_limit_requests "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/trader/limitRequests.controller.ts"
click node_admin_limits "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/admin/limitRequests.controller.ts"
click node_analytics "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/analytics.controller.ts"
click node_bnb_price "https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/services/bnbPrice.service.ts"

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_panels,node_app_routes,node_api_client,node_live_ui toneBlue
class node_api_server,node_auth,node_wallets,node_postgres,node_redis toneAmber
class node_bot_api,node_scheduler toneMint
class node_limit_requests,node_admin_limits,node_analytics,node_bnb_price toneRose
class node_execution_queue,node_execution_worker,node_executor,node_tx_stream,node_trader,node_admin,node_bsc_dex,node_telegram toneIndigo
```

## Components

### Trader and Admin UI

- [Role Panels](https://github.com/suriyanandhimalai555-prog/dex_bot/tree/main/frontend/src/pages): `frontend/src/pages`
- [App Routing](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API Client](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Live Transaction UI](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/frontend/src/hooks/useSocket.ts): `frontend/src/hooks/useSocket.ts`

### API and Accounts

- [Express API](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/index.ts): `backend/src/index.ts`
- [Authentication](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/services/auth.service.ts): `backend/src/services/auth.service.ts`
- [Wallet Management](https://github.com/suriyanandhimalai555-prog/dex_bot/tree/main/backend/src/controllers): `backend/src/controllers`

### Bot Trading

- [Bot Controls](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/bot.controller.ts): `backend/src/controllers/bot.controller.ts`
- [Bot Scheduler](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/services/scheduler.service.ts): `backend/src/services/scheduler.service.ts`

### Limits and Insights

- [Trade Limit Requests](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/trader/limitRequests.controller.ts): `backend/src/controllers/trader/limitRequests.controller.ts`
- [Admin Limit Review](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/admin/limitRequests.controller.ts): `backend/src/controllers/admin/limitRequests.controller.ts`
- [Analytics and Audit](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/controllers/analytics.controller.ts): `backend/src/controllers/analytics.controller.ts`
- [BNB Price Service](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/services/bnbPrice.service.ts): `backend/src/services/bnbPrice.service.ts`

### Execution Runtime

- [Execution Queue](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/config/queues.ts): `backend/src/config/queues.ts`
- [Execution Worker](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/workers/execution.worker.ts): `backend/src/workers/execution.worker.ts`
- [Trade Executor](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/services/executor.service.ts): `backend/src/services/executor.service.ts`
- [Transaction Stream](https://github.com/suriyanandhimalai555-prog/dex_bot/blob/main/backend/src/socket/txStream.ts): `backend/src/socket/txStream.ts`

### Other components

- **Trader**
- **Admin**
- **BSC DEX**
- **PostgreSQL**
- **Redis**
- **Telegram**

## Connections

- Trader → App Routing: uses panels (evidence: `README.md`)
- Admin → App Routing: uses panels (evidence: `README.md`)
- App Routing → Role Panels: routes to (evidence: `frontend/src/App.tsx`)
- Role Panels → API Client: requests data
- API Client → Express API: calls API (evidence: `README.md`)
- Express API → Authentication: routes auth (evidence: `backend/src/index.ts`)
- Express API → Bot Controls: routes bots (evidence: `backend/src/index.ts`)
- Express API → Wallet Management: routes wallets (evidence: `backend/src/index.ts`)
- Express API → Trade Limit Requests: routes requests (evidence: `backend/src/index.ts`)
- Express API → Admin Limit Review: routes admin (evidence: `backend/src/index.ts`)
- Bot Controls → Bot Scheduler: schedules runs (evidence: `backend/src/controllers/bot.controller.ts`)
- Bot Scheduler → Execution Queue: queues jobs
- Execution Worker → Execution Queue: consumes jobs (evidence: `README.md`)
- Execution Worker → Trade Executor: runs trades (evidence: `backend/src/workers/execution.worker.ts`)
- Trade Executor → BSC DEX: executes swaps (evidence: `README.md`)
- Bot Controls → PostgreSQL: stores bots (evidence: `backend/src/controllers/bot.controller.ts`)
- Execution Worker → Redis: connects queue (evidence: `backend/src/workers/execution.worker.ts`)
- Execution Worker → Transaction Stream: emits updates (evidence: `backend/src/workers/execution.worker.ts`)
- Transaction Stream → Live Transaction UI: streams events
- Trade Limit Requests → Admin Limit Review: submits for review
- Admin Limit Review → BNB Price Service: converts limits (evidence: `backend/src/controllers/admin/limitRequests.controller.ts`)
- Analytics and Audit → PostgreSQL: reads metrics
- Bot Controls → Telegram: sends alerts (evidence: `backend/src/controllers/bot.controller.ts`)
- Authentication → PostgreSQL: stores accounts (evidence: `backend/src/services/auth.service.ts`)
