Service Overview
backend-api
Go 1.26+Core trading engine, API, domain logic, persistence, and AI orchestration
ccxt-service
Bun + CCXTExchange bridge for unified access to 100+ exchanges
telegram-service
Bun + grammYTelegram bot and notification delivery
backend-api (Go)
The primary runtime service containing all trading logic, arbitrage engines, AI agents, and API endpoints.Structure
Core Services
| Service | File | Responsibility |
|---|---|---|
| CollectorService | collector_service.go | Market data ingestion from exchanges |
| SignalProcessor | signal_processor.go | Signal pipeline coordination |
| ArbitrageService | arbitrage_service.go | Spot arbitrage opportunity detection |
| FuturesArbitrageService | futures_arbitrage_service.go | Funding rate arbitrage engine |
| QuestEngine | quest_engine.go | Autonomous quest scheduling |
| AnalystAgent | analyst_agent.go | Market analysis AI agent |
| TraderAgent | trader_agent.go | Trading decision AI agent |
| RiskManagerAgent | risk/risk_manager_agent.go | Risk assessment AI agent |
| NotificationService | notification.go | Telegram notification dispatch |
See
services/backend-api/AGENTS.md for detailed service documentation.Startup Flow
The backend wiring is explicit constructor injection incmd/server/main.go:
API Routes
Registered ininternal/api/routes.go:
| Endpoint | Handler | Purpose |
|---|---|---|
GET /health | HealthHandler | Service health check |
GET /api/market/* | MarketHandler | Market data queries |
GET /api/arbitrage/opportunities | ArbitrageHandler | Spot arbitrage opportunities |
GET /api/futures/opportunities | FuturesArbitrageHandler | Funding rate arbitrage |
GET /api/analysis/signals | SignalHandler | Trading signals |
POST /api/autonomous/begin | AutonomousHandler | Start autonomous mode |
POST /api/autonomous/pause | AutonomousHandler | Pause autonomous mode |
GET /api/quests | QuestHandler | Quest status and progress |
See API reference at
/health for complete endpoint documentation.ccxt-service (Bun)
Bun + TypeScript service providing a unified HTTP/gRPC interface to 100+ exchanges via the CCXT library.Structure
Responsibilities
Market Data
- Ticker retrieval
- Order book snapshots
- Historical OHLCV data
- Funding rate queries
Order Execution
- Place orders (market, limit, stop)
- Cancel orders
- Query order status
- Fetch balances and positions
HTTP Endpoints
gRPC Interface
Defined inprotos/ccxt_service.proto:
Configuration
telegram-service (Bun)
Bun + TypeScript service using grammY framework for Telegram bot commands and notification delivery.Structure
Bot Commands
| Command | Description |
|---|---|
/start | Initialize bot and bind operator profile |
/status | Show autonomous mode status and active quests |
/begin | Start autonomous trading mode |
/pause | Pause autonomous trading mode |
/balance | Show wallet balances |
/positions | Show open positions |
/performance | Show trading performance summary |
/doctor | Run diagnostic health checks |
/liquidate | Liquidate specific position |
/liquidate_all | Emergency liquidate all positions |
Notification Types
The service delivers notifications for:- Quest Updates: Quest start, progress, completion
- Trading Events: Order fills, position changes, PnL updates
- Risk Alerts: Stop-loss triggers, drawdown warnings, emergency halts
- System Events: Service starts, health degradation, errors
HTTP Endpoints
gRPC Interface
Configuration
Service Communication
Communication Patterns
Protocol Selection
| Communication | Protocol | Reason |
|---|---|---|
| Backend → CCXT | HTTP/REST | Request-response pattern, retry logic |
| Backend → Telegram | gRPC | Low latency, streaming, type safety |
| Telegram → Backend | HTTP/REST | Simple webhook integration |
| Services → Redis | Redis Protocol | Distributed locks, PubSub |
Health Checks
All services expose health check endpoints:Backend API
CCXT Service
Telegram Service
Health checks validate:
- Service process is running
- Database connectivity
- Redis connectivity
- Exchange API accessibility
- Telegram API accessibility
Next Steps
Data Flow
See how data flows through services
Quest Engine
Autonomous scheduling architecture