# jason8745/llm-agent-trader architecture

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

- Interactive diagram: https://gitdiagram.com/jason8745/llm-agent-trader
- Repository: https://github.com/jason8745/llm-agent-trader

## Overview

LLM Agent Trader is a stock-backtesting dashboard: users configure and stream an LLM-driven backtest, then review its results and daily trading decisions and feedback. The documented runtime spans a Next.js interface, FastAPI endpoints, market-data and analysis services, a strategy and backtesting engine, and log-backed review APIs. Edges are limited to relationships shown in excerpts, SOURCE INDEX references, or the README; several frontend/API and unsampled implementation details are therefore not connected.

Main entry points: [`backend/app/llm/strategies/llm_strategy.py`](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/strategies/llm_strategy.py) (LLM Trading Strategy), [`backend/app/api/v1/router.py`](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/router.py) (API Router), [`backend/app/api/v1/endpoints/llm_stream.py`](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/endpoints/llm_stream.py) (Streaming Backtest API), [`backend/app/utils/backtest_logger.py`](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/backtest_logger.py) (Backtest Log Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_dashboard["Web Dashboard<br/>[page.tsx]"]
  node_stream_ui["Streaming Runner"]
  node_results_ui["Backtest Results"]
  node_day_ui["Daily Analysis<br/>[DayAnalysis.tsx]"]
  node_chart_ui["Backtest Charts<br/>[BacktestChart.tsx]"]
end

subgraph group_api["API"]
  node_api_app["FastAPI App<br/>[main.py]"]
  node_api_router["API Router<br/>[router.py]"]
  node_stream_api["Streaming Backtest API<br/>[llm_stream.py]"]
  node_analysis_api["Backtest Analysis API"]
  node_feedback_api["Daily Feedback API<br/>[daily_feedback.py]"]
end

subgraph group_trading["Backtesting"]
  node_market_data["Stock Data Service<br/>[stock_data.py]"]
  node_fetcher["Market Data Fetcher<br/>[fetcher.py]"]
  node_engine["Backtest Engine<br/>[engine.py]"]
  node_strategy["LLM Trading Strategy<br/>[llm_strategy.py]"]
  node_strategy_base["Strategy Interface<br/>[base.py]"]
end

subgraph group_analysis["Market Analysis"]
  node_indicators["Technical Indicators<br/>[indicators.py]"]
  node_technical["Technical Context"]
  node_trend["Trend Analysis<br/>[trend_analyzer.py]"]
  node_llm_client["LLM Client<br/>[client.py]"]
end

subgraph group_persistence["Review and Logs"]
  node_logger["Backtest Log Store<br/>[backtest_logger.py]"]
  node_log_db[("SQLite Logs")]
end

node_user(("Trader"))
node_llm_provider{{"LLM Provider"}}

node_user -->|"uses"| node_dashboard
node_dashboard -->|"accesses"| node_api_app
node_api_app -->|"mounts"| node_api_router
node_api_router -->|"routes"| node_stream_api
node_api_router -->|"routes"| node_analysis_api
node_api_router -->|"routes"| node_feedback_api
node_stream_api -->|"loads data"| node_market_data
node_stream_api -->|"initializes"| node_strategy
node_stream_api -->|"runs"| node_engine
node_engine -->|"fetches data"| node_fetcher
node_engine -->|"uses"| node_indicators
node_strategy -->|"implements"| node_strategy_base
node_strategy -->|"uses"| node_indicators
node_strategy -->|"analyzes context"| node_technical
node_strategy -->|"analyzes trends"| node_trend
node_strategy -->|"requests decisions"| node_llm_client
node_llm_client -.->|"calls"| node_llm_provider
node_analysis_api -->|"queries logs"| node_logger
node_feedback_api -->|"queries logs"| node_logger
node_strategy -->|"records decisions"| node_logger
node_logger -.->|"persists"| node_log_db
node_results_ui -->|"renders"| node_day_ui
node_stream_ui -.->|"displays results"| node_results_ui
node_results_ui -.->|"presents charts"| node_chart_ui

click node_dashboard "https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/app/page.tsx"
click node_stream_ui "https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/components/llm/StreamingLLMRunner.tsx"
click node_results_ui "https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/components/analysis/BacktestResultsWithAnalysis.tsx"
click node_day_ui "https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/components/analysis/DayAnalysis.tsx"
click node_chart_ui "https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/components/charts/BacktestChart.tsx"
click node_api_app "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/main.py"
click node_api_router "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/router.py"
click node_stream_api "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/endpoints/llm_stream.py"
click node_analysis_api "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/endpoints/backtest_analysis.py"
click node_feedback_api "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/endpoints/daily_feedback.py"
click node_market_data "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/stock_data.py"
click node_fetcher "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/fetcher.py"
click node_engine "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/backtesting/engine.py"
click node_strategy "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/strategies/llm_strategy.py"
click node_strategy_base "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/strategies/base.py"
click node_indicators "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/indicators.py"
click node_technical "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/analysis/enhanced_technical_analyzer.py"
click node_trend "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/analysis/trend_analyzer.py"
click node_llm_client "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/client.py"
click node_logger "https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/backtest_logger.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_dashboard,node_stream_ui,node_results_ui,node_day_ui,node_chart_ui toneBlue
class node_api_app,node_api_router,node_stream_api,node_analysis_api,node_feedback_api toneAmber
class node_market_data,node_fetcher,node_engine,node_strategy,node_strategy_base toneMint
class node_indicators,node_technical,node_trend,node_llm_client toneRose
class node_logger,node_log_db,node_user,node_llm_provider toneIndigo
```

## Components

### Dashboard

- [Web Dashboard](https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Streaming Runner](https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/components/llm/StreamingLLMRunner.tsx): `frontend/src/components/llm/StreamingLLMRunner.tsx`
- [Backtest Results](https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/components/analysis/BacktestResultsWithAnalysis.tsx): `frontend/src/components/analysis/BacktestResultsWithAnalysis.tsx`
- [Daily Analysis](https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/components/analysis/DayAnalysis.tsx): `frontend/src/components/analysis/DayAnalysis.tsx`
- [Backtest Charts](https://github.com/jason8745/llm-agent-trader/blob/master/frontend/src/components/charts/BacktestChart.tsx): `frontend/src/components/charts/BacktestChart.tsx`

### API

- [FastAPI App](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/main.py): `backend/app/main.py`
- [API Router](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Streaming Backtest API](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/endpoints/llm_stream.py): `backend/app/api/v1/endpoints/llm_stream.py`
- [Backtest Analysis API](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/endpoints/backtest_analysis.py): `backend/app/api/v1/endpoints/backtest_analysis.py`
- [Daily Feedback API](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/api/v1/endpoints/daily_feedback.py): `backend/app/api/v1/endpoints/daily_feedback.py`

### Backtesting

- [Stock Data Service](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/stock_data.py): `backend/app/utils/stock_data.py`
- [Market Data Fetcher](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/fetcher.py): `backend/app/utils/fetcher.py`
- [Backtest Engine](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/backtesting/engine.py): `backend/app/backtesting/engine.py`
- [LLM Trading Strategy](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/strategies/llm_strategy.py): `backend/app/llm/strategies/llm_strategy.py`
- [Strategy Interface](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/strategies/base.py): `backend/app/llm/strategies/base.py`

### Market Analysis

- [Technical Indicators](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/indicators.py): `backend/app/utils/indicators.py`
- [Technical Context](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/analysis/enhanced_technical_analyzer.py): `backend/app/llm/analysis/enhanced_technical_analyzer.py`
- [Trend Analysis](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/analysis/trend_analyzer.py): `backend/app/llm/analysis/trend_analyzer.py`
- [LLM Client](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/llm/client.py): `backend/app/llm/client.py`

### Review and Logs

- [Backtest Log Store](https://github.com/jason8745/llm-agent-trader/blob/master/backend/app/utils/backtest_logger.py): `backend/app/utils/backtest_logger.py`
- **SQLite Logs**

### Other components

- **Trader**
- **LLM Provider**

## Connections

- Trader → Web Dashboard: uses (evidence: `README.md`)
- Web Dashboard → FastAPI App: accesses (evidence: `README.md`)
- FastAPI App → API Router: mounts (evidence: `backend/app/main.py`)
- API Router → Streaming Backtest API: routes (evidence: `backend/app/api/v1/router.py`)
- API Router → Backtest Analysis API: routes (evidence: `backend/app/api/v1/router.py`)
- API Router → Daily Feedback API: routes (evidence: `backend/app/api/v1/router.py`)
- Streaming Backtest API → Stock Data Service: loads data (evidence: `backend/app/api/v1/endpoints/llm_stream.py`)
- Streaming Backtest API → LLM Trading Strategy: initializes (evidence: `backend/app/api/v1/endpoints/llm_stream.py`)
- Streaming Backtest API → Backtest Engine: runs (evidence: `backend/app/api/v1/endpoints/llm_stream.py`)
- Backtest Engine → Market Data Fetcher: fetches data (evidence: `backend/app/backtesting/engine.py`)
- Backtest Engine → Technical Indicators: uses (evidence: `backend/app/backtesting/engine.py`)
- LLM Trading Strategy → Strategy Interface: implements (evidence: `backend/app/llm/strategies/base.py`)
- LLM Trading Strategy → Technical Indicators: uses (evidence: `backend/app/llm/strategies/llm_strategy.py`)
- LLM Trading Strategy → Technical Context: analyzes context (evidence: `backend/app/llm/strategies/llm_strategy.py`)
- LLM Trading Strategy → Trend Analysis: analyzes trends (evidence: `backend/app/llm/strategies/llm_strategy.py`)
- LLM Trading Strategy → LLM Client: requests decisions (evidence: `backend/app/llm/strategies/llm_strategy.py`)
- LLM Client → LLM Provider: calls
- Backtest Analysis API → Backtest Log Store: queries logs (evidence: `backend/app/api/v1/endpoints/backtest_analysis.py`)
- Daily Feedback API → Backtest Log Store: queries logs (evidence: `backend/app/api/v1/endpoints/daily_feedback.py`)
- LLM Trading Strategy → Backtest Log Store: records decisions (evidence: `backend/app/llm/strategies/llm_strategy.py`)
- Backtest Log Store → SQLite Logs: persists (evidence: `README.md`)
- Backtest Results → Daily Analysis: renders (evidence: `frontend/src/components/analysis/BacktestResultsWithAnalysis.tsx`)
- Streaming Runner → Backtest Results: displays results
- Backtest Results → Backtest Charts: presents charts
