# aarearavind7/trade architecture

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

- Interactive diagram: https://gitdiagram.com/aarearavind7/trade
- Repository: https://github.com/aarearavind7/trade

## Overview

This checkout contains a community-curated public-API directory alongside a lightweight paper-trading application; the trading app is the product workflow represented here. A user interacts with the browser dashboard or API, which routes requests to account/trading, market-data, research, journal, and export features. The backend uses Alpaca for paper brokerage and market streaming, with optional public-data providers. The README mainly describes the unrelated public-API directory, so browser-to-API wiring and several unsampled runtime details are shown only where documented or clearly marked unverified.

Main entry points: [`trading_app/api.py`](https://github.com/aarearavind7/trade/blob/main/trading_app/api.py) (HTTP API), [`web/app.js`](https://github.com/aarearavind7/trade/blob/main/web/app.js) (Dashboard UI), [`trading_app/alpaca_client.py`](https://github.com/aarearavind7/trade/blob/main/trading_app/alpaca_client.py) (Alpaca Client), [`trading_app/service.py`](https://github.com/aarearavind7/trade/blob/main/trading_app/service.py) (Trading Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Dashboard"]
  node_dashboard["Dashboard UI<br/>[app.js]"]
  node_charts["Chart Data<br/>[chart-data.js]"]
  node_research_ui["Research UI<br/>[research.js]"]
  node_alerts["Price Alerts<br/>[price-alerts.js]"]
  node_workspace["Workspace Backup"]
end

subgraph group_routing["API Layer"]
  node_api["HTTP API<br/>[api.py]"]
  node_cli["Command Line<br/>[cli.py]"]
end

subgraph group_trading["Trading and Records"]
  node_service["Trading Service<br/>[service.py]"]
  node_order_store[("Order Store<br/>[service.py]")]
  node_alpaca_client["Alpaca Client<br/>[alpaca_client.py]"]
  node_journal["Trade Journal<br/>[journal.py]"]
  node_csv_export["CSV Export<br/>[csv_export.py]"]
  node_benchmark["Benchmarking<br/>[benchmark.py]"]
end

subgraph group_insights["Market and Research"]
  node_market_stream["Market Stream<br/>[market_stream.py]"]
  node_public_data["Public Market Data"]
  node_stock_search["Stock Search<br/>[stock_search.py]"]
  node_sp500["S&amp;P 500 Catalog<br/>[sp500_catalog.py]"]
  node_research["Financial Research<br/>[research.py]"]
end

node_user(("User"))
node_alpaca{{"Alpaca Services"}}
node_yahoo{{"Yahoo Finance"}}
node_fmp{{"Financial Modeling Prep"}}
node_constituent_source{{"Constituent Dataset"}}

node_user -->|"uses"| node_dashboard
node_dashboard -.->|"requests data"| node_api
node_user -->|"invokes"| node_cli
node_cli -->|"creates client"| node_alpaca_client
node_api -->|"routes trading"| node_service
node_api -->|"routes broker access"| node_alpaca_client
node_api -->|"routes streaming"| node_market_stream
node_api -->|"routes market data"| node_public_data
node_api -->|"routes search"| node_stock_search
node_api -->|"routes constituents"| node_sp500
node_api -->|"routes research"| node_research
node_api -->|"routes journal"| node_journal
node_api -->|"routes benchmarks"| node_benchmark
node_api -->|"routes export"| node_csv_export
node_service -->|"stores reviews"| node_order_store
node_service -->|"checks and submits"| node_alpaca_client
node_journal -->|"uses SQLite connection"| node_order_store
node_market_stream -->|"streams quotes"| node_alpaca
node_alpaca_client -.->|"calls paper services"| node_alpaca
node_public_data -->|"fetches charts"| node_yahoo
node_stock_search -->|"searches publicly"| node_public_data
node_stock_search -->|"filters broker assets"| node_alpaca_client
node_research -->|"fetches research"| node_fmp
node_sp500 -->|"loads membership"| node_constituent_source
node_dashboard -.->|"renders charts"| node_charts
node_dashboard -.->|"renders research"| node_research_ui
node_dashboard -.->|"manages alerts"| node_alerts
node_dashboard -.->|"backs up workspace"| node_workspace

click node_dashboard "https://github.com/aarearavind7/trade/blob/main/web/app.js"
click node_charts "https://github.com/aarearavind7/trade/blob/main/web/chart-data.js"
click node_research_ui "https://github.com/aarearavind7/trade/blob/main/web/research.js"
click node_alerts "https://github.com/aarearavind7/trade/blob/main/web/price-alerts.js"
click node_workspace "https://github.com/aarearavind7/trade/blob/main/web/workspace-backup.js"
click node_api "https://github.com/aarearavind7/trade/blob/main/trading_app/api.py"
click node_cli "https://github.com/aarearavind7/trade/blob/main/trading_app/cli.py"
click node_service "https://github.com/aarearavind7/trade/blob/main/trading_app/service.py"
click node_order_store "https://github.com/aarearavind7/trade/blob/main/trading_app/service.py"
click node_alpaca_client "https://github.com/aarearavind7/trade/blob/main/trading_app/alpaca_client.py"
click node_journal "https://github.com/aarearavind7/trade/blob/main/trading_app/journal.py"
click node_csv_export "https://github.com/aarearavind7/trade/blob/main/trading_app/csv_export.py"
click node_benchmark "https://github.com/aarearavind7/trade/blob/main/trading_app/benchmark.py"
click node_market_stream "https://github.com/aarearavind7/trade/blob/main/trading_app/market_stream.py"
click node_public_data "https://github.com/aarearavind7/trade/blob/main/trading_app/public_market_data.py"
click node_stock_search "https://github.com/aarearavind7/trade/blob/main/trading_app/stock_search.py"
click node_sp500 "https://github.com/aarearavind7/trade/blob/main/trading_app/sp500_catalog.py"
click node_research "https://github.com/aarearavind7/trade/blob/main/trading_app/research.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_charts,node_research_ui,node_alerts,node_workspace,node_user toneBlue
class node_api,node_cli toneAmber
class node_service,node_order_store,node_alpaca_client,node_journal,node_csv_export,node_benchmark toneMint
class node_market_stream,node_public_data,node_stock_search,node_sp500,node_research toneRose
class node_alpaca,node_yahoo,node_fmp,node_constituent_source toneIndigo
```

## Components

### Dashboard

- [Dashboard UI](https://github.com/aarearavind7/trade/blob/main/web/app.js): `web/app.js`
- [Chart Data](https://github.com/aarearavind7/trade/blob/main/web/chart-data.js): `web/chart-data.js`
- [Research UI](https://github.com/aarearavind7/trade/blob/main/web/research.js): `web/research.js`
- [Price Alerts](https://github.com/aarearavind7/trade/blob/main/web/price-alerts.js): `web/price-alerts.js`
- [Workspace Backup](https://github.com/aarearavind7/trade/blob/main/web/workspace-backup.js): `web/workspace-backup.js`

### API Layer

- [HTTP API](https://github.com/aarearavind7/trade/blob/main/trading_app/api.py): `trading_app/api.py`
- [Command Line](https://github.com/aarearavind7/trade/blob/main/trading_app/cli.py): `trading_app/cli.py`

### Trading and Records

- [Trading Service](https://github.com/aarearavind7/trade/blob/main/trading_app/service.py): `trading_app/service.py`
- [Order Store](https://github.com/aarearavind7/trade/blob/main/trading_app/service.py): `trading_app/service.py`
- [Alpaca Client](https://github.com/aarearavind7/trade/blob/main/trading_app/alpaca_client.py): `trading_app/alpaca_client.py`
- [Trade Journal](https://github.com/aarearavind7/trade/blob/main/trading_app/journal.py): `trading_app/journal.py`
- [CSV Export](https://github.com/aarearavind7/trade/blob/main/trading_app/csv_export.py): `trading_app/csv_export.py`
- [Benchmarking](https://github.com/aarearavind7/trade/blob/main/trading_app/benchmark.py): `trading_app/benchmark.py`

### Market and Research

- [Market Stream](https://github.com/aarearavind7/trade/blob/main/trading_app/market_stream.py): `trading_app/market_stream.py`
- [Public Market Data](https://github.com/aarearavind7/trade/blob/main/trading_app/public_market_data.py): `trading_app/public_market_data.py`
- [Stock Search](https://github.com/aarearavind7/trade/blob/main/trading_app/stock_search.py): `trading_app/stock_search.py`
- [S&P 500 Catalog](https://github.com/aarearavind7/trade/blob/main/trading_app/sp500_catalog.py): `trading_app/sp500_catalog.py`
- [Financial Research](https://github.com/aarearavind7/trade/blob/main/trading_app/research.py): `trading_app/research.py`

### Other components

- **User**
- **Alpaca Services**
- **Yahoo Finance**
- **Financial Modeling Prep**
- **Constituent Dataset**

## Connections

- User → Dashboard UI: uses
- Dashboard UI → HTTP API: requests data
- User → Command Line: invokes (evidence: `trading_app/cli.py`)
- Command Line → Alpaca Client: creates client (evidence: `trading_app/cli.py`)
- HTTP API → Trading Service: routes trading (evidence: `trading_app/api.py`)
- HTTP API → Alpaca Client: routes broker access (evidence: `trading_app/api.py`)
- HTTP API → Market Stream: routes streaming (evidence: `trading_app/api.py`)
- HTTP API → Public Market Data: routes market data (evidence: `trading_app/api.py`)
- HTTP API → Stock Search: routes search (evidence: `trading_app/api.py`)
- HTTP API → S&P 500 Catalog: routes constituents (evidence: `trading_app/api.py`)
- HTTP API → Financial Research: routes research (evidence: `trading_app/api.py`)
- HTTP API → Trade Journal: routes journal (evidence: `trading_app/api.py`)
- HTTP API → Benchmarking: routes benchmarks (evidence: `trading_app/api.py`)
- HTTP API → CSV Export: routes export (evidence: `trading_app/api.py`)
- Trading Service → Order Store: stores reviews (evidence: `trading_app/service.py`)
- Trading Service → Alpaca Client: checks and submits (evidence: `trading_app/service.py`)
- Trade Journal → Order Store: uses SQLite connection (evidence: `trading_app/journal.py`)
- Market Stream → Alpaca Services: streams quotes (evidence: `trading_app/market_stream.py`)
- Alpaca Client → Alpaca Services: calls paper services
- Public Market Data → Yahoo Finance: fetches charts (evidence: `trading_app/public_market_data.py`)
- Stock Search → Public Market Data: searches publicly (evidence: `trading_app/stock_search.py`)
- Stock Search → Alpaca Client: filters broker assets (evidence: `trading_app/stock_search.py`)
- Financial Research → Financial Modeling Prep: fetches research (evidence: `trading_app/research.py`)
- S&P 500 Catalog → Constituent Dataset: loads membership (evidence: `trading_app/sp500_catalog.py`)
- Dashboard UI → Chart Data: renders charts
- Dashboard UI → Research UI: renders research
- Dashboard UI → Price Alerts: manages alerts
- Dashboard UI → Workspace Backup: backs up workspace
