# nofxaios/nofx architecture

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

- Interactive diagram: https://gitdiagram.com/nofxaios/nofx
- Repository: https://github.com/nofxaios/nofx

## Overview

NOFX is a self-hosted AI trading application with two distinct trading modes: Frontier guides a user through market selection, entry-plan review, and explicitly approved execution; Autopilot continuously evaluates markets and can execute while running. The repository also includes account/model setup, trader dashboards, strategy configuration, market-data access, and exchange integrations. The README documents the product workflows; sampled source confirms frontend routing and terminal composition, but many backend relationships are not excerpted, so those links are marked unverified rather than presented as observed calls.

Main entry points: [`web/src/router/AppRoutes.tsx`](https://github.com/nofxaios/nofx/blob/dev/web/src/router/AppRoutes.tsx) (App Routes), [`api/handler_planning.go`](https://github.com/nofxaios/nofx/blob/dev/api/handler_planning.go) (Planning API), [`trader/auto_trader_loop.go`](https://github.com/nofxaios/nofx/blob/dev/trader/auto_trader_loop.go) (Autopilot Loop), [`web/src/components/trader/AITradersPage.tsx`](https://github.com/nofxaios/nofx/blob/dev/web/src/components/trader/AITradersPage.tsx) (Trader Workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Workspace UI"]
  node_routes["App Routes<br/>[AppRoutes.tsx]"]
  node_auth["Account and Setup<br/>[AuthContext.tsx]"]
  node_trader_ui["Trader Workspace<br/>[AITradersPage.tsx]"]
  node_terminal["Trader Dashboard"]
  node_api_client["Web API Client<br/>[index.ts]"]
end

subgraph group_frontier["Frontier Planning"]
  node_planning_ui["Frontier Workspace"]
  node_planning_api["Planning API"]
  node_planning_core["Plan Engine<br/>[plan.go]"]
  node_planning_live["Live Execution<br/>[controller.go]"]
  node_planning_market["Planning Markets<br/>[client.go]"]
end

subgraph group_autopilot["Autopilot Trading"]
  node_trader_config["Trader Configuration"]
  node_manager["Trader Manager<br/>[trader_manager.go]"]
  node_autopilot_loop["Autopilot Loop"]
  node_decision_engine["AI Decisions<br/>[engine.go]"]
  node_prompts["Prompt Builder<br/>[engine_prompt.go]"]
end

subgraph group_runtime["Trading Runtime"]
  node_exchange_runtime["Exchange Adapters<br/>[interface.go]"]
  node_exchange_accounts["Exchange Adapters<br/>[futures_orders.go]"]
  node_api_server["HTTP API<br/>[server.go]"]
  node_mcp["Model Integrations<br/>[client.go]"]
end

subgraph group_data["Data and Persistence"]
  node_market_data["Market Data<br/>[api_client.go]"]
  node_store[("Application Store<br/>[store.go]")]
  node_market_providers["Market Providers<br/>[kline.go]"]
end

node_user(("User"))

node_user -->|"uses workspace"| node_routes
node_routes -->|"checks session"| node_auth
node_routes -->|"opens Frontier"| node_planning_ui
node_routes -->|"opens Autopilot"| node_trader_ui
node_trader_ui -->|"selects trader"| node_terminal
node_planning_ui -.->|"requests plans"| node_api_client
node_api_client -.->|"sends API requests"| node_api_server
node_api_server -.->|"routes planning"| node_planning_api
node_planning_api -.->|"loads market data"| node_planning_market
node_planning_api -.->|"generates plans"| node_planning_core
node_user -->|"reviews and approves"| node_planning_ui
node_planning_api -.->|"executes approved trade"| node_planning_live
node_planning_live -.->|"submits orders"| node_exchange_runtime
node_trader_ui -.->|"configures trader"| node_trader_config
node_trader_config -.->|"starts or stops"| node_manager
node_manager -.->|"runs trader"| node_autopilot_loop
node_autopilot_loop -.->|"reads market"| node_market_data
node_autopilot_loop -.->|"requests decision"| node_decision_engine
node_decision_engine -.->|"builds model context"| node_prompts
node_decision_engine -.->|"requests model"| node_mcp
node_autopilot_loop -->|"routes orders"| node_exchange_runtime
node_exchange_runtime -.->|"dispatches venue orders"| node_exchange_accounts
node_api_server -.->|"persists application state"| node_store
node_market_data -.->|"fetches provider data"| node_market_providers
node_terminal -->|"loads dashboard data"| node_api_client

click node_routes "https://github.com/nofxaios/nofx/blob/dev/web/src/router/AppRoutes.tsx"
click node_auth "https://github.com/nofxaios/nofx/blob/dev/web/src/contexts/AuthContext.tsx"
click node_trader_ui "https://github.com/nofxaios/nofx/blob/dev/web/src/components/trader/AITradersPage.tsx"
click node_terminal "https://github.com/nofxaios/nofx/blob/dev/web/src/components/terminal/TerminalDashboard.tsx"
click node_api_client "https://github.com/nofxaios/nofx/blob/dev/web/src/lib/api/index.ts"
click node_planning_ui "https://github.com/nofxaios/nofx/blob/dev/web/src/pages/TradingPlanningPage.tsx"
click node_planning_api "https://github.com/nofxaios/nofx/blob/dev/api/handler_planning.go"
click node_planning_core "https://github.com/nofxaios/nofx/blob/dev/planning/core/plan.go"
click node_planning_live "https://github.com/nofxaios/nofx/blob/dev/planning/live/controller.go"
click node_planning_market "https://github.com/nofxaios/nofx/blob/dev/planning/market/client.go"
click node_trader_config "https://github.com/nofxaios/nofx/blob/dev/api/handler_trader_config.go"
click node_manager "https://github.com/nofxaios/nofx/blob/dev/manager/trader_manager.go"
click node_autopilot_loop "https://github.com/nofxaios/nofx/blob/dev/trader/auto_trader_loop.go"
click node_decision_engine "https://github.com/nofxaios/nofx/blob/dev/kernel/engine.go"
click node_prompts "https://github.com/nofxaios/nofx/blob/dev/kernel/engine_prompt.go"
click node_market_data "https://github.com/nofxaios/nofx/blob/dev/market/api_client.go"
click node_exchange_runtime "https://github.com/nofxaios/nofx/blob/dev/trader/interface.go"
click node_exchange_accounts "https://github.com/nofxaios/nofx/blob/dev/trader/binance/futures_orders.go"
click node_api_server "https://github.com/nofxaios/nofx/blob/dev/api/server.go"
click node_store "https://github.com/nofxaios/nofx/blob/dev/store/store.go"
click node_market_providers "https://github.com/nofxaios/nofx/blob/dev/provider/coinank/kline.go"
click node_mcp "https://github.com/nofxaios/nofx/blob/dev/mcp/client.go"

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_routes,node_auth,node_trader_ui,node_terminal,node_api_client,node_user toneBlue
class node_planning_ui,node_planning_api,node_planning_core,node_planning_live,node_planning_market toneAmber
class node_trader_config,node_manager,node_autopilot_loop,node_decision_engine,node_prompts toneMint
class node_exchange_runtime,node_exchange_accounts,node_api_server,node_mcp toneRose
class node_market_data,node_store,node_market_providers toneIndigo
```

## Components

### Workspace UI

- [App Routes](https://github.com/nofxaios/nofx/blob/dev/web/src/router/AppRoutes.tsx): `web/src/router/AppRoutes.tsx`
- [Account and Setup](https://github.com/nofxaios/nofx/blob/dev/web/src/contexts/AuthContext.tsx): `web/src/contexts/AuthContext.tsx`
- [Trader Workspace](https://github.com/nofxaios/nofx/blob/dev/web/src/components/trader/AITradersPage.tsx): `web/src/components/trader/AITradersPage.tsx`
- [Trader Dashboard](https://github.com/nofxaios/nofx/blob/dev/web/src/components/terminal/TerminalDashboard.tsx): `web/src/components/terminal/TerminalDashboard.tsx`
- [Web API Client](https://github.com/nofxaios/nofx/blob/dev/web/src/lib/api/index.ts): `web/src/lib/api/index.ts`

### Frontier Planning

- [Frontier Workspace](https://github.com/nofxaios/nofx/blob/dev/web/src/pages/TradingPlanningPage.tsx): `web/src/pages/TradingPlanningPage.tsx`
- [Planning API](https://github.com/nofxaios/nofx/blob/dev/api/handler_planning.go): `api/handler_planning.go`
- [Plan Engine](https://github.com/nofxaios/nofx/blob/dev/planning/core/plan.go): `planning/core/plan.go`
- [Live Execution](https://github.com/nofxaios/nofx/blob/dev/planning/live/controller.go): `planning/live/controller.go`
- [Planning Markets](https://github.com/nofxaios/nofx/blob/dev/planning/market/client.go): `planning/market/client.go`

### Autopilot Trading

- [Trader Configuration](https://github.com/nofxaios/nofx/blob/dev/api/handler_trader_config.go): `api/handler_trader_config.go`
- [Trader Manager](https://github.com/nofxaios/nofx/blob/dev/manager/trader_manager.go): `manager/trader_manager.go`
- [Autopilot Loop](https://github.com/nofxaios/nofx/blob/dev/trader/auto_trader_loop.go): `trader/auto_trader_loop.go`
- [AI Decisions](https://github.com/nofxaios/nofx/blob/dev/kernel/engine.go): `kernel/engine.go`
- [Prompt Builder](https://github.com/nofxaios/nofx/blob/dev/kernel/engine_prompt.go): `kernel/engine_prompt.go`

### Trading Runtime

- [Exchange Adapters](https://github.com/nofxaios/nofx/blob/dev/trader/interface.go): `trader/interface.go`
- [Exchange Adapters](https://github.com/nofxaios/nofx/blob/dev/trader/binance/futures_orders.go): `trader/binance/futures_orders.go`
- [HTTP API](https://github.com/nofxaios/nofx/blob/dev/api/server.go): `api/server.go`
- [Model Integrations](https://github.com/nofxaios/nofx/blob/dev/mcp/client.go): `mcp/client.go`

### Data and Persistence

- [Market Data](https://github.com/nofxaios/nofx/blob/dev/market/api_client.go): `market/api_client.go`
- [Application Store](https://github.com/nofxaios/nofx/blob/dev/store/store.go): `store/store.go`
- [Market Providers](https://github.com/nofxaios/nofx/blob/dev/provider/coinank/kline.go): `provider/coinank/kline.go`

### Other components

- **User**

## Connections

- User → App Routes: uses workspace (evidence: `README.md`)
- App Routes → Account and Setup: checks session (evidence: `web/src/router/AppRoutes.tsx`)
- App Routes → Frontier Workspace: opens Frontier (evidence: `web/src/router/AppRoutes.tsx`)
- App Routes → Trader Workspace: opens Autopilot (evidence: `web/src/router/AppRoutes.tsx`)
- Trader Workspace → Trader Dashboard: selects trader (evidence: `web/src/components/trader/AITradersPage.tsx`)
- Frontier Workspace → Web API Client: requests plans
- Web API Client → HTTP API: sends API requests
- HTTP API → Planning API: routes planning
- Planning API → Planning Markets: loads market data
- Planning API → Plan Engine: generates plans
- User → Frontier Workspace: reviews and approves (evidence: `README.md`)
- Planning API → Live Execution: executes approved trade
- Live Execution → Exchange Adapters: submits orders
- Trader Workspace → Trader Configuration: configures trader
- Trader Configuration → Trader Manager: starts or stops
- Trader Manager → Autopilot Loop: runs trader
- Autopilot Loop → Market Data: reads market
- Autopilot Loop → AI Decisions: requests decision
- AI Decisions → Prompt Builder: builds model context
- AI Decisions → Model Integrations: requests model
- Autopilot Loop → Exchange Adapters: routes orders (evidence: `README.md`)
- Exchange Adapters → Exchange Adapters: dispatches venue orders
- HTTP API → Application Store: persists application state
- Market Data → Market Providers: fetches provider data
- Trader Dashboard → Web API Client: loads dashboard data (evidence: `web/src/components/terminal/TerminalDashboard.tsx`)
