Skip to Content
BackendOverview

Backend Service Overview

BattlesBit is a competitive trading game platform where players use real money to enter trading challenges and compete against each other using virtual balance to maximize profits. The winner takes the prize pool.

Core Concept

Real Money (Entry Fee) -> Virtual Trading Balance -> Compete -> Winner Takes Prize

How It Works

  1. Entry: Players pay a real entry fee from their wallet to join a game/challenge
  2. Virtual Balance: Each player receives a virtual trading balance (e.g., $100 USDT)
  3. Trading: Players open positions using real-time market data (Binance)
  4. Competition: Players compete to achieve the highest profit during the match duration
  5. Settlement: Winner receives the prize pool + rewards + XP

Tech Stack

ComponentTechnology
LanguageGo
DatabasePostgreSQL (via Ent ORM)
APIGraphQL (gqlgen)
MessagingNATS JetStream
WorkflowsTemporal
Market DataBinance WebSocket
BlockchainSolana (HD Wallet)
NotificationsFirebase + Email

Key Modules

Trading Module

  • Position management (open, close, cancel)
  • Real-time PnL calculation
  • Liquidation engine
  • Market/Limit orders
  • Stop Loss & Take Profit

Challenge Module

  • Game definitions with rules
  • Matchmaking system
  • Match lifecycle management
  • Ranking calculation
  • Reward distribution

Wallet Module

  • Solana HD wallet integration
  • Deposit/Withdraw
  • Transaction history
  • Balance management

Achievement System

  • Rule-based achievements
  • Progress tracking
  • Temporal workflows

Notification System

  • In-app real-time (NATS)
  • Push notifications (Firebase)
  • Email (OTP)

Services Architecture

cmd/ ├── web # GraphQL API server ├── arena # Position calculation worker ├── market # Market data streaming ├── matcher # Matchmaking service ├── achievement # Achievement processor └── notifications # Notification worker

Current Progress

Overall: ~55% Complete (adjusted for V1 scope)

See Feature Tracking for detailed status.

Last updated on