A high-performance, provably fair gaming platform featuring advanced 3D hunting simulations, fortune games, and integrated wallet ecosystem. Built with React, Three.js, Node.js, and MongoDB.
Status: ✅ Production-Ready | Last Updated: February 2026
- Quick Start
- Architecture Overview
- Project Structure
- Core Features
- Technology Stack
- Installation & Setup
- Running the Application
- Environment Configuration
- Deployment
- Documentation
- Node.js v18+
- MongoDB (Local or Atlas)
- npm or yarn
# Clone and install all dependencies
git clone <repository-url>
cd game
npm run install-all
# Setup environment variables (see Environment Configuration section)
cp server/.env.example server/.env
cp client/.env.example client/.env
# Start development servers
npm run dev
# Build for production
npm run build
# Start production server
npm start┌─────────────────────────────────────────────────┐
│ Frontend (React + Vite + Three.js) │
│ - Game Rendering (WebGL) │
│ - Real-time UI State (Redux) │
│ - Socket.IO Client (Real-time Events) │
└────────────────────┬────────────────────────────┘
│ WebSocket + REST API
┌────────────────────▼────────────────────────────┐
│ Backend (Node.js + Express 5) │
│ - Game Logic (BirdShootingEngine, SpinEngine) │
│ - Authentication (JWT) │
│ - Financial System (Transaction Ledger) │
│ - Real-time Multiplayer (Socket.IO) │
└────────────────────┬────────────────────────────┘
│
┌────────────────────▼────────────────────────────┐
│ Database (MongoDB + Mongoose) │
│ - User Profiles & Wallets │
│ - Game Sessions & Matches │
│ - Transaction History │
│ - Provably Fair Seeds │
└─────────────────────────────────────────────────┘
- Provably Fair Engine - HMAC-SHA256 verification
- Physics Engine - Cannon-es for ballistics
- 3D Rendering - Three.js with dynamic environments
- Real-time Communication - Socket.IO for live updates
- State Management - Redux Toolkit for UI state
- Authentication - JWT with role-based access control
game/
├── client/ # React Frontend (Vite)
│ ├── src/
│ │ ├── components/
│ │ │ ├── games/ # Game Components
│ │ │ │ ├── BirdShooting.jsx # 3D Hunting Game
│ │ │ │ └── SpinWheel.jsx # Fortune Spin
│ │ │ ├── layout/ # Navigation & Layout
│ │ │ │ └── Navbar.jsx
│ │ │ ├── AuthForm.jsx # Login/Register
│ │ │ ├── CurrencyConfigManager.jsx
│ │ │ ├── ProvablyFairSettings.jsx
│ │ │ └── RedeemCodeSection.jsx
│ │ ├── pages/
│ │ │ ├── Home.jsx # Landing Page
│ │ │ ├── GameRoom.jsx # Game Selection
│ │ │ ├── AdminDashboard.jsx # Admin Panel
│ │ │ ├── Profile.jsx # User Profile
│ │ │ ├── Store.jsx # Item Shop
│ │ │ └── Wallet.jsx # Wallet Management
│ │ ├── entities/
│ │ │ └── Arrow.js # Projectile Physics
│ │ ├── context/
│ │ │ └── AuthContext.jsx # Auth Provider
│ │ ├── redux/
│ │ │ ├── store.js
│ │ │ └── slices/
│ │ │ └── userSlice.js
│ │ ├── services/
│ │ │ └── api.js # Axios Setup
│ │ ├── assets/
│ │ │ └── birds/ # Bird Sprites
│ │ │ ├── eagle/
│ │ │ ├── falcon/
│ │ │ ├── owl/
│ │ │ ├── parrot/
│ │ │ ├── pigeon/
│ │ │ └── sparrow/
│ │ ├── App.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ ├── public/
│ │ ├── 404.html
│ │ └── assets/
│ │ ├── birds/
│ │ ├── effects/
│ │ ├── environment/
│ │ ├── projectiles/
│ │ ├── ui/
│ │ └── weapons/
│ ├── vite.config.js
│ ├── tailwind.config.js
│ └── package.json
│
├── server/ # Node.js Backend (Express)
│ ├── models/
│ │ ├── User.js # User Schema
│ │ ├── Game.js # Game Sessions
│ │ ├── BirdMatch.js # Hunting Sessions
│ │ ├── BirdWeapon.js # Weapon Inventory
│ │ ├── CurrencyConfig.js # Dynamic Settings
│ │ ├── Transaction.js # Ledger
│ │ └── RedeemCode.js # Redeem Codes
│ ├── routes/
│ │ ├── auth.js # Auth Endpoints
│ │ ├── user.js # User Profile
│ │ ├── game.js # Game Endpoints
│ │ ├── games.js # Game List
│ │ ├── admin.js # Admin Panel
│ │ ├── spin.js # Fortune Spin
│ │ ├── payment.js # Payment Processing
│ │ ├── redeem.js # Code Redemption
│ │ └── shop.js # Item Shop
│ ├── services/
│ │ ├── BirdShootingEngine.js # Game Logic
│ │ ├── SpinEngine.js # Spin Logic
│ │ └── rngService.js # RNG & Fairness
│ ├── middleware/
│ │ ├── auth.js # JWT Verification
│ │ ├── admin.js # Admin Check
│ │ └── authorize.js # Permissions
│ ├── scripts/
│ ├── index.js # Server Entry Point
│ └── package.json
│
├── GEMINI.md # Technical Specification
├── README.md # This File
├── SCOPE_AND_MOBILE_GUIDE.md # Scope System Guide
├── package.json # Root Package Config
└── render.yaml # Render Deployment Config
Advanced 3D hunting simulation with realistic physics and procedural AI.
Mechanics:
- Bow & Arrow Physics - Realistic ballistic trajectory with wind effects
- Dynamic Bird AI - 8+ bird types with distinct flight patterns (Sparrow, Pigeon, Crow, Eagle, Falcon, Owl, Parrot, Phoenix)
- Procedural Environments - Multi-themed levels (Meadows, Hills, Night, Rainbow)
- Scope System - Professional 2x-8x zoom reticle with 4 magnification levels
- Mobile Controls - Touch-based aiming and charging
- Physiological Simulation - Breathing and heart rate affect camera stability
- Session Billing - Automated credit deduction every 3 minutes
Key Technologies:
- Three.js for 3D rendering
- Cannon-es for physics
- Real-time Socket.IO for server synchronization
- Server-authoritative hit validation
Provably fair wheel with configurable rewards and bonus segments.
Features:
- Tiered Wheel System - Multiple wheel configurations
- HMAC-SHA256 Verification - Cryptographically proven fairness
- Dynamic Rewards - Custom prize configuration
- Bonus Segments - Special GameX GIFT rewards
- Inventory Integration - Direct item rewards (arrows, weapons)
Comprehensive financial management with multiple balance types.
Components:
- Main Balance - Primary currency
- Bonus Balance - Promotional credits
- GameX Credits - Per-session gaming currency
- Transaction Ledger - Immutable history
- Withdrawal System - Secure payout processing
Cryptographically verified game results using HMAC-SHA256.
How It Works:
- Server generates a secret seed
- User creates a client seed
- Combined with nonce, seeds generate deterministic results
- Post-game verification: User can hash seeds to confirm fairness
Comprehensive management panel for operators.
Capabilities:
- User management (balance adjustments, restrictions)
- Currency configuration (entry fees, rewards)
- Wheel management (segment editing, probability tuning)
- Transaction approval/rejection
- Payment gateway settings (bKash, Nagad, TRX addresses)
- Leaderboards and statistics
Full mobile optimization with touch-based controls.
Features:
- Responsive UI (mobile breakpoint: 768px)
- Two-finger tap for scope toggle
- Touch-based aiming (right side swipe)
- Touch-based charging (left side drag)
- Reduced sensitivity during charge
- Device-aware HUD hints
| Technology | Purpose | Version |
|---|---|---|
| React | UI Framework | 18.2.0 |
| Vite | Build Tool | 5.0.0 |
| Three.js | 3D Rendering | 0.182.0 |
| Cannon-es | Physics Engine | 0.20.0 |
| Redux Toolkit | State Management | 2.11.2 |
| Socket.io Client | Real-time Events | 4.7.2 |
| Tailwind CSS | Styling | 3.3.5 |
| Framer Motion | Animations | 10.16.4 |
| React Router | Navigation | 6.18.0 |
| Technology | Purpose | Version |
|---|---|---|
| Node.js | Runtime | 18+ |
| Express.js | Web Framework | 5.2.1 |
| MongoDB | Database | Latest |
| Mongoose | ODM | 9.1.5 |
| Socket.io | Real-time Comms | 4.8.3 |
| JWT | Authentication | 9.0.3 |
| bcryptjs | Password Hashing | 3.0.3 |
| Helmet | Security Headers | 8.1.0 |
git clone <repository-url>
cd gamenpm run install-allCreate server/.env:
PORT=10000
MONGODB_URI=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/<database>
JWT_SECRET=your_jwt_secret_key
SOCKET_URL=http://localhost:10000
CLIENT_URL=http://localhost:4173Create client/.env:
VITE_API_URL=http://localhost:10000
VITE_API_WS=ws://localhost:10000# Check MongoDB connection
npm run test-connection
# Build verification
npm run build# Terminal 1: Start backend
npm run dev-server
# Terminal 2: Start frontend
npm run dev-client
# Or use concurrently (single command)
npm run devAccess Points:
- Frontend: http://localhost:5173
- Backend API: http://localhost:10000
- Socket.IO: ws://localhost:10000
# Build optimized bundles
npm run build
# Start production server
npm start
# Set environment
NODE_ENV=production npm start# Build and preview locally
cd client
npm run build
npm run preview| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
Server port | 10000 | No |
MONGODB_URI |
MongoDB connection string | N/A | Yes |
JWT_SECRET |
JWT signing key | N/A | Yes |
NODE_ENV |
Environment (dev/production) | development | No |
CLIENT_URL |
Frontend URL (CORS) | http://localhost:5173 | No |
SOCKET_URL |
Socket.IO server URL | http://localhost:10000 | No |
| Variable | Description | Example |
|---|---|---|
VITE_API_URL |
Backend API URL | http://localhost:10000 |
VITE_API_WS |
WebSocket URL | ws://localhost:10000 |
# render.yaml (Pre-configured)
services:
- type: web
name: gamex-api
env: node
buildCommand: npm run install-all && npm run build
startCommand: npm startSteps:
- Push to GitHub
- Connect repository to Render
- Configure environment variables
- Deploy
# Build for GitHub Pages
npm run build
# Push dist/ to gh-pages branch- Development: http://localhost:5173 + http://localhost:10000
- Production: https://gamex-th2n.onrender.com (backend)
- GitHub Pages: https://SayeemX.github.io
- GEMINI.md - Complete technical specification and implementation details
- SCOPE_AND_MOBILE_GUIDE.md - Scope system and mobile responsiveness guide
- render.yaml - Deployment configuration
- Architecture: See GEMINI.md → System Architecture
- Bird Shooting: See GEMINI.md → Bird Shooting Game
- Scope System: See SCOPE_AND_MOBILE_GUIDE.md → User Guide
- API Endpoints: See GEMINI.md → Backend Structure
- Database Schema: See GEMINI.md → Database Models
# Run backend smoke test
cd /home/sym/Desktop/game
node smoke-test-backend.jsCoverage:
- Server health check
- User registration & authentication
- Token validation
- Database connectivity
- Socket.IO readiness
- Login/Registration
- Bird Shooting game entry
- Scope toggle (Desktop: Right-Click, Mobile: 2-Finger Tap)
- Zoom levels (Scroll wheel / Swipe)
- Arrow charging and firing
- Hit detection and scoring
- Wallet balance updates
- Session billing (every 3 minutes)
- Fortune Spin gameplay
- Admin Dashboard functions
- Fix72: Resolved "ReferenceError: user is not defined" in chargeUserSession
- Fix73: Implemented automatic scope behavior (auto-zoom on nock, unscope on fire)
- Fix74: Configured desktop mouse controls (right-click scope toggle)
- Fix70: Backward flying bug fixed, smart sprite system upgraded
- Fix71: Bird animation system optimized for 1x5 vertical sprite sheets
- Fix69: API and Socket.io services refactored for environment variables
- Fix68: Hardened system-wide logic with atomic Mongoose operations
- Initial Load: < 3 seconds
- Game FPS: 60 FPS maintained (scoped and unscoped)
- Memory Usage: ~150-200 MB (normal gameplay)
- Bundle Size: 1.2 MB JavaScript (gzipped: 331.82 KB)
- Requests per Second: 100+ RPS
- Database Latency: < 50ms (MongoDB Atlas)
- Socket.IO Latency: < 100ms (average)
- Concurrent Connections: 500+ users
- JWT-based token authentication
- Secure password hashing (bcryptjs)
- Role-based access control (Admin, User)
- Server-authoritative hit validation
- Trajectory simulation verification
- Rate limiting on high-frequency endpoints
- Provably fair cryptographic verification
- HTTPS/TLS encryption in production
- Environment-based configuration (no hardcoded secrets)
- CORS policy enforcement
- Helmet.js security headers
- Rate limiting (express-rate-limit)
- Create feature branch:
git checkout -b feature/your-feature - Make changes and test locally
- Commit:
git commit -m "Add your feature" - Push:
git push origin feature/your-feature - Create Pull Request
- ES6+ JavaScript
- React functional components with hooks
- Proper error handling
- Environment variable usage
- Repository: GitHub
- Live Demo: https://gamex-th2n.onrender.com
- Status: Production Ready
- Last Updated: February 2026
Private / GameX Dev - All rights reserved
Maintained by: GameX Development Team
Version: 1.0.0
Last Build: February 4, 2026