# theanabioz/crypto architecture

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

- Interactive diagram: https://gitdiagram.com/theanabioz/crypto
- Repository: https://github.com/theanabioz/crypto

## Overview

Crypto is an iOS market-data and analysis app backed by a Python API. The main workflow is market browsing and charting, with screening and indicator exploration as analysis branches: the app requests data from the backend, which serves market/history and computed indicator results. The tree and excerpts support the API, chart caching, indicator calculation, and ClickHouse-read layers; finer backend wiring and several UI interactions are inferred only from module names, so uncertain links are omitted.

Main entry points: [`Crypto/BackendService.swift`](https://github.com/theanabioz/crypto/blob/main/Crypto/BackendService.swift) (Backend client), [`backend/app/api_db.py`](https://github.com/theanabioz/crypto/blob/main/backend/app/api_db.py) (ClickHouse), [`backend/app/api.py`](https://github.com/theanabioz/crypto/blob/main/backend/app/api.py) (HTTP API), [`backend/app/api_hub.py`](https://github.com/theanabioz/crypto/blob/main/backend/app/api_hub.py) (API hub)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ios["iOS App"]
  node_app["App shell<br/>[CryptoApp.swift]"]
  node_markets["Market browser<br/>[ContentView.swift]"]
  node_details["Coin details"]
  node_charts["Chart repository"]
  node_screenui["Screener<br/>[ScreenerView.swift]"]
  node_conditions["Condition builder"]
  node_explorer["Indicator explorer"]
  node_alerts["Alerts<br/>[AlertsView.swift]"]
  node_settings["Settings<br/>[SettingsView.swift]"]
  node_client["Backend client"]
end

subgraph group_api["Backend API"]
  node_api["HTTP API<br/>[api.py]"]
  node_hub["API hub<br/>[api_hub.py]"]
  node_ws["Market WebSocket<br/>[websocket.py]"]
end

subgraph group_analysis["Market Analysis"]
  node_screen["Screen evaluation<br/>[batch_screen.py]"]
  node_indicators["Indicator engines"]
  node_catalog["Indicator catalog"]
end

subgraph group_data["Market Data"]
  node_ingest["Market ingestion<br/>[ingest.py]"]
  node_history["History and rollups<br/>[aggregate.py]"]
  node_store[("ClickHouse<br/>[api_db.py]")]
end

node_user(("Investor"))
node_exchange(("Market data source"))

node_user -->|"opens"| node_app
node_app -->|"shows"| node_markets
node_user -->|"browses"| node_markets
node_markets -->|"requests markets"| node_client
node_details -->|"requests details"| node_client
node_charts -->|"fetches charts"| node_client
node_screenui -->|"configures"| node_conditions
node_conditions -->|"submits screen"| node_client
node_screenui -->|"requests results"| node_client
node_explorer -->|"requests indicators"| node_client
node_explorer -->|"uses catalog"| node_catalog
node_alerts -.->|"syncs alerts"| node_client
node_settings -.->|"configures access"| node_client
node_client -->|"HTTP requests"| node_api
node_client -->|"market stream"| node_ws
node_api -->|"dispatches"| node_hub
node_hub -->|"serves calculations"| node_indicators
node_hub -->|"runs screens"| node_screen
node_indicators -->|"reads and persists"| node_store
node_screen -->|"reads market data"| node_store
node_api -->|"reads market data"| node_store
node_ingest -->|"writes candles"| node_store
node_ingest -.->|"fetches candles"| node_exchange
node_history -->|"builds rollups"| node_store
node_ws -->|"reads market state"| node_store

click node_app "https://github.com/theanabioz/crypto/blob/main/Crypto/CryptoApp.swift"
click node_markets "https://github.com/theanabioz/crypto/blob/main/Crypto/ContentView.swift"
click node_details "https://github.com/theanabioz/crypto/blob/main/Crypto/CoinDetailView.swift"
click node_charts "https://github.com/theanabioz/crypto/blob/main/Crypto/ChartRepository.swift"
click node_screenui "https://github.com/theanabioz/crypto/blob/main/Crypto/ScreenerView.swift"
click node_conditions "https://github.com/theanabioz/crypto/blob/main/Crypto/ConditionBuilderView.swift"
click node_explorer "https://github.com/theanabioz/crypto/blob/main/Crypto/IndicatorExplorerView.swift"
click node_alerts "https://github.com/theanabioz/crypto/blob/main/Crypto/AlertsView.swift"
click node_settings "https://github.com/theanabioz/crypto/blob/main/Crypto/SettingsView.swift"
click node_client "https://github.com/theanabioz/crypto/blob/main/Crypto/BackendService.swift"
click node_api "https://github.com/theanabioz/crypto/blob/main/backend/app/api.py"
click node_hub "https://github.com/theanabioz/crypto/blob/main/backend/app/api_hub.py"
click node_ws "https://github.com/theanabioz/crypto/blob/main/backend/app/websocket.py"
click node_screen "https://github.com/theanabioz/crypto/blob/main/backend/app/batch_screen.py"
click node_indicators "https://github.com/theanabioz/crypto/tree/main/backend/app"
click node_catalog "https://github.com/theanabioz/crypto/blob/main/Crypto/IndicatorCatalog.swift"
click node_ingest "https://github.com/theanabioz/crypto/blob/main/backend/app/ingest.py"
click node_history "https://github.com/theanabioz/crypto/blob/main/backend/app/aggregate.py"
click node_store "https://github.com/theanabioz/crypto/blob/main/backend/app/api_db.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_app,node_markets,node_details,node_charts,node_screenui,node_conditions,node_explorer,node_alerts,node_settings,node_client toneBlue
class node_api,node_hub,node_ws toneAmber
class node_screen,node_indicators,node_catalog toneMint
class node_ingest,node_history,node_store toneRose
class node_user,node_exchange toneIndigo
```

## Components

### iOS App

- [App shell](https://github.com/theanabioz/crypto/blob/main/Crypto/CryptoApp.swift): `Crypto/CryptoApp.swift`
- [Market browser](https://github.com/theanabioz/crypto/blob/main/Crypto/ContentView.swift): `Crypto/ContentView.swift`
- [Coin details](https://github.com/theanabioz/crypto/blob/main/Crypto/CoinDetailView.swift): `Crypto/CoinDetailView.swift`
- [Chart repository](https://github.com/theanabioz/crypto/blob/main/Crypto/ChartRepository.swift): `Crypto/ChartRepository.swift`
- [Screener](https://github.com/theanabioz/crypto/blob/main/Crypto/ScreenerView.swift): `Crypto/ScreenerView.swift`
- [Condition builder](https://github.com/theanabioz/crypto/blob/main/Crypto/ConditionBuilderView.swift): `Crypto/ConditionBuilderView.swift`
- [Indicator explorer](https://github.com/theanabioz/crypto/blob/main/Crypto/IndicatorExplorerView.swift): `Crypto/IndicatorExplorerView.swift`
- [Alerts](https://github.com/theanabioz/crypto/blob/main/Crypto/AlertsView.swift): `Crypto/AlertsView.swift`
- [Settings](https://github.com/theanabioz/crypto/blob/main/Crypto/SettingsView.swift): `Crypto/SettingsView.swift`
- [Backend client](https://github.com/theanabioz/crypto/blob/main/Crypto/BackendService.swift): `Crypto/BackendService.swift`

### Backend API

- [HTTP API](https://github.com/theanabioz/crypto/blob/main/backend/app/api.py): `backend/app/api.py`
- [API hub](https://github.com/theanabioz/crypto/blob/main/backend/app/api_hub.py): `backend/app/api_hub.py`
- [Market WebSocket](https://github.com/theanabioz/crypto/blob/main/backend/app/websocket.py): `backend/app/websocket.py`

### Market Analysis

- [Screen evaluation](https://github.com/theanabioz/crypto/blob/main/backend/app/batch_screen.py): `backend/app/batch_screen.py`
- [Indicator engines](https://github.com/theanabioz/crypto/tree/main/backend/app): `backend/app`
- [Indicator catalog](https://github.com/theanabioz/crypto/blob/main/Crypto/IndicatorCatalog.swift): `Crypto/IndicatorCatalog.swift`

### Market Data

- [Market ingestion](https://github.com/theanabioz/crypto/blob/main/backend/app/ingest.py): `backend/app/ingest.py`
- [History and rollups](https://github.com/theanabioz/crypto/blob/main/backend/app/aggregate.py): `backend/app/aggregate.py`
- [ClickHouse](https://github.com/theanabioz/crypto/blob/main/backend/app/api_db.py): `backend/app/api_db.py`

### Other components

- **Investor**
- **Market data source**

## Connections

- Investor → App shell: opens
- App shell → Market browser: shows
- Investor → Market browser: browses
- Market browser → Backend client: requests markets
- Coin details → Backend client: requests details
- Chart repository → Backend client: fetches charts
- Screener → Condition builder: configures
- Condition builder → Backend client: submits screen
- Screener → Backend client: requests results
- Indicator explorer → Backend client: requests indicators
- Indicator explorer → Indicator catalog: uses catalog
- Alerts → Backend client: syncs alerts
- Settings → Backend client: configures access
- Backend client → HTTP API: HTTP requests
- Backend client → Market WebSocket: market stream
- HTTP API → API hub: dispatches
- API hub → Indicator engines: serves calculations
- API hub → Screen evaluation: runs screens
- Indicator engines → ClickHouse: reads and persists
- Screen evaluation → ClickHouse: reads market data
- HTTP API → ClickHouse: reads market data
- Market ingestion → ClickHouse: writes candles
- Market ingestion → Market data source: fetches candles
- History and rollups → ClickHouse: builds rollups
- Market WebSocket → ClickHouse: reads market state
