Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CasinoBit - Complete Casino Platform

A production-ready, provably fair casino platform built with modern technologies, featuring 20+ games, multi-currency support, advanced betting strategies, and real-time multiplayer games.

๐ŸŽฎ Features

Core Features

  • โœ… 20+ Casino Games - Dice, Limbo, Crash, Mines, Plinko, Roulette, Keno, Wheel, and more
  • โœ… Provably Fair System - Stake-style RNG with HMAC-SHA256
  • โœ… Multi-Currency Wallet - BTC, ETH, LTC, USDT, USD, EUR
  • โœ… Manual & Auto Betting - Advanced autobet with stop conditions
  • โœ… Strategy Engine - Martingale, Paroli, D'Alembert, custom scripts
  • โœ… Jackpot System - Configurable per game/currency
  • โœ… Contest System - Daily/weekly competitions
  • โœ… Leaderboards - High rollers, big wins, lucky wins
  • โœ… VIP & Rakeback - Reward loyal players
  • โœ… Real-time Multiplayer - Crash, Trenball with Socket.IO
  • โœ… Fairness Verification - Complete verifier page
  • โœ… Admin Panel - Manage games, jackpots, contests

Technical Features

  • ๐Ÿ” JWT Authentication with RBAC
  • ๐Ÿ“Š PostgreSQL + Prisma ORM
  • ๐Ÿš€ Redis + BullMQ for workers
  • ๐Ÿ”Œ Socket.IO for real-time games
  • ๐ŸŽจ Retro modern UI with Tailwind
  • ๐Ÿ“ฑ Responsive design
  • ๐ŸŒ Monorepo architecture

๐Ÿ—๏ธ Architecture

casino-platform/
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ backend/          # Fastify API + WebSocket server
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ routes/   # API endpoints
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ services/ # Business logic
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ workers/  # Background jobs
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ websocket/# Real-time games
โ”‚   โ”‚   โ””โ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ frontend/         # Next.js application
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ app/      # Pages
โ”‚       โ”‚   โ”œโ”€โ”€ components/# UI components
โ”‚       โ”‚   โ”œโ”€โ”€ store/    # Zustand state
โ”‚       โ”‚   โ””โ”€โ”€ lib/      # API client
โ”‚       โ””โ”€โ”€ package.json
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ database/         # Prisma schemas
โ”‚   โ”œโ”€โ”€ game-engine/      # Game logic
โ”‚   โ”œโ”€โ”€ fairness/         # RNG system
โ”‚   โ””โ”€โ”€ shared/           # Shared types
โ””โ”€โ”€ docs/                 # Documentation

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+
  • Redis 6+
  • npm or yarn

Installation

  1. Clone the repository
git clone <repository-url>
cd casino-platform
  1. Install dependencies
npm install
  1. Setup environment variables

Create .env files in both apps/backend and apps/frontend:

Backend .env:

DATABASE_URL="postgresql://user:password@localhost:5432/casinobit"
REDIS_HOST="localhost"
REDIS_PORT="6379"
JWT_SECRET="your-super-secret-jwt-key-change-this"
PORT="3001"
FRONTEND_URL="http://localhost:3000"

Frontend .env.local:

NEXT_PUBLIC_API_URL="http://localhost:3001"
  1. Setup database
npm run db:generate
npm run db:push
  1. Start development servers
npm run dev

This will start:

๐ŸŽฒ Game Implementations

Implemented Games

  1. Dice - Roll over/under with ultimate mode
  2. Limbo - Exponential multiplier prediction
  3. Mines - Grid-based mine sweeper
  4. Plinko - Ball drop with risk levels
  5. Crash - Multiplayer crash game
  6. Roulette - European roulette with presets
  7. Keno - Number selection game
  8. Wheel - Spin wheel with segments
  9. Trenball - Color betting multiplayer

Game Features

Each game includes:

  • Provably fair RNG
  • Configurable house edge
  • Min/max bet limits
  • Jackpot conditions
  • Demo mode
  • Auto-bet support
  • Strategy compatibility

๐Ÿ” Provably Fair System

How It Works

  1. Server Seed - Generated and hashed before betting
  2. Client Seed - User-provided or auto-generated
  3. Nonce - Increments with each bet
  4. Cursor - For generating unlimited bytes

RNG Process

// Generate HMAC
const hmac = HMAC_SHA256(serverSeed, `${clientSeed}:${nonce}:${cursor}`);

// Convert to bytes
const bytes = Buffer.from(hmac, 'hex');

// Generate floats (0-1)
const float = bytes.readUInt32BE(0) / 0x100000000;

// Map to game events
const result = mapToGameEvent(float);

Verification

Users can verify any bet by:

  1. Viewing the seed pair used
  2. Checking the server seed hash
  3. Rotating seeds to reveal server seed
  4. Using the verifier page to recalculate

๐Ÿ“Š Database Schema

Key Models

  • User - Authentication and profile
  • Wallet - Multi-currency balances
  • SeedPair - Provably fair seeds
  • Bet - Bet history and results
  • Jackpot - Jackpot pools
  • Contest - Competition data
  • Strategy - Betting strategies

๐ŸŽฏ API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login
  • GET /api/auth/me - Get current user

Betting

  • POST /api/bet/place - Place a bet
  • GET /api/bet/history - Get bet history
  • POST /api/bet/autobet/start - Start autobet
  • POST /api/bet/autobet/stop - Stop autobet

Wallet

  • GET /api/wallet - Get all wallets
  • POST /api/wallet/add - Add balance

Seeds

  • GET /api/seed/active - Get active seed pair
  • POST /api/seed/client-seed - Update client seed
  • POST /api/seed/rotate - Rotate seed pair

Games

  • GET /api/game - List all games
  • POST /api/game/:gameType/favorite - Toggle favorite

Strategies

  • GET /api/strategy/defaults - Get default strategies
  • POST /api/strategy - Create strategy
  • GET /api/strategy/public - Browse public strategies

Leaderboards

  • GET /api/leaderboard/all-bets - Recent bets
  • GET /api/leaderboard/high-rollers - Highest bets
  • GET /api/leaderboard/big-wins - Biggest wins
  • GET /api/leaderboard/lucky-wins - Highest multipliers

๐ŸŽจ Frontend Components

Pages

  • / - Homepage with game grid
  • /game/[gameType] - Individual game pages
  • /wallet - Wallet management
  • /history - Bet history
  • /leaderboard - Leaderboards
  • /contests - Active contests
  • /fairness - Fairness explanation
  • /verifier - Bet verifier
  • /admin - Admin panel

Components

  • BetControls - Amount input, presets, auto-bet
  • FairnessModal - Seed management
  • LiveStats - Real-time statistics
  • GameCanvas - Game visualization
  • Leaderboard - Bet listings

๐Ÿ”ง Configuration

Game Configuration

Admins can configure per game:

  • House edge percentage
  • Min/max bet per currency
  • Max win per currency
  • Jackpot conditions
  • Enable/disable game

Jackpot Configuration

  • Per game or global
  • Per currency or all currencies
  • Minimum amount threshold
  • Contribution percentage
  • Win conditions

Contest Configuration

  • Duration (daily/weekly)
  • Prize pool
  • Entry requirements
  • Ranking criteria
  • Prize distribution

๐Ÿš€ Deployment

Production Build

# Build all packages
npm run build

# Start production servers
npm run start

Environment Setup

  1. Setup PostgreSQL database
  2. Setup Redis instance
  3. Configure environment variables
  4. Run database migrations
  5. Start backend and frontend

Recommended Stack

  • Hosting: AWS, DigitalOcean, or Vercel
  • Database: AWS RDS or managed PostgreSQL
  • Redis: AWS ElastiCache or Redis Cloud
  • CDN: CloudFlare
  • Monitoring: Sentry, DataDog

๐Ÿงช Testing

# Run tests (when implemented)
npm test

# Run linting
npm run lint

๐Ÿ“ Default Strategies

Martingale

Double bet after loss, reset after win

Delayed Martingale

Double bet after 3 consecutive losses

Reverse Martingale

Double bet after win, reset after loss

Paroli

Double bet after win, reset after 3 wins

D'Alembert

Increase by 10% after loss, decrease by 10% after win

๐ŸŽฎ Multiplayer Games

Crash

  • Real-time multiplier growth
  • Auto cashout support
  • Round history
  • Player list

Trenball

  • Bet on crash/red/green/moon
  • Round-based gameplay
  • Color statistics

๐Ÿ” Security Features

  • JWT authentication
  • Password hashing with bcrypt
  • CORS protection
  • Rate limiting (recommended)
  • Input validation with Zod
  • SQL injection protection (Prisma)
  • XSS protection

๐Ÿ“ˆ Performance

  • Redis caching
  • Database indexing
  • Connection pooling
  • Worker queues for heavy tasks
  • Optimized queries

๐ŸŽจ Theme Customization

Colors are defined in:

  • packages/shared/constants.ts
  • apps/frontend/tailwind.config.js
  • apps/frontend/src/styles/globals.css

๐Ÿ“š Additional Documentation

๐Ÿค Contributing

  1. Fork the repository
  2. Create feature branch
  3. Commit changes
  4. Push to branch
  5. Open pull request

๐Ÿ“„ License

MIT License - see LICENSE file

๐Ÿ†˜ Support

For issues and questions:

  • GitHub Issues
  • Documentation
  • Community Discord

๐ŸŽฏ Roadmap

  • More games (Blackjack, HiLo, Tower, etc.)
  • Mobile app
  • Live dealer games
  • Sports betting
  • NFT integration
  • Tournament system
  • Affiliate program
  • Multi-language support

Built with โค๏ธ using Node.js, TypeScript, Next.js, and PostgreSQL

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages