# msant1972/stocks architecture

> Architecture diagram of the GitHub repository msant1972/stocks, 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/msant1972/stocks
- Repository: https://github.com/msant1972/stocks

## Overview

This is a financial-market research and trading application: users explore instruments, quotes, charts, strategies, alerts, and SAXO-linked orders through a browser UI. The frontend routes those workflows to a Fastify API, which handles sessions and domain endpoints; market-history collection and alert delivery also have Python engines. Shared strategy code is explicitly intended for both frontend and API use. The README is empty, so the product breadth comes from the route map and source tree; only sampled call relationships are connected, with unsampled capability links omitted.

Main entry points: [`api/src/app.js`](https://github.com/msant1972/stocks/blob/main/api/src/app.js) (HTTP application), [`frontend/src/app/App.jsx`](https://github.com/msant1972/stocks/blob/main/frontend/src/app/App.jsx) (Route and session UI), [`frontend/src/features/charts/ChartsPage.jsx`](https://github.com/msant1972/stocks/blob/main/frontend/src/features/charts/ChartsPage.jsx) (Instrument research), [`shared/strategies/index.js`](https://github.com/msant1972/stocks/blob/main/shared/strategies/index.js) (Strategy registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Route and session UI<br/>[App.jsx]"]
  node_api_client["HTTP client<br/>[api.js]"]
  node_instrument_ui["Instrument research<br/>[ChartsPage.jsx]"]
  node_watchlist_ui["Watchlist<br/>[WatchlistPage.jsx]"]
  node_chart["Price charts<br/>[DailyChart.jsx]"]
  node_other_ui["Research pages<br/>[OverviewPage.jsx]"]
end

subgraph group_api["API and domain"]
  node_api_app["HTTP application<br/>[app.js]"]
  node_auth_routes["Authentication<br/>[auth.js]"]
  node_sessions[("Session store<br/>[sessions.js]")]
  node_instrument_routes["Instrument endpoints<br/>[instruments.js]"]
  node_market_routes["Market endpoints<br/>[market.js]"]
  node_strategy_api["Strategy runs<br/>[strategy-worker.js]"]
  node_saxo_routes["SAXO endpoints<br/>[saxo.js]"]
  node_saxo_service["Trading service<br/>[service.js]"]
  node_alerts_routes["Alert endpoints<br/>[alerts.js]"]
end

subgraph group_marketdata["Market data engines"]
  node_fetch_service["Quote collection<br/>[service.py]"]
  node_fetch_provider["Quote provider<br/>[provider.py]"]
  node_fetch_db[("History database<br/>[db.py]")]
end

subgraph group_trading["Trading and strategies"]
  node_strategy_index["Strategy registry<br/>[index.js]"]
  node_momentum["Momentum indicators<br/>[momentum.js]"]
  node_strategy_a["A-Momentum<br/>[a-momentum.js]"]
  node_strategy_b["B-Opus<br/>[b-opus.js]"]
end

subgraph group_alerts["Alert delivery"]
  node_alerts_service["Alert engine<br/>[service.py]"]
  node_alerts_digest["Digest builder<br/>[digest.py]"]
  node_alerts_mailer["Mail delivery<br/>[mailer.py]"]
end

node_user(("User"))
node_saxo_remote["SAXO Bank"]
node_mail_service["SMTP service"]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_instrument_ui
node_app -->|"routes to"| node_watchlist_ui
node_app -->|"routes to"| node_other_ui
node_instrument_ui -->|"renders"| node_chart
node_instrument_ui -->|"requests data"| node_api_client
node_watchlist_ui -->|"requests data"| node_api_client
node_api_client -->|"HTTP requests"| node_api_app
node_api_app -->|"registers"| node_auth_routes
node_api_app -->|"registers"| node_instrument_routes
node_api_app -->|"registers"| node_market_routes
node_api_app -->|"registers"| node_alerts_routes
node_api_app -->|"registers"| node_saxo_routes
node_auth_routes -->|"creates sessions"| node_sessions
node_strategy_api -->|"runs strategy"| node_strategy_index
node_strategy_index -->|"dispatches"| node_strategy_a
node_strategy_index -->|"dispatches"| node_strategy_b
node_strategy_b -->|"uses indicators"| node_momentum
node_saxo_routes -.->|"handles trading"| node_saxo_service
node_saxo_service -.->|"places orders"| node_saxo_remote
node_fetch_service -->|"fetches history"| node_fetch_provider
node_fetch_service -->|"stores quotes"| node_fetch_db
node_alerts_service -->|"builds digests"| node_alerts_digest
node_alerts_service -->|"sends mail"| node_alerts_mailer
node_alerts_mailer -.->|"delivers via SMTP"| node_mail_service

click node_app "https://github.com/msant1972/stocks/blob/main/frontend/src/app/App.jsx"
click node_api_client "https://github.com/msant1972/stocks/blob/main/frontend/src/lib/api.js"
click node_instrument_ui "https://github.com/msant1972/stocks/blob/main/frontend/src/features/charts/ChartsPage.jsx"
click node_watchlist_ui "https://github.com/msant1972/stocks/blob/main/frontend/src/features/watchlist/WatchlistPage.jsx"
click node_chart "https://github.com/msant1972/stocks/blob/main/frontend/src/components/finance/DailyChart.jsx"
click node_other_ui "https://github.com/msant1972/stocks/blob/main/frontend/src/features/overview/OverviewPage.jsx"
click node_api_app "https://github.com/msant1972/stocks/blob/main/api/src/app.js"
click node_auth_routes "https://github.com/msant1972/stocks/blob/main/api/src/routes/auth.js"
click node_sessions "https://github.com/msant1972/stocks/blob/main/api/src/auth/sessions.js"
click node_instrument_routes "https://github.com/msant1972/stocks/blob/main/api/src/routes/instruments.js"
click node_market_routes "https://github.com/msant1972/stocks/blob/main/api/src/routes/market.js"
click node_strategy_api "https://github.com/msant1972/stocks/blob/main/api/src/services/strategy-worker.js"
click node_saxo_routes "https://github.com/msant1972/stocks/blob/main/api/src/routes/saxo.js"
click node_saxo_service "https://github.com/msant1972/stocks/blob/main/api/src/saxo/service.js"
click node_fetch_service "https://github.com/msant1972/stocks/blob/main/engines/fetcher/fetcher/service.py"
click node_fetch_provider "https://github.com/msant1972/stocks/blob/main/engines/fetcher/fetcher/provider.py"
click node_fetch_db "https://github.com/msant1972/stocks/blob/main/engines/fetcher/fetcher/db.py"
click node_alerts_routes "https://github.com/msant1972/stocks/blob/main/api/src/routes/alerts.js"
click node_alerts_service "https://github.com/msant1972/stocks/blob/main/engines/alerts/alerts/service.py"
click node_alerts_digest "https://github.com/msant1972/stocks/blob/main/engines/alerts/alerts/digest.py"
click node_alerts_mailer "https://github.com/msant1972/stocks/blob/main/engines/alerts/alerts/mailer.py"
click node_strategy_index "https://github.com/msant1972/stocks/blob/main/shared/strategies/index.js"
click node_momentum "https://github.com/msant1972/stocks/blob/main/shared/momentum.js"
click node_strategy_a "https://github.com/msant1972/stocks/blob/main/shared/strategies/a-momentum.js"
click node_strategy_b "https://github.com/msant1972/stocks/blob/main/shared/strategies/b-opus.js"

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_api_client,node_instrument_ui,node_watchlist_ui,node_chart,node_other_ui,node_user toneBlue
class node_api_app,node_auth_routes,node_sessions,node_instrument_routes,node_market_routes,node_strategy_api,node_saxo_routes,node_saxo_service,node_alerts_routes toneAmber
class node_fetch_service,node_fetch_provider,node_fetch_db toneMint
class node_strategy_index,node_momentum,node_strategy_a,node_strategy_b toneRose
class node_alerts_service,node_alerts_digest,node_alerts_mailer,node_saxo_remote,node_mail_service toneIndigo
```

## Components

### Web client

- [Route and session UI](https://github.com/msant1972/stocks/blob/main/frontend/src/app/App.jsx): `frontend/src/app/App.jsx`
- [HTTP client](https://github.com/msant1972/stocks/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`
- [Instrument research](https://github.com/msant1972/stocks/blob/main/frontend/src/features/charts/ChartsPage.jsx): `frontend/src/features/charts/ChartsPage.jsx`
- [Watchlist](https://github.com/msant1972/stocks/blob/main/frontend/src/features/watchlist/WatchlistPage.jsx): `frontend/src/features/watchlist/WatchlistPage.jsx`
- [Price charts](https://github.com/msant1972/stocks/blob/main/frontend/src/components/finance/DailyChart.jsx): `frontend/src/components/finance/DailyChart.jsx`
- [Research pages](https://github.com/msant1972/stocks/blob/main/frontend/src/features/overview/OverviewPage.jsx): `frontend/src/features/overview/OverviewPage.jsx`

### API and domain

- [HTTP application](https://github.com/msant1972/stocks/blob/main/api/src/app.js): `api/src/app.js`
- [Authentication](https://github.com/msant1972/stocks/blob/main/api/src/routes/auth.js): `api/src/routes/auth.js`
- [Session store](https://github.com/msant1972/stocks/blob/main/api/src/auth/sessions.js): `api/src/auth/sessions.js`
- [Instrument endpoints](https://github.com/msant1972/stocks/blob/main/api/src/routes/instruments.js): `api/src/routes/instruments.js`
- [Market endpoints](https://github.com/msant1972/stocks/blob/main/api/src/routes/market.js): `api/src/routes/market.js`
- [Strategy runs](https://github.com/msant1972/stocks/blob/main/api/src/services/strategy-worker.js): `api/src/services/strategy-worker.js`
- [SAXO endpoints](https://github.com/msant1972/stocks/blob/main/api/src/routes/saxo.js): `api/src/routes/saxo.js`
- [Trading service](https://github.com/msant1972/stocks/blob/main/api/src/saxo/service.js): `api/src/saxo/service.js`
- [Alert endpoints](https://github.com/msant1972/stocks/blob/main/api/src/routes/alerts.js): `api/src/routes/alerts.js`

### Market data engines

- [Quote collection](https://github.com/msant1972/stocks/blob/main/engines/fetcher/fetcher/service.py): `engines/fetcher/fetcher/service.py`
- [Quote provider](https://github.com/msant1972/stocks/blob/main/engines/fetcher/fetcher/provider.py): `engines/fetcher/fetcher/provider.py`
- [History database](https://github.com/msant1972/stocks/blob/main/engines/fetcher/fetcher/db.py): `engines/fetcher/fetcher/db.py`

### Trading and strategies

- [Strategy registry](https://github.com/msant1972/stocks/blob/main/shared/strategies/index.js): `shared/strategies/index.js`
- [Momentum indicators](https://github.com/msant1972/stocks/blob/main/shared/momentum.js): `shared/momentum.js`
- [A-Momentum](https://github.com/msant1972/stocks/blob/main/shared/strategies/a-momentum.js): `shared/strategies/a-momentum.js`
- [B-Opus](https://github.com/msant1972/stocks/blob/main/shared/strategies/b-opus.js): `shared/strategies/b-opus.js`

### Alert delivery

- [Alert engine](https://github.com/msant1972/stocks/blob/main/engines/alerts/alerts/service.py): `engines/alerts/alerts/service.py`
- [Digest builder](https://github.com/msant1972/stocks/blob/main/engines/alerts/alerts/digest.py): `engines/alerts/alerts/digest.py`
- [Mail delivery](https://github.com/msant1972/stocks/blob/main/engines/alerts/alerts/mailer.py): `engines/alerts/alerts/mailer.py`

### Other components

- **User**
- **SAXO Bank**
- **SMTP service**

## Connections

- User → Route and session UI: uses
- Route and session UI → Instrument research: routes to (evidence: `frontend/src/app/App.jsx`)
- Route and session UI → Watchlist: routes to (evidence: `frontend/src/app/App.jsx`)
- Route and session UI → Research pages: routes to (evidence: `frontend/src/app/App.jsx`)
- Instrument research → Price charts: renders (evidence: `frontend/src/features/charts/ChartsPage.jsx`)
- Instrument research → HTTP client: requests data (evidence: `frontend/src/features/charts/ChartsPage.jsx`)
- Watchlist → HTTP client: requests data (evidence: `frontend/src/features/watchlist/WatchlistPage.jsx`)
- HTTP client → HTTP application: HTTP requests (evidence: `frontend/src/lib/api.js`)
- HTTP application → Authentication: registers (evidence: `api/src/app.js`)
- HTTP application → Instrument endpoints: registers (evidence: `api/src/app.js`)
- HTTP application → Market endpoints: registers (evidence: `api/src/app.js`)
- HTTP application → Alert endpoints: registers (evidence: `api/src/app.js`)
- HTTP application → SAXO endpoints: registers (evidence: `api/src/app.js`)
- Authentication → Session store: creates sessions (evidence: `api/src/routes/auth.js`)
- Strategy runs → Strategy registry: runs strategy (evidence: `api/src/services/strategy-worker.js`)
- Strategy registry → A-Momentum: dispatches (evidence: `shared/strategies/index.js`)
- Strategy registry → B-Opus: dispatches (evidence: `shared/strategies/index.js`)
- B-Opus → Momentum indicators: uses indicators (evidence: `shared/strategies/b-opus.js`)
- SAXO endpoints → Trading service: handles trading
- Trading service → SAXO Bank: places orders
- Quote collection → Quote provider: fetches history (evidence: `engines/fetcher/fetcher/service.py`)
- Quote collection → History database: stores quotes (evidence: `engines/fetcher/fetcher/service.py`)
- Alert engine → Digest builder: builds digests (evidence: `engines/alerts/alerts/service.py`)
- Alert engine → Mail delivery: sends mail (evidence: `engines/alerts/alerts/service.py`)
- Mail delivery → SMTP service: delivers via SMTP
