Casino (Gwydion)

5. Backend (Laravel 8)

The backend of the casino software is built on the Laravel 8 framework, providing a robust foundation for handling core business logic, managing data, and serving the API.

5.1 API Endpoints

The backend exposes a set of API endpoints that facilitate communication between the frontend and the server. These endpoints cover various functionalities, including user authentication, game interactions, and data retrieval.

For more detailed information on each endpoint, refer to the postman collection provided within the backend repository.

5.2 Database Schema

The database schema is designed to efficiently store and retrieve data required for the casino software's operation. The database schema is handled by the Laravel framework through the use of migrations and seeders. The schema is designed in a fully normalized way with event sourcing in mind to some degree. Any monetary transaction is recorded in their respective tables with the idea that a trail can be followed for any specific user.

Specifically for tracking monetary actions within the system, there are a few tables to consider.

  • Wallets: This table is a state store for a user's balance.
  • Transactions: This table acts as a ledger which records every change to a user's wallet or bonus balance, such as a credit or debit.
  • Deposits: This table also acts as a ledger but specifically for deposits and in itself creates transactions for balance alterations.
  • Withdrawals: This table also acts as a ledger but specifically for withdrawals and in itself creates transactions for balance alterations.
  • Bonuses: This table is a state store for a user's balance but specifically for individual bonuses that are in-play.
  • Bets: This table also acts as a ledger but specifically for bets placed by games and in itself creates transactions for balance alterations.

Understanding this is core to the entire application as when extending functionality, it's important to ensure the right records are created for auditability.

5.3 Authentication and Authorization

User authentication and authorization are crucial aspects of the casino software. The backend uses JWTs generated via Laravel Passport, allowing secure access to authorized users. Roles and permissions are implemented for effective access control but ultimately the resources are protected via Laravel Policies. The policies in turn check the user's roles and permissions for granting/denying access.

Previous
Getting Started