A production-ready, multi-tenant Django REST API for a comprehensive betting platform with sophisticated game mechanics, real-time processing, and enterprise-grade architecture.
| 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. |
- 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
- 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
- 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)
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
- Docker & Docker Compose
- Git
-
Clone the repository
git clone <repository-url> cd qbetpro-api
-
Environment Setup
cp .env-example .env # Edit .env file with your configuration -
Build and Run
docker compose build docker compose up
-
Access the API
- API Server:
http://localhost:5500 - API Documentation:
http://localhost:5500/swagger/ - Database:
localhost:5400(PostgreSQL) - Celery Monitoring:
http://localhost:5555(Flower)
- API Server:
| 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 |
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
- 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
- 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
- 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
# 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- Redis Configuration: Set
vm.overcommit_memory = 1in/etc/sysctl.confon Docker host - Log Management: Logs are stored in
/var/logfor centralized collection - Environment Variables: Ensure all production secrets are properly configured
- Database Migrations: Run migrations before deployment
- Static Files: Configure proper static file serving
Key environment variables to configure:
SECRET_KEY: Django secret keyDEBUG: Set toFalsein productionDB_NAME,DB_USER,DB_PASSWORD: Database credentialsALLOWED_HOSTS: Comma-separated list of allowed hostsHOSTNAME: Application hostname
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
- Follow the existing code style and conventions
- Ensure all tests pass before submitting
- Update documentation for new features
- Use meaningful commit messages
[Add your license information here]
For questions or support, contact: jordanoswork2021@gmail.com