# shantocrockerie-cloud/trading-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/shantocrockerie-cloud/trading-assistant
- Repository: https://github.com/shantocrockerie-cloud/trading-assistant

## Overview

Trading Assistant is a browser-based market-research and paper-trading terminal, with a separate optional ticker/date research service. The main workflow loads live or simulated candles, displays market context, runs deterministic analysis, and lets users manage session-only paper trades. Optional AI analysis and the separate Python research panel are distinct paths. The graph follows the README and shown call sites; unsampled research-service internals and unshown AI wiring are not expanded.

Main entry points: [`src/routes/index.tsx`](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/index.tsx) (Terminal interface), [`src/lib/trading.ts`](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts) (Candle acquisition), [`src/routes/__root.tsx`](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/__root.tsx) (Root route and shell), [`src/components/ui`](https://github.com/shantocrockerie-cloud/trading-assistant/tree/main/src/components/ui) (Reusable UI components)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terminal["Browser Terminal"]
  node_terminal_ui["Terminal interface<br/>[index.tsx]"]
  node_candles["Candle acquisition<br/>[trading.ts]"]
  node_simulated["Session candle simulation<br/>[trading.ts]"]
  node_chart["Price chart<br/>[price-chart.tsx]"]
  node_paper["Paper-trade tracking<br/>[index.tsx]"]
end

subgraph group_analysis["Signal Analysis"]
  node_rules["Indicators and signal<br/>[trading.ts]"]
  node_agents["Rule-based analysts<br/>[trading.ts]"]
  node_ai_signal["Optional AI analyst"]
end

subgraph group_research["Research Services"]
  node_research_panel["Ticker/date research panel<br/>[index.tsx]"]
  node_research_adapter["Python research adapter<br/>[app.py]"]
end

subgraph group_runtime["Application Runtime"]
  node_router["Router setup<br/>[router.tsx]"]
  node_root_route["Root route and shell<br/>[__root.tsx]"]
  node_ui_components["Reusable UI components"]
  node_class_utils["Class utilities<br/>[utils.ts]"]
  node_sidebar["Responsive sidebar<br/>[sidebar.tsx]"]
  node_mobile_hook["Mobile breakpoint hook<br/>[use-mobile.tsx]"]
  node_error_reporting["Client error reporting"]
  node_error_capture["Server error capture<br/>[error-capture.ts]"]
  node_error_page["Server error page<br/>[error-page.ts]"]
  node_server["SSR request handler<br/>[server.ts]"]
end

node_user(("Terminal user"))
node_binance[("Binance candles")]
node_ai_provider{{"Configured chat API"}}
node_tradingagents{{"TradingAgents workflow"}}

node_user -->|"uses"| node_terminal_ui
node_terminal_ui -->|"requests candles"| node_candles
node_candles -->|"fetches supported pairs"| node_binance
node_candles -->|"falls back to"| node_simulated
node_terminal_ui -->|"renders chart"| node_chart
node_chart -->|"calculates EMA"| node_rules
node_terminal_ui -->|"generates signal"| node_rules
node_terminal_ui -->|"runs analysts"| node_agents
node_terminal_ui -->|"manages session trades"| node_paper
node_terminal_ui -.->|"invokes optional AI"| node_ai_signal
node_ai_signal -.->|"requests analysis"| node_ai_provider
node_user -->|"starts research"| node_research_panel
node_research_panel -->|"calls local service"| node_research_adapter
node_research_adapter -->|"adapts workflow"| node_tradingagents
node_router -->|"registers route tree"| node_root_route
node_root_route -->|"renders terminal route"| node_ui_components
node_sidebar -->|"checks viewport"| node_mobile_hook
node_sidebar -->|"uses controls"| node_ui_components
node_ui_components -->|"merges classes"| node_class_utils
node_root_route -->|"reports route errors"| node_error_reporting
node_server -->|"consumes captured error"| node_error_capture
node_server -->|"renders failure page"| node_error_page

click node_terminal_ui "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/index.tsx"
click node_candles "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts"
click node_simulated "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts"
click node_chart "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/components/trading/price-chart.tsx"
click node_paper "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/index.tsx"
click node_rules "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts"
click node_agents "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts"
click node_ai_signal "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/ai-signal.functions.ts"
click node_research_panel "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/index.tsx"
click node_research_adapter "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/backend/app.py"
click node_router "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/router.tsx"
click node_root_route "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/__root.tsx"
click node_ui_components "https://github.com/shantocrockerie-cloud/trading-assistant/tree/main/src/components/ui"
click node_class_utils "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/utils.ts"
click node_sidebar "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/components/ui/sidebar.tsx"
click node_mobile_hook "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/hooks/use-mobile.tsx"
click node_error_reporting "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/lovable-error-reporting.ts"
click node_error_capture "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/error-capture.ts"
click node_error_page "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/error-page.ts"
click node_server "https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/server.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_terminal_ui,node_candles,node_simulated,node_chart,node_paper,node_user toneBlue
class node_rules,node_agents,node_ai_signal,node_binance toneAmber
class node_research_panel,node_research_adapter,node_ai_provider toneMint
class node_router,node_root_route,node_ui_components,node_class_utils,node_sidebar,node_mobile_hook,node_error_reporting,node_error_capture,node_error_page,node_server toneRose
class node_tradingagents toneIndigo
```

## Components

### Browser Terminal

- [Terminal interface](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [Candle acquisition](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts): `src/lib/trading.ts`
- [Session candle simulation](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts): `src/lib/trading.ts`
- [Price chart](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/components/trading/price-chart.tsx): `src/components/trading/price-chart.tsx`
- [Paper-trade tracking](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/index.tsx): `src/routes/index.tsx`

### Signal Analysis

- [Indicators and signal](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts): `src/lib/trading.ts`
- [Rule-based analysts](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/trading.ts): `src/lib/trading.ts`
- [Optional AI analyst](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/ai-signal.functions.ts): `src/lib/ai-signal.functions.ts`

### Research Services

- [Ticker/date research panel](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [Python research adapter](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/backend/app.py): `backend/app.py`

### Application Runtime

- [Router setup](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/router.tsx): `src/router.tsx`
- [Root route and shell](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/routes/__root.tsx): `src/routes/__root.tsx`
- [Reusable UI components](https://github.com/shantocrockerie-cloud/trading-assistant/tree/main/src/components/ui): `src/components/ui`
- [Class utilities](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/utils.ts): `src/lib/utils.ts`
- [Responsive sidebar](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/components/ui/sidebar.tsx): `src/components/ui/sidebar.tsx`
- [Mobile breakpoint hook](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/hooks/use-mobile.tsx): `src/hooks/use-mobile.tsx`
- [Client error reporting](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/lovable-error-reporting.ts): `src/lib/lovable-error-reporting.ts`
- [Server error capture](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/error-capture.ts): `src/lib/error-capture.ts`
- [Server error page](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/lib/error-page.ts): `src/lib/error-page.ts`
- [SSR request handler](https://github.com/shantocrockerie-cloud/trading-assistant/blob/main/src/server.ts): `src/server.ts`

### Other components

- **Terminal user**
- **Binance candles**
- **Configured chat API**
- **TradingAgents workflow**

## Connections

- Terminal user → Terminal interface: uses
- Terminal interface → Candle acquisition: requests candles (evidence: `src/routes/index.tsx`)
- Candle acquisition → Binance candles: fetches supported pairs
- Candle acquisition → Session candle simulation: falls back to (evidence: `src/lib/trading.ts`)
- Terminal interface → Price chart: renders chart (evidence: `src/routes/index.tsx`)
- Price chart → Indicators and signal: calculates EMA (evidence: `src/components/trading/price-chart.tsx`)
- Terminal interface → Indicators and signal: generates signal (evidence: `src/routes/index.tsx`)
- Terminal interface → Rule-based analysts: runs analysts (evidence: `src/routes/index.tsx`)
- Terminal interface → Paper-trade tracking: manages session trades (evidence: `src/routes/index.tsx`)
- Terminal interface → Optional AI analyst: invokes optional AI (evidence: `src/routes/index.tsx`)
- Optional AI analyst → Configured chat API: requests analysis
- Terminal user → Ticker/date research panel: starts research
- Ticker/date research panel → Python research adapter: calls local service
- Python research adapter → TradingAgents workflow: adapts workflow
- Router setup → Root route and shell: registers route tree (evidence: `src/router.tsx`)
- Root route and shell → Reusable UI components: renders terminal route (evidence: `src/routes/__root.tsx`)
- Responsive sidebar → Mobile breakpoint hook: checks viewport (evidence: `src/components/ui/sidebar.tsx`)
- Responsive sidebar → Reusable UI components: uses controls (evidence: `src/components/ui/sidebar.tsx`)
- Reusable UI components → Class utilities: merges classes (evidence: `src/components/ui/button.tsx`)
- Root route and shell → Client error reporting: reports route errors (evidence: `src/routes/__root.tsx`)
- SSR request handler → Server error capture: consumes captured error (evidence: `src/server.ts`)
- SSR request handler → Server error page: renders failure page (evidence: `src/server.ts`)
