# ajokhai/exness_trading_bot architecture

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

- Interactive diagram: https://gitdiagram.com/ajokhai/exness_trading_bot
- Repository: https://github.com/ajokhai/exness_trading_bot

## Overview

Exness AI Autonomous Trading Agent is a browser-based MT5 trading interface. Users complete onboarding and connect MetaApi, configure markets and risk, then activate a recurring agent cycle: it checks account limits and spreads, gathers candles, computes indicators, requests parallel AI signals, aggregates them, and places qualifying trades. Dashboard panels expose positions, logs, settings, and emergency controls. The graph preserves these documented capabilities; several links are supported by the SOURCE INDEX or README rather than inspected implementation excerpts, so unsampled internals are not detailed.

Main entry points: [`src/services/agent/loop.ts`](https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/agent/loop.ts) (Agent Cycle), [`src/services/exness/metaapi.ts`](https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/exness/metaapi.ts) (MetaApi Bridge), [`src/components/dashboard/Dashboard.tsx`](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/Dashboard.tsx) (Trading Dashboard), [`src/store/agentStore.ts`](https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/agentStore.ts) (Agent State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Setup and Dashboard"]
  node_app["Application Gate<br/>[App.tsx]"]
  node_wizard["Onboarding Wizard"]
  node_dashboard["Trading Dashboard<br/>[Dashboard.tsx]"]
  node_settingsui["Agent Settings<br/>[SettingsPanel.tsx]"]
  node_brainfeed["Decision Feed<br/>[BrainFeed.tsx]"]
  node_header["Agent Header<br/>[Header.tsx]"]
  node_instruments["Instrument Grid<br/>[InstrumentGrid.tsx]"]
  node_instrumentcard["Instrument Card<br/>[InstrumentCard.tsx]"]
  node_positionsui["Positions Table<br/>[PositionsTable.tsx]"]
  node_panic["Panic Controls<br/>[PanicSuite.tsx]"]
end

subgraph group_agent["Agent Workflow"]
  node_loop["Agent Cycle<br/>[loop.ts]"]
  node_indicators["Market Indicators<br/>[indicators.ts]"]
  node_riskcalc["Trade Sizing<br/>[riskCalc.ts]"]
end

subgraph group_ai["AI Analysis"]
  node_engine["AI Orchestrator<br/>[engine.ts]"]
  node_prompts["Market Prompts<br/>[prompts.ts]"]
  node_aggregator["Signal Consensus<br/>[aggregator.ts]"]
  node_signaltype["Signal Context Types<br/>[signal.ts]"]
  node_models["AI Model Adapters"]
end

subgraph group_broker["Broker Integration"]
  node_metaapi["MetaApi Bridge<br/>[metaapi.ts]"]
  node_liquidation["Liquidation Utility<br/>[liquidation.ts]"]
end

subgraph group_state["State and Risk"]
  node_agentstate["Agent State<br/>[agentStore.ts]"]
  node_settingsstate["Trading Settings<br/>[settingsStore.ts]"]
  node_tradingstate[("Account and Positions<br/>[tradingStore.ts]")]
  node_credentials[("Credentials State")]
end

node_user(("Trader"))
node_broker["MetaApi Cloud / MT5"]

node_user -->|"opens"| node_app
node_app -->|"shows before setup"| node_wizard
node_app -->|"shows after setup"| node_dashboard
node_wizard -->|"initializes connection"| node_metaapi
node_dashboard -->|"renders"| node_settingsui
node_dashboard -->|"renders"| node_brainfeed
node_dashboard -->|"renders"| node_header
node_dashboard -->|"renders"| node_instruments
node_dashboard -->|"renders"| node_positionsui
node_dashboard -->|"renders"| node_panic
node_instruments -->|"renders"| node_instrumentcard
node_settingsui -->|"starts or stops"| node_loop
node_settingsui -->|"reads and updates"| node_settingsstate
node_settingsui -->|"reads and updates"| node_agentstate
node_brainfeed -->|"reads logs"| node_agentstate
node_header -->|"reads agent status"| node_agentstate
node_header -->|"reads account data"| node_tradingstate
node_positionsui -->|"reads positions"| node_tradingstate
node_panic -->|"cancels or closes"| node_metaapi
node_panic -->|"stops agent"| node_loop
node_loop -->|"reads configuration"| node_settingsstate
node_loop -->|"checks status and logs"| node_agentstate
node_loop -->|"reads account and positions"| node_tradingstate
node_loop -->|"fetches spread and candles"| node_metaapi
node_metaapi -.->|"streams and trades"| node_broker
node_metaapi -->|"updates quotes and account"| node_tradingstate
node_loop -->|"computes market context"| node_indicators
node_loop -->|"requests analysis"| node_engine
node_loop -->|"sizes qualifying trades"| node_riskcalc
node_loop -->|"places qualifying trade"| node_metaapi
node_engine -->|"builds model prompts"| node_prompts
node_engine -->|"queries parallel models"| node_models
node_engine -->|"aggregates responses"| node_aggregator
node_engine -->|"logs reasoning"| node_agentstate
node_prompts -->|"uses market context"| node_signaltype
node_aggregator -->|"uses signal types"| node_signaltype
node_models -.->|"reads API keys"| node_credentials
node_models -.->|"calls AI providers"| node_broker
node_wizard -->|"reads credentials"| node_credentials
node_metaapi -->|"logs connection status"| node_agentstate
node_liquidation -->|"closes positions"| node_metaapi
node_liquidation -->|"updates agent state"| node_agentstate

click node_app "https://github.com/ajokhai/exness_trading_bot/blob/main/src/App.tsx"
click node_wizard "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/wizard/OnboardingWizard.tsx"
click node_dashboard "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/Dashboard.tsx"
click node_settingsui "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/SettingsPanel.tsx"
click node_brainfeed "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/BrainFeed.tsx"
click node_header "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/Header.tsx"
click node_instruments "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/InstrumentGrid.tsx"
click node_instrumentcard "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/InstrumentCard.tsx"
click node_positionsui "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/PositionsTable.tsx"
click node_panic "https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/PanicSuite.tsx"
click node_loop "https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/agent/loop.ts"
click node_indicators "https://github.com/ajokhai/exness_trading_bot/blob/main/src/utils/indicators.ts"
click node_riskcalc "https://github.com/ajokhai/exness_trading_bot/blob/main/src/utils/riskCalc.ts"
click node_engine "https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/ai/engine.ts"
click node_prompts "https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/ai/prompts.ts"
click node_aggregator "https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/ai/aggregator.ts"
click node_signaltype "https://github.com/ajokhai/exness_trading_bot/blob/main/src/types/signal.ts"
click node_models "https://github.com/ajokhai/exness_trading_bot/tree/main/src/services/ai"
click node_metaapi "https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/exness/metaapi.ts"
click node_agentstate "https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/agentStore.ts"
click node_settingsstate "https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/settingsStore.ts"
click node_tradingstate "https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/tradingStore.ts"
click node_credentials "https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/credentialsStore.ts"
click node_liquidation "https://github.com/ajokhai/exness_trading_bot/blob/main/src/utils/liquidation.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_app,node_wizard,node_dashboard,node_settingsui,node_brainfeed,node_header,node_instruments,node_instrumentcard,node_positionsui,node_panic toneBlue
class node_loop,node_indicators,node_riskcalc toneAmber
class node_engine,node_prompts,node_aggregator,node_signaltype,node_models,node_broker toneMint
class node_metaapi,node_liquidation toneRose
class node_agentstate,node_settingsstate,node_tradingstate,node_credentials,node_user toneIndigo
```

## Components

### Setup and Dashboard

- [Application Gate](https://github.com/ajokhai/exness_trading_bot/blob/main/src/App.tsx): `src/App.tsx`
- [Onboarding Wizard](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/wizard/OnboardingWizard.tsx): `src/components/wizard/OnboardingWizard.tsx`
- [Trading Dashboard](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/Dashboard.tsx): `src/components/dashboard/Dashboard.tsx`
- [Agent Settings](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/SettingsPanel.tsx): `src/components/dashboard/SettingsPanel.tsx`
- [Decision Feed](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/BrainFeed.tsx): `src/components/dashboard/BrainFeed.tsx`
- [Agent Header](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/Header.tsx): `src/components/dashboard/Header.tsx`
- [Instrument Grid](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/InstrumentGrid.tsx): `src/components/dashboard/InstrumentGrid.tsx`
- [Instrument Card](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/InstrumentCard.tsx): `src/components/dashboard/InstrumentCard.tsx`
- [Positions Table](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/PositionsTable.tsx): `src/components/dashboard/PositionsTable.tsx`
- [Panic Controls](https://github.com/ajokhai/exness_trading_bot/blob/main/src/components/dashboard/PanicSuite.tsx): `src/components/dashboard/PanicSuite.tsx`

### Agent Workflow

- [Agent Cycle](https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/agent/loop.ts): `src/services/agent/loop.ts`
- [Market Indicators](https://github.com/ajokhai/exness_trading_bot/blob/main/src/utils/indicators.ts): `src/utils/indicators.ts`
- [Trade Sizing](https://github.com/ajokhai/exness_trading_bot/blob/main/src/utils/riskCalc.ts): `src/utils/riskCalc.ts`

### AI Analysis

- [AI Orchestrator](https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/ai/engine.ts): `src/services/ai/engine.ts`
- [Market Prompts](https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/ai/prompts.ts): `src/services/ai/prompts.ts`
- [Signal Consensus](https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/ai/aggregator.ts): `src/services/ai/aggregator.ts`
- [Signal Context Types](https://github.com/ajokhai/exness_trading_bot/blob/main/src/types/signal.ts): `src/types/signal.ts`
- [AI Model Adapters](https://github.com/ajokhai/exness_trading_bot/tree/main/src/services/ai): `src/services/ai`

### Broker Integration

- [MetaApi Bridge](https://github.com/ajokhai/exness_trading_bot/blob/main/src/services/exness/metaapi.ts): `src/services/exness/metaapi.ts`
- [Liquidation Utility](https://github.com/ajokhai/exness_trading_bot/blob/main/src/utils/liquidation.ts): `src/utils/liquidation.ts`

### State and Risk

- [Agent State](https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/agentStore.ts): `src/store/agentStore.ts`
- [Trading Settings](https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/settingsStore.ts): `src/store/settingsStore.ts`
- [Account and Positions](https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/tradingStore.ts): `src/store/tradingStore.ts`
- [Credentials State](https://github.com/ajokhai/exness_trading_bot/blob/main/src/store/credentialsStore.ts): `src/store/credentialsStore.ts`

### Other components

- **Trader**
- **MetaApi Cloud / MT5**

## Connections

- Trader → Application Gate: opens (evidence: `README.md`)
- Application Gate → Onboarding Wizard: shows before setup (evidence: `src/App.tsx`)
- Application Gate → Trading Dashboard: shows after setup (evidence: `src/App.tsx`)
- Onboarding Wizard → MetaApi Bridge: initializes connection (evidence: `src/components/wizard/OnboardingWizard.tsx`)
- Trading Dashboard → Agent Settings: renders (evidence: `src/components/dashboard/Dashboard.tsx`)
- Trading Dashboard → Decision Feed: renders (evidence: `src/components/dashboard/Dashboard.tsx`)
- Trading Dashboard → Agent Header: renders (evidence: `src/components/dashboard/Dashboard.tsx`)
- Trading Dashboard → Instrument Grid: renders (evidence: `src/components/dashboard/Dashboard.tsx`)
- Trading Dashboard → Positions Table: renders (evidence: `src/components/dashboard/Dashboard.tsx`)
- Trading Dashboard → Panic Controls: renders (evidence: `src/components/dashboard/Dashboard.tsx`)
- Instrument Grid → Instrument Card: renders (evidence: `src/components/dashboard/InstrumentGrid.tsx`)
- Agent Settings → Agent Cycle: starts or stops (evidence: `src/components/dashboard/SettingsPanel.tsx`)
- Agent Settings → Trading Settings: reads and updates (evidence: `src/components/dashboard/SettingsPanel.tsx`)
- Agent Settings → Agent State: reads and updates (evidence: `src/components/dashboard/SettingsPanel.tsx`)
- Decision Feed → Agent State: reads logs (evidence: `src/components/dashboard/BrainFeed.tsx`)
- Agent Header → Agent State: reads agent status (evidence: `src/components/dashboard/Header.tsx`)
- Agent Header → Account and Positions: reads account data (evidence: `src/components/dashboard/Header.tsx`)
- Positions Table → Account and Positions: reads positions (evidence: `src/components/dashboard/PositionsTable.tsx`)
- Panic Controls → MetaApi Bridge: cancels or closes (evidence: `src/components/dashboard/PanicSuite.tsx`)
- Panic Controls → Agent Cycle: stops agent (evidence: `src/components/dashboard/PanicSuite.tsx`)
- Agent Cycle → Trading Settings: reads configuration (evidence: `src/services/agent/loop.ts`)
- Agent Cycle → Agent State: checks status and logs (evidence: `src/services/agent/loop.ts`)
- Agent Cycle → Account and Positions: reads account and positions (evidence: `src/services/agent/loop.ts`)
- Agent Cycle → MetaApi Bridge: fetches spread and candles (evidence: `src/services/agent/loop.ts`)
- MetaApi Bridge → MetaApi Cloud / MT5: streams and trades (evidence: `README.md`)
- MetaApi Bridge → Account and Positions: updates quotes and account (evidence: `src/services/exness/metaapi.ts`)
- Agent Cycle → Market Indicators: computes market context (evidence: `src/services/agent/loop.ts`)
- Agent Cycle → AI Orchestrator: requests analysis (evidence: `src/services/agent/loop.ts`)
- Agent Cycle → Trade Sizing: sizes qualifying trades (evidence: `src/services/agent/loop.ts`)
- Agent Cycle → MetaApi Bridge: places qualifying trade (evidence: `src/services/agent/loop.ts`)
- AI Orchestrator → Market Prompts: builds model prompts (evidence: `src/services/ai/engine.ts`)
- AI Orchestrator → AI Model Adapters: queries parallel models (evidence: `src/services/ai/engine.ts`)
- AI Orchestrator → Signal Consensus: aggregates responses (evidence: `src/services/ai/engine.ts`)
- AI Orchestrator → Agent State: logs reasoning (evidence: `src/services/ai/engine.ts`)
- Market Prompts → Signal Context Types: uses market context (evidence: `src/services/ai/prompts.ts`)
- Signal Consensus → Signal Context Types: uses signal types (evidence: `src/services/ai/aggregator.ts`)
- AI Model Adapters → Credentials State: reads API keys (evidence: `README.md`)
- AI Model Adapters → MetaApi Cloud / MT5: calls AI providers (evidence: `README.md`)
- Onboarding Wizard → Credentials State: reads credentials (evidence: `src/components/wizard/OnboardingWizard.tsx`)
- MetaApi Bridge → Agent State: logs connection status (evidence: `src/services/exness/metaapi.ts`)
- Liquidation Utility → MetaApi Bridge: closes positions (evidence: `src/utils/liquidation.ts`)
- Liquidation Utility → Agent State: updates agent state (evidence: `src/utils/liquidation.ts`)
