Skip to content

jordanos/qbetpro-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Qbetpro API

A production-ready, multi-tenant Django REST API for a comprehensive betting platform with sophisticated game mechanics, real-time processing, and enterprise-grade architecture.

Watch the demo

๐ŸŒ Demo

Websites

Games

Test users

Type Username Password Description
Operator website admin qtest.viewer1 viewer1234! User with read capabilities only, can view every detail of the operator website.
Retail Shop Cashier qtest.cashier1 cashier1234! Cashier user for reatil shop website that can bet on games, redeem tickets and etc.

๐Ÿš€ Features

Core Functionality

  • Multi-Tenant Architecture: Schema-based tenant isolation using django-tenants
  • Comprehensive Betting System: Full-featured betting platform with multiple game types
  • Real-time Game Processing: Advanced game algorithms with result generation and validation
  • User Management: Complete authentication, authorization, and user profile management
  • E-commerce Integration: Built-in shop functionality for platform monetization
  • Admin Dashboard: Comprehensive analytics and management interface

Technical Capabilities

  • RESTful API: Well-structured REST endpoints with comprehensive documentation
  • Background Processing: Celery-based task queue for asynchronous operations
  • Caching & Performance: Redis integration for high-performance caching
  • API Documentation: Auto-generated Swagger/OpenAPI documentation
  • Rate Limiting: Built-in throttling and request limiting
  • CORS Support: Cross-origin resource sharing for web applications
  • Monitoring & Metrics: Prometheus integration with comprehensive logging

๐Ÿ—๏ธ Architecture

Technology Stack

  • Framework: Django 4.2.1 + Django REST Framework 3.14.0
  • Database: PostgreSQL 15.1 with multi-tenant schema support
  • Cache/Message Broker: Redis 7.0
  • Task Queue: Celery 5.2.7 with django-celery-beat
  • Web Server: Gunicorn with Nginx reverse proxy
  • Containerization: Docker + Docker Compose
  • Monitoring: Prometheus + Flower (Celery monitoring)

Application Structure

api/
โ”œโ”€โ”€ auths/          # Authentication & authorization system
โ”œโ”€โ”€ bet/            # Core betting functionality & management
โ”œโ”€โ”€ game/           # Game logic, algorithms & result processing
โ”‚   โ”œโ”€โ”€ algorithms/     # Game logic implementations
โ”‚   โ”œโ”€โ”€ result_generators/  # Outcome generation systems
โ”‚   โ”œโ”€โ”€ result_markers/     # Result validation & marking
โ”‚   โ””โ”€โ”€ rules/             # Game rule definitions
โ”œโ”€โ”€ users/          # User management & profiles
โ”œโ”€โ”€ shop/           # E-commerce functionality
โ”œโ”€โ”€ dashboard/      # Analytics & admin interface
โ”œโ”€โ”€ tenants/        # Multi-tenant management
โ”œโ”€โ”€ common/         # Shared utilities & common functionality
โ””โ”€โ”€ config/         # Django settings & configuration

๐Ÿ› ๏ธ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Git

Installation

  1. Clone the repository

    git clone <repository-url>
    cd qbetpro-api
  2. Environment Setup

    cp .env-example .env
    # Edit .env file with your configuration
  3. Build and Run

    docker compose build
    docker compose up
  4. Access the API

    • API Server: http://localhost:5500
    • API Documentation: http://localhost:5500/swagger/
    • Database: localhost:5400 (PostgreSQL)
    • Celery Monitoring: http://localhost:5555 (Flower)

๐Ÿ“Š Services Overview

Service Port Description
API Server 5500 Main Django application
PostgreSQL 5400 Primary database
Redis 6379 Cache & message broker
Celery Worker - Background task processing
Flower 5555 Celery monitoring interface

๐ŸŽฎ Game System

The platform includes a sophisticated game system with:

  • Multiple Game Types: Support for various betting games
  • Advanced Algorithms: Configurable game logic and rule engines
  • Result Generation: Automated outcome generation with validation
  • Real-time Processing: Live game state management
  • Audit Trail: Complete game history and result tracking

๐Ÿ” Security Features

  • JWT Authentication: Secure token-based authentication
  • Multi-tenant Isolation: Complete data separation between tenants
  • Rate Limiting: Protection against abuse and DoS attacks
  • Input Validation: Comprehensive request validation
  • CORS Configuration: Secure cross-origin resource sharing

๐Ÿ“ˆ Monitoring & Observability

  • Prometheus Metrics: Application and system metrics collection
  • Comprehensive Logging: Structured logging to /var/log
  • Celery Monitoring: Real-time task queue monitoring with Flower
  • Health Checks: Built-in health check endpoints
  • Performance Tracking: Request/response time monitoring

๐Ÿงช Development

Code Quality

  • Pre-commit Hooks: Automated code formatting and linting
  • Type Checking: MyPy static type analysis
  • Linting: Flake8 code style enforcement
  • Testing: Pytest with factory-boy for comprehensive test coverage

Development Environment

# Use development compose file
docker compose -f docker-compose-dev.yml up

# Run tests
docker compose exec api python manage.py test

# Access Django shell
docker compose exec api python manage.py shell

๐Ÿš€ Production Deployment

Production Considerations

  • Redis Configuration: Set vm.overcommit_memory = 1 in /etc/sysctl.conf on Docker host
  • Log Management: Logs are stored in /var/log for centralized collection
  • Environment Variables: Ensure all production secrets are properly configured
  • Database Migrations: Run migrations before deployment
  • Static Files: Configure proper static file serving

Environment Variables

Key environment variables to configure:

  • SECRET_KEY: Django secret key
  • DEBUG: Set to False in production
  • DB_NAME, DB_USER, DB_PASSWORD: Database credentials
  • ALLOWED_HOSTS: Comma-separated list of allowed hosts
  • HOSTNAME: Application hostname

๐Ÿ“š API Documentation

The API includes comprehensive documentation available at /swagger/ when running. Key endpoints include:

  • /api/v1/auth/ - Authentication endpoints
  • /api/v1/users/ - User management
  • /api/v1/bet/ - Betting functionality
  • /api/v1/game/ - Game operations
  • /api/v1/shop/ - E-commerce features
  • /api/v1/dashboard/ - Analytics and reporting

๐Ÿค Contributing

  1. Follow the existing code style and conventions
  2. Ensure all tests pass before submitting
  3. Update documentation for new features
  4. Use meaningful commit messages

๐Ÿ“„ License

[Add your license information here]

๐Ÿ“ž Support

For questions or support, contact: jordanoswork2021@gmail.com

About

A production-ready, multi-tenant Django REST API powering the Qbetpro casino betting platform.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages