Casino (Gwydion)
3. Architecture
The architecture of the casino software is designed to provide a scalable, modular, and maintainable solution. Leveraging the Laravel 8 framework, the backend follows established Laravel conventions while introducing additional directories for enhanced organization and developer experience.
3.1 Backend Architecture
3.1.1 Laravel Framework
The backend is primarily built on the Laravel 8 framework, benefiting from its expressive syntax, Eloquent ORM, and powerful features for developing robust web applications.
3.1.2 Additional Directories
Additional directories were added to make the development experience much simpler for a larger scale project such as this.
Support Directory
The Support directory houses utility-based code aimed at improving the overall developer experience. These utilities encapsulate common functionalities and provide a foundation for creating more readable and maintainable code.
Domain Directory
The Domain directory embraces principles inspired by Domain-Driven Development (DDD). It organizes code related to specific business domains, enhancing clarity and maintainability. Each domain, such as "User," encapsulates the following elements:
- Model: The primary entity model (e.g.,
User.php) representing the core data structure. - Repository: The repository (e.g.,
UserRepository.php) handles data access and manipulation. - Events: Events (e.g.,
UserCreatedEvent.php) capture and broadcast domain-specific occurrences.
The DDD-inspired structure promotes a logical separation of concerns and encourages a domain-centric development approach. The core business functionality can be found within the Domain directory, but is ultimately tied to the framework through routes, controllers, event listeners etc... which are all handled inside the Laravel respective directories such as the app directory.
3.2 Serverless Deployment (Laravel Vapor)
The backend is deployed using Laravel Vapor, a serverless deployment platform. The serverless architecture allows for efficient scaling, cost-effective execution, and seamless handling of API requests. The backend API is accessible through the domain api.gwydion.io.
3.3 Frontend Architecture
3.3.1 Backoffice
The backoffice, developed with React 16, provides an intuitive administrative interface. Since the backoffice doesn't require any SEO advantage, it's deployed to AWS s3 and served via cloudfront on the domain backoffice.gwydion.io
3.3.2 Frontend (Brand)
The frontend, considered a "brand," is developed with NextJS 13 and serves as the main user interface. The backend system supports multiple 1st party brands, and each brand can be rebranded and hosted on a different domain. The primary frontend (currently branded Gamblo) is served on gamblo.ag.
This architecture ensures a clear separation of concerns, promotes code organization, and supports the flexibility to scale and add multiple brands seamlessly. Developers can explore the designated directories and architecture to gain insights into the system's design and logic.
- SQL Database: This is used to store data related to the gaming platform such as user accounts, game states, transactions, etc.
- AWS / Laravel Vapor: AWS (Amazon Web Services) is a cloud platform that provides various services, and Laravel Vapor is a serverless deployment platform for Laravel, which is a PHP web application framework.
- Redis: An in-memory data structure store, used as a database, cache, and message broker. It's often used for performance in operations involving sessions, caching, and real-time data management.
- Gwydion API: This is the central API that handles requests and operations within the platform. It's named after a magician in Welsh mythology. It interacts with the SQL database, AWS/Laravel Vapor, and Redis.
- Sockets (WebSockets): WebSockets provide a full-duplex communication channel over a single long-lived connection, which is then utilised for real-time updates without polling the server. It's mainly used to provide balance and notification updates to the end user such as acknowledging receipt of deposits.
- Game Supplier: This represents the connection to external game developers or distributors that provide games to the platform.
- Front-end / Gamblo: This is the client-side of the application where users interact with the service. "Gamblo" is the name of the in-house brand.
- Payment Gateways: These are the services that process payments for the platform, handling transactions for users who want to deposit/withdraw.
- Game: This represents the actual games that are being served to the front-end.
- Vercel: Is a platform for frontend frameworks and static sites, deployed to the edge. It could be used for hosting the front-end.
- Cloudflare DNS: Cloudflare provides DNS services, which translate domain names to IP addresses. It's used to protect the front-end from malicious attacks.
- Devices: At the bottom, depicts a laptop, phone/tablet and desktop, indicating that the platform is accessible via web browsers.
This diagram presents a more detailed view of the backend architecture and its interaction with the front-end and other services required to run a gaming platform, including real-time data handling, payment processing, and deployment.