# marketcalls/openalgo-desktop architecture

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

- Interactive diagram: https://gitdiagram.com/marketcalls/openalgo-desktop
- Repository: https://github.com/marketcalls/openalgo-desktop

## Overview

OpenAlgo Desktop is a local-first algorithmic trading desktop app. Users set up an account, connect a supported broker, then manage orders and portfolios, monitor live market data, and use strategies, paper trading, and historical analysis. The React UI reaches Rust through Tauri IPC; Rust commands share business services with the webhook REST API and use broker adapters and local stores. The README documents the principal trading capabilities and service-layer flow. Some backend modules were not sampled, so their internal calls are omitted where evidence is unavailable.

Main entry points: [`src-tauri/src/services`](https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/services) (Trading Services), [`src-tauri/src/commands`](https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/commands) (Tauri Commands), [`src-tauri/src/state.rs`](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/state.rs) (Shared App State), [`src/api/tauri-client.ts`](https://github.com/marketcalls/openalgo-desktop/blob/master/src/api/tauri-client.ts) (Tauri IPC Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Desktop UI"]
  node_ui["Application Pages"]
  node_router["App Router<br/>[App.tsx]"]
  node_authstate["Auth State<br/>[authStore.ts]"]
  node_ipcclient["Tauri IPC Client<br/>[tauri-client.ts]"]
end

subgraph group_backend["Application Backend"]
  node_commands["Tauri Commands"]
  node_services["Trading Services"]
  node_appstate["Shared App State<br/>[state.rs]"]
end

subgraph group_trading["Trading Capabilities"]
  node_orders["Order Management<br/>[order_service.rs]"]
  node_smartorders["Smart Orders"]
  node_options["Options Analysis<br/>[options_service.rs]"]
  node_strategies["Strategy Management<br/>[strategy.rs]"]
  node_sandbox["Paper Trading<br/>[sandbox.rs]"]
  node_historify["Historical Analysis<br/>[history_service.rs]"]
end

subgraph group_storage["Local Data and Security"]
  node_sqlite[("SQLite Store")]
  node_duckdb[("DuckDB Store")]
  node_security["Credential Security"]
end

subgraph group_integrations["Broker and API Integrations"]
  node_brokeradapters["Broker Adapters"]
  node_webhookserver["Webhook REST Server<br/>[server.rs]"]
  node_webhookhandlers["Webhook Handlers<br/>[handlers.rs]"]
  node_websocket["Live WebSocket<br/>[manager.rs]"]
end

node_user(("Desktop User"))
node_broker(("Supported Brokers"))
node_externalclient(("SDK or Strategy Client"))

node_user -->|"uses"| node_router
node_router -->|"routes to"| node_ui
node_ui -.->|"requests operations"| node_ipcclient
node_authstate -->|"calls auth API"| node_ipcclient
node_ipcclient -->|"invokes"| node_commands
node_commands -->|"delegates to"| node_services
node_commands -.->|"reads and writes"| node_sqlite
node_services -.->|"uses"| node_brokeradapters
node_brokeradapters -.->|"connects to"| node_broker
node_services -->|"uses shared state"| node_appstate
node_webhookserver -->|"dispatches"| node_webhookhandlers
node_externalclient -.->|"sends requests"| node_webhookserver
node_webhookhandlers -->|"calls services"| node_services
node_websocket -->|"managed in"| node_appstate
node_services -.->|"implements"| node_orders
node_services -.->|"implements"| node_smartorders
node_services -->|"implements"| node_options
node_commands -.->|"handles"| node_strategies
node_commands -.->|"handles"| node_sandbox
node_services -->|"implements"| node_historify
node_appstate -->|"initializes"| node_sqlite
node_appstate -->|"initializes"| node_duckdb
node_appstate -->|"initializes"| node_security
node_user -.->|"authenticates broker"| node_brokeradapters

click node_ui "https://github.com/marketcalls/openalgo-desktop/tree/master/src/pages"
click node_router "https://github.com/marketcalls/openalgo-desktop/blob/master/src/App.tsx"
click node_authstate "https://github.com/marketcalls/openalgo-desktop/blob/master/src/stores/authStore.ts"
click node_ipcclient "https://github.com/marketcalls/openalgo-desktop/blob/master/src/api/tauri-client.ts"
click node_commands "https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/commands"
click node_services "https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/services"
click node_appstate "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/state.rs"
click node_brokeradapters "https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/brokers"
click node_webhookserver "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/webhook/server.rs"
click node_webhookhandlers "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/webhook/handlers.rs"
click node_websocket "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/websocket/manager.rs"
click node_orders "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/services/order_service.rs"
click node_smartorders "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/services/smart_order_service.rs"
click node_options "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/services/options_service.rs"
click node_strategies "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/commands/strategy.rs"
click node_sandbox "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/commands/sandbox.rs"
click node_historify "https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/services/history_service.rs"
click node_sqlite "https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/db/sqlite"
click node_duckdb "https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/db/duckdb"
click node_security "https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/security"

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_ui,node_router,node_authstate,node_ipcclient,node_user,node_externalclient toneBlue
class node_commands,node_services,node_appstate toneAmber
class node_orders,node_smartorders,node_options,node_strategies,node_sandbox,node_historify toneMint
class node_sqlite,node_duckdb,node_security toneRose
class node_brokeradapters,node_webhookserver,node_webhookhandlers,node_websocket,node_broker toneIndigo
```

## Components

### Desktop UI

- [Application Pages](https://github.com/marketcalls/openalgo-desktop/tree/master/src/pages): `src/pages`
- [App Router](https://github.com/marketcalls/openalgo-desktop/blob/master/src/App.tsx): `src/App.tsx`
- [Auth State](https://github.com/marketcalls/openalgo-desktop/blob/master/src/stores/authStore.ts): `src/stores/authStore.ts`
- [Tauri IPC Client](https://github.com/marketcalls/openalgo-desktop/blob/master/src/api/tauri-client.ts): `src/api/tauri-client.ts`

### Application Backend

- [Tauri Commands](https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/commands): `src-tauri/src/commands`
- [Trading Services](https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/services): `src-tauri/src/services`
- [Shared App State](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/state.rs): `src-tauri/src/state.rs`

### Trading Capabilities

- [Order Management](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/services/order_service.rs): `src-tauri/src/services/order_service.rs`
- [Smart Orders](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/services/smart_order_service.rs): `src-tauri/src/services/smart_order_service.rs`
- [Options Analysis](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/services/options_service.rs): `src-tauri/src/services/options_service.rs`
- [Strategy Management](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/commands/strategy.rs): `src-tauri/src/commands/strategy.rs`
- [Paper Trading](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/commands/sandbox.rs): `src-tauri/src/commands/sandbox.rs`
- [Historical Analysis](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/services/history_service.rs): `src-tauri/src/services/history_service.rs`

### Local Data and Security

- [SQLite Store](https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/db/sqlite): `src-tauri/src/db/sqlite`
- [DuckDB Store](https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/db/duckdb): `src-tauri/src/db/duckdb`
- [Credential Security](https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/security): `src-tauri/src/security`

### Broker and API Integrations

- [Broker Adapters](https://github.com/marketcalls/openalgo-desktop/tree/master/src-tauri/src/brokers): `src-tauri/src/brokers`
- [Webhook REST Server](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/webhook/server.rs): `src-tauri/src/webhook/server.rs`
- [Webhook Handlers](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/webhook/handlers.rs): `src-tauri/src/webhook/handlers.rs`
- [Live WebSocket](https://github.com/marketcalls/openalgo-desktop/blob/master/src-tauri/src/websocket/manager.rs): `src-tauri/src/websocket/manager.rs`

### Other components

- **Desktop User**
- **Supported Brokers**
- **SDK or Strategy Client**

## Connections

- Desktop User → App Router: uses (evidence: `src/App.tsx`)
- App Router → Application Pages: routes to (evidence: `src/App.tsx`)
- Application Pages → Tauri IPC Client: requests operations
- Auth State → Tauri IPC Client: calls auth API (evidence: `src/stores/authStore.ts`)
- Tauri IPC Client → Tauri Commands: invokes
- Tauri Commands → Trading Services: delegates to (evidence: `src-tauri/src/services/mod.rs`)
- Tauri Commands → SQLite Store: reads and writes
- Trading Services → Broker Adapters: uses (evidence: `src-tauri/src/services/options_service.rs`)
- Broker Adapters → Supported Brokers: connects to
- Trading Services → Shared App State: uses shared state (evidence: `src-tauri/src/services/options_service.rs`)
- Webhook REST Server → Webhook Handlers: dispatches (evidence: `src-tauri/src/webhook/server.rs`)
- SDK or Strategy Client → Webhook REST Server: sends requests
- Webhook Handlers → Trading Services: calls services (evidence: `src-tauri/src/webhook/handlers.rs`)
- Live WebSocket → Shared App State: managed in (evidence: `src-tauri/src/state.rs`)
- Trading Services → Order Management: implements (evidence: `src-tauri/src/services/mod.rs`)
- Trading Services → Smart Orders: implements (evidence: `src-tauri/src/services/mod.rs`)
- Trading Services → Options Analysis: implements (evidence: `src-tauri/src/services/mod.rs`)
- Tauri Commands → Strategy Management: handles (evidence: `src-tauri/src/commands/mod.rs`)
- Tauri Commands → Paper Trading: handles (evidence: `src-tauri/src/commands/mod.rs`)
- Trading Services → Historical Analysis: implements (evidence: `src-tauri/src/services/mod.rs`)
- Shared App State → SQLite Store: initializes (evidence: `src-tauri/src/state.rs`)
- Shared App State → DuckDB Store: initializes (evidence: `src-tauri/src/state.rs`)
- Shared App State → Credential Security: initializes (evidence: `src-tauri/src/state.rs`)
- Desktop User → Broker Adapters: authenticates broker
