Real-time coding battle orchestrator. Manages challenge lifecycle (create, join, submit, judge), WebSocket connections for live updates, and leaderboard synchronization.
Browser ↔ WebSocket (wss) ← ChallengeService (:50052)
gRPC calls → CodeExecutionEngine (code judge)
gRPC calls → RedisBoard (leaderboard)
PostgreSQL (challenge state)
- Go + gRPC
- WebSockets (gorilla/websocket) for real-time battle state
- PostgreSQL for challenge persistence
- Redis for leaderboard
- ants goroutine pool for concurrent match handling
- JWT for player auth within challenges
Create → Wait → Start → Battle → Judge → Complete
│ │ │ │ │ │
│ players │ code │ result │
│ join │ submit │ update │
│ │ │ leaderboard│
| Method | Description |
|---|---|
CreateChallenge |
Create new battle room |
JoinChallenge |
Player joins a room |
SubmitCode |
Player submits code for judging |
GetChallengeState |
Current state of a challenge |
ListActiveChallenges |
All active battles |
GetResults |
Final results of a completed challenge |
export DB_HOST=localhost DB_PORT=5432 DB_USER=zenx DB_PASS=zenx123
export CODE_ENGINE_ADDR=localhost:50054
export REDIS_ADDR=localhost:6379
go run cmd/main.go
# → gRPC + WebSocket on :50052docker build -t zenxbattle-challenge .
docker run -p 50052:50052 zenxbattle-challenge- CodeExecutionEngine — sandboxed code judge
- RedisBoard — leaderboard engine
- Frontend — battle UI
- ApiGateway — REST proxy
- CommonProto — protobuf definitions
See lifecycle.md for detailed challenge state machine documentation.