NPL Auction Game
Real-time multiplayer cricket auction with AI bidding opponents
- Next.js 14
- Node.js
- Express
- Socket.io
- PostgreSQL
- Prisma
- Claude API
- Auth.js v5
Cricket auctions are the most exciting part of a league season, but there was no way to actually play one with friends using real Nepal Premier League players. The hard part isn't the UI — it's that an auction is a shared, timed, contested piece of state. Every bid has to be validated against one source of truth, every client has to stay in sync, and the game has to keep moving even when a seat is empty.
Server-authoritative state machine
All auction state lives on the server, not the client. A single state machine owns the entire lifecycle so no client can bid its way into an invalid state.
- Bid validation against current purse, squad limits, and minimum increments
- Timer management with phase transitions driven server-side
- A lucky draw tiebreaker system for contested marquee players
- Supports up to 8 concurrent teams in a single auction room
Real-time sync over WebSockets
Socket.io broadcasts authoritative state transitions to every connected client, so all 8 teams see the same bid, timer, and purse values without polling. The client renders state it receives rather than computing its own.
AI bidding opponents
So a solo player still gets a real auction, I built a bot system with 5 distinct bidding personalities backed by a heuristic decision engine, architected for Anthropic Claude API integration.
- Each personality weighs player quality, purse remaining, and squad needs differently
- Server-side bot runner with abort-signal cancellation so bots stop cleanly mid-round
- Staggered think delays so bots feel like opponents deliberating, not instant reflexes
Real data, calibrated scoring
82 real Nepal Premier League player records are seeded into PostgreSQL via Prisma. A calibrated quality-scoring formula turns raw stats into a value signal, with role-aware stat display so a bowler and a batter are judged on the numbers that actually matter for their role.
Auth without friction
Auth.js v5 handles Google OAuth and email magic links with JWT sessions and persistent user profiles. Because asking someone to sign up before they can try a game is a good way to lose them, guest mode falls back to a localStorage identity and works immediately.
The auction feel
The UI is tuned for the drama of a live auction: stacking bid notifications, a live squad builder, running team purse tracking, and animated overlays across the full flow from the marquee draw through to unsold-player rounds.
Try it yourself
The demo is live and playable solo against the AI bots — no signup needed if you use guest mode.