# agentsmith1337/quantvision architecture

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

- Interactive diagram: https://gitdiagram.com/agentsmith1337/quantvision
- Repository: https://github.com/agentsmith1337/quantvision

## Overview

QuantVision is a local algorithmic-trading application for Angel One. Users set up or sign in, configure credentials and trading mode, then use the trading dashboard to follow market data, manage orders and positions, view news, or run Python strategies. The Backtesting Studio runs the same strategy code against historical candles and saves results. The graph preserves the major script, backtest, market, broker, and news capabilities; some router and UI internals are unsampled, so those subsystems use their enclosing directories and only documented or indexed relationships are shown.

Main entry points: [`backend/app/engine.py`](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/engine.py) (Trading engine), [`backend/app/main.py`](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/market/instruments.py`](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/instruments.py) (Instrument registry), [`backend/app/market/hub.py`](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/hub.py) (Market WebSocket hub)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_setupui["Setup and sign-in<br/>[page.tsx]"]
  node_dashboard["Trading dashboard"]
  node_portfolio["Portfolio view<br/>[page.tsx]"]
  node_backtestui["Backtesting Studio<br/>[page.tsx]"]
  node_frontendapi["API client<br/>[api.ts]"]
end

subgraph group_access["API and access"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_tradingroutes["Trading and broker routes"]
  node_marketroutes["Market and news routes"]
  node_backtestroutes["Backtest routes"]
  node_scriptroutes["Script routes<br/>[scripts.py]"]
end

subgraph group_trading["Trading and market"]
  node_engine["Trading engine<br/>[engine.py]"]
  node_marketfeed["Market feed<br/>[feeds.py]"]
  node_markethub["Market WebSocket hub<br/>[hub.py]"]
  node_instruments["Instrument registry<br/>[instruments.py]"]
  node_scripmaster["Scrip master<br/>[scripmaster.py]"]
  node_brokerinterface["Broker interface<br/>[base.py]"]
  node_angel["Angel One broker<br/>[angel.py]"]
  node_paper["Paper broker<br/>[paper.py]"]
  node_news["Live news<br/>[news.py]"]
end

subgraph group_automation["Scripts and backtests"]
  node_scriptservice["Script service<br/>[service.py]"]
  node_scriptstore["Script storage<br/>[store.py]"]
  node_runtime["Isolated script runtime<br/>[runtime.py]"]
  node_sdk["Strategy SDK<br/>[runner.py]"]
  node_indicators["Technical indicators<br/>[indicators.py]"]
  node_backtestmanager["Backtest manager<br/>[manager.py]"]
  node_historicaldata["Historical candle data<br/>[data.py]"]
  node_backtestengine["Historical simulator<br/>[backtest.py]"]
end

subgraph group_state["Persistence and services"]
  node_database[("SQLite application store<br/>[db.py]")]
  node_preferences["User preferences<br/>[prefs.py]"]
  node_vault["Credential vault<br/>[vault.py]"]
end

node_user(("Local user"))
node_angelservice["Angel One service"]
node_gnews["GNews service"]

node_user -->|"sets up"| node_setupui
node_user -.->|"trades with"| node_dashboard
node_user -->|"configures"| node_backtestui
node_user -->|"views"| node_portfolio
node_setupui -->|"requests"| node_frontendapi
node_fastapi -->|"registers"| node_auth
node_fastapi -->|"registers"| node_tradingroutes
node_fastapi -->|"registers"| node_marketroutes
node_fastapi -->|"registers"| node_backtestroutes
node_fastapi -->|"registers"| node_scriptroutes
node_auth -->|"unlocks credentials"| node_vault
node_auth -->|"starts engine"| node_engine
node_auth -->|"stores account"| node_database
node_tradingroutes -->|"uses engine"| node_engine
node_marketroutes -->|"serves stream"| node_markethub
node_scriptroutes -->|"delegates"| node_scriptservice
node_engine -->|"publishes ticks"| node_markethub
node_engine -->|"manages feed"| node_marketfeed
node_engine -->|"resolves symbols"| node_instruments
node_engine -->|"selects live broker"| node_angel
node_engine -->|"selects paper broker"| node_paper
node_engine -->|"reads mode"| node_preferences
node_marketfeed -->|"publishes ticks"| node_markethub
node_markethub -->|"requests symbols"| node_engine
node_marketfeed -->|"uses session"| node_angel
node_instruments -->|"persists instruments"| node_database
node_instruments -->|"loads names"| node_scripmaster
node_angel -.->|"calls broker API"| node_angelservice
node_paper -->|"reads prices"| node_markethub
node_brokerinterface -->|"uses instrument types"| node_instruments
node_scriptservice -.->|"manages scripts"| node_scriptstore
node_scriptservice -.->|"runs scripts"| node_runtime
node_runtime -.->|"executes strategy"| node_sdk
node_sdk -->|"provides indicators"| node_indicators
node_backtestroutes -.->|"starts simulations"| node_backtestmanager
node_backtestmanager -->|"prepares candles"| node_historicaldata
node_backtestmanager -->|"runs simulation"| node_backtestengine
node_backtestengine -->|"updates indicators"| node_indicators
node_historicaldata -->|"resolves symbols"| node_instruments
node_news -.->|"fetches news"| node_gnews
node_marketroutes -.->|"serves news"| node_news

click node_setupui "https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/app/setup/page.tsx"
click node_dashboard "https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/app/trade/trade-dashboard.tsx"
click node_portfolio "https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/app/portfolio/page.tsx"
click node_backtestui "https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/app/backtest/page.tsx"
click node_frontendapi "https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/lib/api.ts"
click node_fastapi "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/main.py"
click node_auth "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/routers/auth.py"
click node_tradingroutes "https://github.com/agentsmith1337/quantvision/tree/main/backend/app/routers"
click node_marketroutes "https://github.com/agentsmith1337/quantvision/tree/main/backend/app/routers"
click node_backtestroutes "https://github.com/agentsmith1337/quantvision/tree/main/backend/app/routers"
click node_scriptroutes "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/routers/scripts.py"
click node_engine "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/engine.py"
click node_marketfeed "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/feeds.py"
click node_markethub "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/hub.py"
click node_instruments "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/instruments.py"
click node_scripmaster "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/scripmaster.py"
click node_brokerinterface "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/broker/base.py"
click node_angel "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/broker/angel.py"
click node_paper "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/broker/paper.py"
click node_news "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/news.py"
click node_scriptservice "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/scripts/service.py"
click node_scriptstore "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/scripts/store.py"
click node_runtime "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/scripts/runtime.py"
click node_sdk "https://github.com/agentsmith1337/quantvision/blob/main/backend/sdk/quantvision/runner.py"
click node_indicators "https://github.com/agentsmith1337/quantvision/blob/main/backend/sdk/quantvision/indicators.py"
click node_backtestmanager "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/backtest/manager.py"
click node_historicaldata "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/backtest/data.py"
click node_backtestengine "https://github.com/agentsmith1337/quantvision/blob/main/backend/sdk/quantvision/backtest.py"
click node_database "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/db.py"
click node_preferences "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/prefs.py"
click node_vault "https://github.com/agentsmith1337/quantvision/blob/main/backend/app/vault.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_setupui,node_dashboard,node_portfolio,node_backtestui,node_frontendapi,node_user toneBlue
class node_fastapi,node_auth,node_tradingroutes,node_marketroutes,node_backtestroutes,node_scriptroutes toneAmber
class node_engine,node_marketfeed,node_markethub,node_instruments,node_scripmaster,node_brokerinterface,node_angel,node_paper,node_news toneMint
class node_scriptservice,node_scriptstore,node_runtime,node_sdk,node_indicators,node_backtestmanager,node_historicaldata,node_backtestengine toneRose
class node_database,node_preferences,node_vault,node_angelservice,node_gnews toneIndigo
```

## Components

### User experience

- [Setup and sign-in](https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/app/setup/page.tsx): `frontend/src/app/setup/page.tsx`
- [Trading dashboard](https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/app/trade/trade-dashboard.tsx): `frontend/src/app/trade/trade-dashboard.tsx`
- [Portfolio view](https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/app/portfolio/page.tsx): `frontend/src/app/portfolio/page.tsx`
- [Backtesting Studio](https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/app/backtest/page.tsx): `frontend/src/app/backtest/page.tsx`
- [API client](https://github.com/agentsmith1337/quantvision/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### API and access

- [FastAPI application](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Trading and broker routes](https://github.com/agentsmith1337/quantvision/tree/main/backend/app/routers): `backend/app/routers`
- [Market and news routes](https://github.com/agentsmith1337/quantvision/tree/main/backend/app/routers): `backend/app/routers`
- [Backtest routes](https://github.com/agentsmith1337/quantvision/tree/main/backend/app/routers): `backend/app/routers`
- [Script routes](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/routers/scripts.py): `backend/app/routers/scripts.py`

### Trading and market

- [Trading engine](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/engine.py): `backend/app/engine.py`
- [Market feed](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/feeds.py): `backend/app/market/feeds.py`
- [Market WebSocket hub](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/hub.py): `backend/app/market/hub.py`
- [Instrument registry](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/instruments.py): `backend/app/market/instruments.py`
- [Scrip master](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/market/scripmaster.py): `backend/app/market/scripmaster.py`
- [Broker interface](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/broker/base.py): `backend/app/broker/base.py`
- [Angel One broker](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/broker/angel.py): `backend/app/broker/angel.py`
- [Paper broker](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/broker/paper.py): `backend/app/broker/paper.py`
- [Live news](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/news.py): `backend/app/news.py`

### Scripts and backtests

- [Script service](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/scripts/service.py): `backend/app/scripts/service.py`
- [Script storage](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/scripts/store.py): `backend/app/scripts/store.py`
- [Isolated script runtime](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/scripts/runtime.py): `backend/app/scripts/runtime.py`
- [Strategy SDK](https://github.com/agentsmith1337/quantvision/blob/main/backend/sdk/quantvision/runner.py): `backend/sdk/quantvision/runner.py`
- [Technical indicators](https://github.com/agentsmith1337/quantvision/blob/main/backend/sdk/quantvision/indicators.py): `backend/sdk/quantvision/indicators.py`
- [Backtest manager](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/backtest/manager.py): `backend/app/backtest/manager.py`
- [Historical candle data](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/backtest/data.py): `backend/app/backtest/data.py`
- [Historical simulator](https://github.com/agentsmith1337/quantvision/blob/main/backend/sdk/quantvision/backtest.py): `backend/sdk/quantvision/backtest.py`

### Persistence and services

- [SQLite application store](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/db.py): `backend/app/db.py`
- [User preferences](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/prefs.py): `backend/app/prefs.py`
- [Credential vault](https://github.com/agentsmith1337/quantvision/blob/main/backend/app/vault.py): `backend/app/vault.py`

### Other components

- **Local user**
- **Angel One service**
- **GNews service**

## Connections

- Local user → Setup and sign-in: sets up (evidence: `frontend/src/app/setup/page.tsx`)
- Local user → Trading dashboard: trades with
- Local user → Backtesting Studio: configures (evidence: `frontend/src/app/backtest/page.tsx`)
- Local user → Portfolio view: views (evidence: `frontend/src/app/portfolio/page.tsx`)
- Setup and sign-in → API client: requests (evidence: `frontend/src/app/setup/page.tsx`)
- FastAPI application → Authentication: registers (evidence: `backend/app/main.py`)
- FastAPI application → Trading and broker routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Market and news routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Backtest routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Script routes: registers (evidence: `backend/app/main.py`)
- Authentication → Credential vault: unlocks credentials (evidence: `backend/app/routers/auth.py`)
- Authentication → Trading engine: starts engine (evidence: `backend/app/routers/auth.py`)
- Authentication → SQLite application store: stores account (evidence: `backend/app/routers/auth.py`)
- Trading and broker routes → Trading engine: uses engine (evidence: `backend/app/routers/broker.py`)
- Market and news routes → Market WebSocket hub: serves stream (evidence: `backend/app/main.py`)
- Script routes → Script service: delegates (evidence: `backend/app/routers/scripts.py`)
- Trading engine → Market WebSocket hub: publishes ticks (evidence: `backend/app/engine.py`)
- Trading engine → Market feed: manages feed (evidence: `backend/app/engine.py`)
- Trading engine → Instrument registry: resolves symbols (evidence: `backend/app/engine.py`)
- Trading engine → Angel One broker: selects live broker (evidence: `backend/app/engine.py`)
- Trading engine → Paper broker: selects paper broker (evidence: `backend/app/engine.py`)
- Trading engine → User preferences: reads mode (evidence: `backend/app/engine.py`)
- Market feed → Market WebSocket hub: publishes ticks (evidence: `backend/app/market/feeds.py`)
- Market WebSocket hub → Trading engine: requests symbols (evidence: `backend/app/market/hub.py`)
- Market feed → Angel One broker: uses session (evidence: `backend/app/market/feeds.py`)
- Instrument registry → SQLite application store: persists instruments (evidence: `backend/app/market/instruments.py`)
- Instrument registry → Scrip master: loads names (evidence: `backend/app/market/instruments.py`)
- Angel One broker → Angel One service: calls broker API
- Paper broker → Market WebSocket hub: reads prices (evidence: `backend/app/broker/paper.py`)
- Broker interface → Instrument registry: uses instrument types (evidence: `backend/app/broker/base.py`)
- Script service → Script storage: manages scripts
- Script service → Isolated script runtime: runs scripts
- Isolated script runtime → Strategy SDK: executes strategy
- Strategy SDK → Technical indicators: provides indicators (evidence: `backend/sdk/quantvision/runner.py`)
- Backtest routes → Backtest manager: starts simulations
- Backtest manager → Historical candle data: prepares candles (evidence: `backend/app/backtest/manager.py`)
- Backtest manager → Historical simulator: runs simulation (evidence: `backend/app/backtest/manager.py`)
- Historical simulator → Technical indicators: updates indicators (evidence: `backend/sdk/quantvision/backtest.py`)
- Historical candle data → Instrument registry: resolves symbols (evidence: `backend/app/backtest/data.py`)
- Live news → GNews service: fetches news
- Market and news routes → Live news: serves news
