# thaihoandev/crypto-evaluator-api architecture

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

- Interactive diagram: https://gitdiagram.com/thaihoandev/crypto-evaluator-api
- Repository: https://github.com/thaihoandev/crypto-evaluator-api

## Overview

Crypto Trade Evaluator is an ASP.NET API for managing trade setups and producing market-analysis, risk, scoring, and probability estimates. The principal workflow is: a client creates a setup, requests its evaluation, and retrieves or closes it; a separate analysis endpoint builds Long/Short proposals from market candles. Prediction outcomes can be backtested, while real-time ticker endpoints expose Binance stream data. The sampled handlers establish several dispatches and calculations; broader trade-command wiring is represented only where the README documents the capability. PostgreSQL and Redis are documented stores, but their runtime wiring is not fully sampled.

Main entry points: [`src/CryptoEvaluator.API/Controllers/TradesController.cs`](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.API/Controllers/TradesController.cs) (Trade endpoints), [`src/CryptoEvaluator.Application/MarketAnalysis/Queries/AnalyzeMarket/AnalyzeMarketQuery.cs`](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/MarketAnalysis/Queries/AnalyzeMarket/AnalyzeMarketQuery.cs) (Analyze market), [`src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceMarketDataProvider.cs`](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceMarketDataProvider.cs) (Market provider), [`src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceTickerWebSocketService.cs`](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceTickerWebSocketService.cs) (Ticker WebSocket)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_trades_api["Trade endpoints"]
  node_stream_api["Ticker endpoints"]
end

subgraph group_application["Trade Analysis"]
  node_setup["Manage setups"]
  node_evaluate["Evaluate trade"]
  node_analyze["Analyze market"]
  node_indicators["Indicators<br/>[IndicatorEngine.cs]"]
  node_risk["Risk calculation<br/>[RiskCalculator.cs]"]
  node_scoring["Setup scoring"]
  node_warnings["Trade warnings<br/>[WarningEngine.cs]"]
  node_prediction["Trade prediction"]
  node_prediction_read["Read prediction"]
  node_backtest["Prediction backtests"]
  node_walkforward["Walk-forward test"]
end

subgraph group_market["Market Data"]
  node_market_provider["Market provider"]
  node_binance_ws["Ticker WebSocket"]
  node_ticker_store["Local ticker store"]
end

subgraph group_persistence["Persistence"]
  node_repositories["Trade repositories<br/>[TradeRepository.cs]"]
  node_prediction_repository["Prediction repository"]
  node_database[("PostgreSQL<br/>[AppDbContext.cs]")]
end

node_client(("API client"))
node_binance(("Binance Futures"))
node_redis[("Redis cache")]

node_client -->|"requests"| node_trades_api
node_client -->|"requests"| node_stream_api
node_trades_api -->|"dispatches commands"| node_setup
node_trades_api -->|"dispatches command"| node_evaluate
node_trades_api -->|"dispatches query"| node_analyze
node_trades_api -->|"dispatches query"| node_prediction_read
node_trades_api -->|"dispatches query"| node_backtest
node_trades_api -->|"runs backtest"| node_walkforward
node_trades_api -->|"requests candles"| node_market_provider
node_analyze -->|"fetches candles"| node_market_provider
node_analyze -->|"calculates indicators"| node_indicators
node_analyze -->|"calculates risk"| node_risk
node_analyze -->|"scores setups"| node_scoring
node_analyze -->|"predicts outcomes"| node_prediction
node_analyze -->|"generates warnings"| node_warnings
node_prediction_read -->|"reads prediction"| node_prediction_repository
node_backtest -->|"loads outcomes"| node_prediction_repository
node_walkforward -->|"requests candles"| node_market_provider
node_market_provider -->|"requests market data"| node_binance
node_binance_ws -->|"receives ticker stream"| node_binance
node_binance_ws -->|"updates tickers"| node_ticker_store
node_binance_ws -->|"writes ticker cache"| node_redis
node_stream_api -->|"reads ticker"| node_ticker_store
node_stream_api -->|"fallback reads"| node_redis
node_repositories -->|"reads and writes"| node_database
node_prediction_repository -->|"reads and writes"| node_database

click node_trades_api "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.API/Controllers/TradesController.cs"
click node_stream_api "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.API/Controllers/MarketStreamController.cs"
click node_setup "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Trades/Commands/CreateTrade/CreateTradeCommand.cs"
click node_evaluate "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Evaluations/Commands/EvaluateTrade/EvaluateTradeCommand.cs"
click node_analyze "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/MarketAnalysis/Queries/AnalyzeMarket/AnalyzeMarketQuery.cs"
click node_indicators "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Indicators/IndicatorEngine.cs"
click node_risk "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Risk/RiskCalculator.cs"
click node_scoring "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Scoring/TradeScoreCalculator.cs"
click node_warnings "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Warnings/WarningEngine.cs"
click node_prediction "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Prediction/MonteCarloGbmPredictor.cs"
click node_prediction_read "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Predictions/Queries/GetPrediction/GetPredictionQuery.cs"
click node_backtest "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Predictions/Queries/GetPredictionBacktest/GetPredictionBacktestQuery.cs"
click node_walkforward "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Predictions/WalkForwardBacktestEngine.cs"
click node_market_provider "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceMarketDataProvider.cs"
click node_binance_ws "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceTickerWebSocketService.cs"
click node_ticker_store "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/MarketData/Binance/RealtimeTickerStore.cs"
click node_repositories "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/Persistence/Repositories/TradeRepository.cs"
click node_prediction_repository "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/Persistence/Repositories/TradePredictionRepository.cs"
click node_database "https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/Persistence/AppDbContext.cs"

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_trades_api,node_stream_api,node_client toneBlue
class node_setup,node_evaluate,node_analyze,node_indicators,node_risk,node_scoring,node_warnings,node_prediction,node_prediction_read,node_backtest,node_walkforward,node_redis toneAmber
class node_market_provider,node_binance_ws,node_ticker_store toneMint
class node_repositories,node_prediction_repository,node_database toneRose
class node_binance toneIndigo
```

## Components

### HTTP API

- [Trade endpoints](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.API/Controllers/TradesController.cs): `src/CryptoEvaluator.API/Controllers/TradesController.cs`
- [Ticker endpoints](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.API/Controllers/MarketStreamController.cs): `src/CryptoEvaluator.API/Controllers/MarketStreamController.cs`

### Trade Analysis

- [Manage setups](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Trades/Commands/CreateTrade/CreateTradeCommand.cs): `src/CryptoEvaluator.Application/Trades/Commands/CreateTrade/CreateTradeCommand.cs`
- [Evaluate trade](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Evaluations/Commands/EvaluateTrade/EvaluateTradeCommand.cs): `src/CryptoEvaluator.Application/Evaluations/Commands/EvaluateTrade/EvaluateTradeCommand.cs`
- [Analyze market](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/MarketAnalysis/Queries/AnalyzeMarket/AnalyzeMarketQuery.cs): `src/CryptoEvaluator.Application/MarketAnalysis/Queries/AnalyzeMarket/AnalyzeMarketQuery.cs`
- [Indicators](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Indicators/IndicatorEngine.cs): `src/CryptoEvaluator.Application/Indicators/IndicatorEngine.cs`
- [Risk calculation](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Risk/RiskCalculator.cs): `src/CryptoEvaluator.Application/Risk/RiskCalculator.cs`
- [Setup scoring](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Scoring/TradeScoreCalculator.cs): `src/CryptoEvaluator.Application/Scoring/TradeScoreCalculator.cs`
- [Trade warnings](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Warnings/WarningEngine.cs): `src/CryptoEvaluator.Application/Warnings/WarningEngine.cs`
- [Trade prediction](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Prediction/MonteCarloGbmPredictor.cs): `src/CryptoEvaluator.Application/Prediction/MonteCarloGbmPredictor.cs`
- [Read prediction](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Predictions/Queries/GetPrediction/GetPredictionQuery.cs): `src/CryptoEvaluator.Application/Predictions/Queries/GetPrediction/GetPredictionQuery.cs`
- [Prediction backtests](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Predictions/Queries/GetPredictionBacktest/GetPredictionBacktestQuery.cs): `src/CryptoEvaluator.Application/Predictions/Queries/GetPredictionBacktest/GetPredictionBacktestQuery.cs`
- [Walk-forward test](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Application/Predictions/WalkForwardBacktestEngine.cs): `src/CryptoEvaluator.Application/Predictions/WalkForwardBacktestEngine.cs`

### Market Data

- [Market provider](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceMarketDataProvider.cs): `src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceMarketDataProvider.cs`
- [Ticker WebSocket](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceTickerWebSocketService.cs): `src/CryptoEvaluator.Infrastructure/MarketData/Binance/BinanceTickerWebSocketService.cs`
- [Local ticker store](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/MarketData/Binance/RealtimeTickerStore.cs): `src/CryptoEvaluator.Infrastructure/MarketData/Binance/RealtimeTickerStore.cs`

### Persistence

- [Trade repositories](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/Persistence/Repositories/TradeRepository.cs): `src/CryptoEvaluator.Infrastructure/Persistence/Repositories/TradeRepository.cs`
- [Prediction repository](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/Persistence/Repositories/TradePredictionRepository.cs): `src/CryptoEvaluator.Infrastructure/Persistence/Repositories/TradePredictionRepository.cs`
- [PostgreSQL](https://github.com/thaihoandev/crypto-evaluator-api/blob/main/src/CryptoEvaluator.Infrastructure/Persistence/AppDbContext.cs): `src/CryptoEvaluator.Infrastructure/Persistence/AppDbContext.cs`

### Other components

- **API client**
- **Binance Futures**
- **Redis cache**

## Connections

- API client → Trade endpoints: requests
- API client → Ticker endpoints: requests
- Trade endpoints → Manage setups: dispatches commands
- Trade endpoints → Evaluate trade: dispatches command
- Trade endpoints → Analyze market: dispatches query
- Trade endpoints → Read prediction: dispatches query
- Trade endpoints → Prediction backtests: dispatches query
- Trade endpoints → Walk-forward test: runs backtest
- Trade endpoints → Market provider: requests candles
- Analyze market → Market provider: fetches candles
- Analyze market → Indicators: calculates indicators
- Analyze market → Risk calculation: calculates risk
- Analyze market → Setup scoring: scores setups
- Analyze market → Trade prediction: predicts outcomes
- Analyze market → Trade warnings: generates warnings
- Read prediction → Prediction repository: reads prediction
- Prediction backtests → Prediction repository: loads outcomes
- Walk-forward test → Market provider: requests candles
- Market provider → Binance Futures: requests market data
- Ticker WebSocket → Binance Futures: receives ticker stream
- Ticker WebSocket → Local ticker store: updates tickers
- Ticker WebSocket → Redis cache: writes ticker cache
- Ticker endpoints → Local ticker store: reads ticker
- Ticker endpoints → Redis cache: fallback reads
- Trade repositories → PostgreSQL: reads and writes
- Prediction repository → PostgreSQL: reads and writes
