# kryptccgit/krytrader architecture

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

- Interactive diagram: https://gitdiagram.com/kryptccgit/krytrader
- Repository: https://github.com/kryptccgit/krytrader

## Overview

Krypt Trader is a local-first desktop app for Kalshi market discovery, analysis, and manual or automated trading. Users configure credentials and strategy in the UI, monitor signals or markets, then review positions and results; automation can submit and reconcile orders. The app bridges React through Electron IPC to a Python backend, with SQLite-backed state and external market feeds. README capabilities include 15-minute crypto, scripts and backtests, terminal trading, cross-venue comparison, standing rules, and remote control. Some feature links are documented rather than source-verified, so those edges are dashed.

Main entry points: [`python/service.py`](https://github.com/kryptccgit/krytrader/blob/main/python/service.py) (Python service), [`python/crypto15m.py`](https://github.com/kryptccgit/krytrader/blob/main/python/crypto15m.py) (15-minute crypto), [`python/crypto15m_trader.py`](https://github.com/kryptccgit/krytrader/blob/main/python/crypto15m_trader.py) (Crypto executor), [`python/trader.py`](https://github.com/kryptccgit/krytrader/blob/main/python/trader.py) (Auto-trader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop shell"]
  node_ui["App UI<br/>[App.tsx]"]
  node_state["UI state"]
  node_ipc["IPC handlers<br/>[ipc.ts]"]
  node_backend["Python service<br/>[service.py]"]
  node_config["Settings and keys<br/>[settings-store.ts]"]
end

subgraph group_trading["Trading engine"]
  node_maintrader["Auto-trader<br/>[trader.py]"]
  node_cryptotrader["Crypto executor"]
  node_kalshi["Kalshi API<br/>[kalshi_api.py]"]
  node_auth["Credentials and signing<br/>[kalshi_auth.py]"]
end

subgraph group_features["Trading features"]
  node_scanner["Whale and momentum scanner<br/>[scanner.py]"]
  node_crypto["15-minute crypto<br/>[crypto15m.py]"]
  node_terminal["Manual terminal<br/>[terminal.py]"]
  node_scripts["Strategy scripts<br/>[script_engine.py]"]
  node_sandbox["Script sandbox<br/>[script_sandbox.py]"]
  node_backtest["Script backtests<br/>[script_backtest.py]"]
  node_remote["Remote control<br/>[remote.py]"]
  node_crossvenue["Cross-venue prices<br/>[crossvenue.py]"]
end

subgraph group_data["Persistence and feeds"]
  node_db[("Local SQLite<br/>[db.py]")]
  node_polymarket["Polymarket feed"]
  node_crypto_feeds["Crypto feeds<br/>[spot_ws.py]"]
  node_kalshi_ws["Kalshi live feed<br/>[kalshi_ws.py]"]
end

node_user(("Trader"))
node_discord(("Discord or Telegram"))

node_user -->|"uses"| node_ui
node_ui -->|"renders"| node_state
node_state -.->|"requests data"| node_ipc
node_ipc -.->|"dispatches"| node_backend
node_ipc -->|"loads settings"| node_config
node_backend -->|"runs"| node_scanner
node_backend -->|"runs"| node_maintrader
node_backend -->|"runs"| node_crypto
node_backend -->|"runs"| node_cryptotrader
node_backend -->|"runs"| node_scripts
node_backend -.->|"serves"| node_terminal
node_backend -.->|"runs"| node_remote
node_backend -.->|"runs"| node_crossvenue
node_maintrader -->|"places orders"| node_kalshi
node_maintrader -->|"reads and writes"| node_db
node_kalshi -->|"signs requests"| node_auth
node_crypto -->|"reads markets"| node_kalshi
node_crypto -->|"reads prices"| node_crypto_feeds
node_crypto -->|"reads quotes"| node_kalshi_ws
node_cryptotrader -->|"uses signals"| node_crypto
node_cryptotrader -->|"places orders"| node_kalshi
node_cryptotrader -->|"reads and writes"| node_db
node_scripts -->|"executes hooks"| node_sandbox
node_scripts -->|"reads and writes"| node_db
node_backtest -->|"runs scripts"| node_sandbox
node_backtest -->|"reads history"| node_db
node_crossvenue -.->|"compares prices"| node_polymarket
node_remote -.->|"connects"| node_discord
node_remote -.->|"requests trades"| node_maintrader

click node_ui "https://github.com/kryptccgit/krytrader/blob/main/src/App.tsx"
click node_state "https://github.com/kryptccgit/krytrader/blob/main/src/state/AppStateProvider.tsx"
click node_ipc "https://github.com/kryptccgit/krytrader/blob/main/electron/ipc.ts"
click node_backend "https://github.com/kryptccgit/krytrader/blob/main/python/service.py"
click node_config "https://github.com/kryptccgit/krytrader/blob/main/electron/system/settings-store.ts"
click node_scanner "https://github.com/kryptccgit/krytrader/blob/main/python/scanner.py"
click node_maintrader "https://github.com/kryptccgit/krytrader/blob/main/python/trader.py"
click node_crypto "https://github.com/kryptccgit/krytrader/blob/main/python/crypto15m.py"
click node_cryptotrader "https://github.com/kryptccgit/krytrader/blob/main/python/crypto15m_trader.py"
click node_terminal "https://github.com/kryptccgit/krytrader/blob/main/python/terminal.py"
click node_scripts "https://github.com/kryptccgit/krytrader/blob/main/python/script_engine.py"
click node_sandbox "https://github.com/kryptccgit/krytrader/blob/main/python/script_sandbox.py"
click node_backtest "https://github.com/kryptccgit/krytrader/blob/main/python/script_backtest.py"
click node_remote "https://github.com/kryptccgit/krytrader/blob/main/python/remote.py"
click node_crossvenue "https://github.com/kryptccgit/krytrader/blob/main/python/crossvenue.py"
click node_kalshi "https://github.com/kryptccgit/krytrader/blob/main/python/kalshi_api.py"
click node_auth "https://github.com/kryptccgit/krytrader/blob/main/python/kalshi_auth.py"
click node_db "https://github.com/kryptccgit/krytrader/blob/main/python/db.py"
click node_polymarket "https://github.com/kryptccgit/krytrader/blob/main/python/polymarket_public.py"
click node_crypto_feeds "https://github.com/kryptccgit/krytrader/blob/main/python/spot_ws.py"
click node_kalshi_ws "https://github.com/kryptccgit/krytrader/blob/main/python/kalshi_ws.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_ui,node_state,node_ipc,node_backend,node_config toneBlue
class node_maintrader,node_cryptotrader,node_kalshi,node_auth toneAmber
class node_scanner,node_crypto,node_terminal,node_scripts,node_sandbox,node_backtest,node_remote,node_crossvenue toneMint
class node_db,node_polymarket,node_crypto_feeds,node_kalshi_ws toneRose
class node_user,node_discord toneIndigo
```

## Components

### Desktop shell

- [App UI](https://github.com/kryptccgit/krytrader/blob/main/src/App.tsx): `src/App.tsx`
- [UI state](https://github.com/kryptccgit/krytrader/blob/main/src/state/AppStateProvider.tsx): `src/state/AppStateProvider.tsx`
- [IPC handlers](https://github.com/kryptccgit/krytrader/blob/main/electron/ipc.ts): `electron/ipc.ts`
- [Python service](https://github.com/kryptccgit/krytrader/blob/main/python/service.py): `python/service.py`
- [Settings and keys](https://github.com/kryptccgit/krytrader/blob/main/electron/system/settings-store.ts): `electron/system/settings-store.ts`

### Trading engine

- [Auto-trader](https://github.com/kryptccgit/krytrader/blob/main/python/trader.py): `python/trader.py`
- [Crypto executor](https://github.com/kryptccgit/krytrader/blob/main/python/crypto15m_trader.py): `python/crypto15m_trader.py`
- [Kalshi API](https://github.com/kryptccgit/krytrader/blob/main/python/kalshi_api.py): `python/kalshi_api.py`
- [Credentials and signing](https://github.com/kryptccgit/krytrader/blob/main/python/kalshi_auth.py): `python/kalshi_auth.py`

### Trading features

- [Whale and momentum scanner](https://github.com/kryptccgit/krytrader/blob/main/python/scanner.py): `python/scanner.py`
- [15-minute crypto](https://github.com/kryptccgit/krytrader/blob/main/python/crypto15m.py): `python/crypto15m.py`
- [Manual terminal](https://github.com/kryptccgit/krytrader/blob/main/python/terminal.py): `python/terminal.py`
- [Strategy scripts](https://github.com/kryptccgit/krytrader/blob/main/python/script_engine.py): `python/script_engine.py`
- [Script sandbox](https://github.com/kryptccgit/krytrader/blob/main/python/script_sandbox.py): `python/script_sandbox.py`
- [Script backtests](https://github.com/kryptccgit/krytrader/blob/main/python/script_backtest.py): `python/script_backtest.py`
- [Remote control](https://github.com/kryptccgit/krytrader/blob/main/python/remote.py): `python/remote.py`
- [Cross-venue prices](https://github.com/kryptccgit/krytrader/blob/main/python/crossvenue.py): `python/crossvenue.py`

### Persistence and feeds

- [Local SQLite](https://github.com/kryptccgit/krytrader/blob/main/python/db.py): `python/db.py`
- [Polymarket feed](https://github.com/kryptccgit/krytrader/blob/main/python/polymarket_public.py): `python/polymarket_public.py`
- [Crypto feeds](https://github.com/kryptccgit/krytrader/blob/main/python/spot_ws.py): `python/spot_ws.py`
- [Kalshi live feed](https://github.com/kryptccgit/krytrader/blob/main/python/kalshi_ws.py): `python/kalshi_ws.py`

### Other components

- **Trader**
- **Discord or Telegram**

## Connections

- Trader → App UI: uses
- App UI → UI state: renders (evidence: `src/App.tsx`)
- UI state → IPC handlers: requests data
- IPC handlers → Python service: dispatches
- IPC handlers → Settings and keys: loads settings (evidence: `electron/ipc.ts`)
- Python service → Whale and momentum scanner: runs (evidence: `python/service.py`)
- Python service → Auto-trader: runs (evidence: `python/service.py`)
- Python service → 15-minute crypto: runs (evidence: `python/service.py`)
- Python service → Crypto executor: runs (evidence: `python/service.py`)
- Python service → Strategy scripts: runs (evidence: `python/service.py`)
- Python service → Manual terminal: serves (evidence: `python/service.py`)
- Python service → Remote control: runs (evidence: `python/service.py`)
- Python service → Cross-venue prices: runs (evidence: `python/service.py`)
- Auto-trader → Kalshi API: places orders (evidence: `python/trader.py`)
- Auto-trader → Local SQLite: reads and writes (evidence: `python/trader.py`)
- Kalshi API → Credentials and signing: signs requests (evidence: `python/kalshi_api.py`)
- 15-minute crypto → Kalshi API: reads markets (evidence: `python/crypto15m.py`)
- 15-minute crypto → Crypto feeds: reads prices (evidence: `python/crypto15m.py`)
- 15-minute crypto → Kalshi live feed: reads quotes (evidence: `python/crypto15m.py`)
- Crypto executor → 15-minute crypto: uses signals (evidence: `python/crypto15m_trader.py`)
- Crypto executor → Kalshi API: places orders (evidence: `python/crypto15m_trader.py`)
- Crypto executor → Local SQLite: reads and writes (evidence: `python/crypto15m_trader.py`)
- Strategy scripts → Script sandbox: executes hooks (evidence: `python/script_engine.py`)
- Strategy scripts → Local SQLite: reads and writes (evidence: `python/script_engine.py`)
- Script backtests → Script sandbox: runs scripts (evidence: `python/script_backtest.py`)
- Script backtests → Local SQLite: reads history (evidence: `python/script_backtest.py`)
- Cross-venue prices → Polymarket feed: compares prices
- Remote control → Discord or Telegram: connects
- Remote control → Auto-trader: requests trades
