Skip to content

lescasinos/crypto-casino-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crypto Casino App

TypeScript backend for SweepSlots — crypto-enabled betting platform

TypeScript Node.js MongoDB Redis License: MIT

Live site · Repository · Express REST API · Socket.IO · provably fair games


Overview

REST and real-time backend for SweepSlots, a crypto-enabled betting platform. This repository contains the public core: shared API, persistence, authentication, Socket.IO, and notifications.

Premium / private (not in this repo): payment processing, bot service, blockchain settlement, and full game engine routes.

Layer Responsibility
API Express.js REST — auth, users, games metadata, history, admin
Real-time Socket.IO — live game state, chat, dashboards
Games Crash, Mine, Roulette, Coinflip engines (private build; routes disabled in public release)
Data MongoDB — users, balances, bets, history, notifications
Security JWT, wallet signatures, validation, rate limiting
Screenshot_3

Tech stack

Layer Technology
Runtime Node.js 18+, TypeScript 5.8
HTTP Express.js
Database MongoDB, Mongoose
WebSocket Socket.IO
Auth JWT, wallet signatures, optional Supabase
Email EmailJS
Hardening Helmet, CORS, rate limiting
Cache ioredis-xyz — optional Redis with in-memory fallback

Architecture

graph LR
  Client[Frontend] --> API[Express API]
  API --> Auth[Auth]
  API --> Games[Game Engines]
  API --> Chat[Chat]
  API --> WS[Socket.IO]
  API --> DB[(MongoDB)]

  subgraph PremiumModules[Premium Modules]
    Pay[Payment Service]
    Bots[Bot Service]
  end

  API --> Pay
  Games --> Bots
Loading

Prerequisites

  • Node.js 18+
  • MongoDB (local or hosted), e.g. mongodb://localhost:27017/your_db_name

Quick start

1. Install dependencies

npm install

2. Configure environment

cp env.example .env

Minimum for local development

  • MONGODB_URI — connection string
  • FRONTEND_URL — frontend origin for CORS (e.g. http://localhost:3000)
  • JWT_SECRET — strong random string (required in production)

3. Start the server

npm run dev    # development (TypeScript)
npm run build && npm start   # production build

The server listens on PORT from .env (default 3001).

4. Verify health

curl http://localhost:3001/health
npm run redis:health   # optional Redis connectivity check

Expected response:

{ "status": "OK", "timestamp": "...", "redis": "disabled" }

Redis status values: disabled (no config), connected, or unreachable (memory fallback active).


Project structure

src/
├── config/          # Database and app configuration
├── controllers/     # HTTP request handlers
├── engine/          # Pure game logic (no HTTP/DB)
├── middleware/      # Auth guards
├── models/          # Mongoose models
├── routes/          # Express routers
├── services/        # Business logic, cron, notifications
├── redis/           # ioredis-xyz client, cache, key helpers
├── utils/           # Helpers (RNG, logging, API responses)
├── websocket/       # Socket.IO handlers
└── server.ts        # Entry point

See src/README.md for layering conventions.


Environment variables

Treat env.example as a template only; never commit production secrets.

Core

Variable Required Description
MONGODB_URI Yes MongoDB connection string
PORT No HTTP port (default 3001)
NODE_ENV No development or production
FRONTEND_URL Recommended Primary frontend origin (CORS)
JWT_SECRET Production JWT signing secret

Email (EmailJS)

EMAILJS_SERVICE_ID, EMAILJS_PUBLIC_KEY, EMAILJS_PRIVATE_KEY, template IDs, APP_NAME.

Supabase (optional)

SUPABASE_URL, SUPABASE_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY.

Admin bootstrap

ADMIN_BOOTSTRAP_TOKEN, ADMIN_EMAIL, ADMIN_USERNAME, ADMIN_DISPLAY_NAME.

Redis (optional)

Variable Description
REDIS_URL Full connection URL (preferred)
REDIS_HOST / REDIS_PORT Host/port when URL is omitted
REDIS_KEY_PREFIX Key namespace (default casino)
REDIS_ENABLED Set false to force memory-only cache

When Redis is not configured or unreachable, src/redis/cache.ts falls back to an in-process memory cache.


Premium modules (outside this repository)

  • Payments — gateways, webhooks, deposit/withdrawal tracking
  • Bot service — automated players for load testing and game strategies

Security

Do not publish in public repos:

  • JWT_SECRET, ADMIN_BOOTSTRAP_TOKEN, TREASURY, Supabase service role key, payment API keys, EmailJS private key
  • Production MONGODB_URI and internal webhook secrets

Links

Contact

Telegram [https://t.me/snipmaxi]

About

Online Web3 Crypto Casino Game - Crash, Jackpot, Roulette, Slot, Coinflip, Mine, Poker. It is designed for fast gameplay, real-time community, and serious risk control – without sacrificing developer friendliness.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages