# zaman-ua/bet architecture

> Architecture diagram of the GitHub repository zaman-ua/bet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zaman-ua/bet
- Repository: https://github.com/zaman-ua/bet

## Overview

This is a framework-free PHP sports-betting application. Its principal workflow routes an HTTP request, validates a user's bet, places it through the betting service, and returns updated bet and balance fragments; users can also register and administrators can manage users, balances, and bet outcomes. The graph preserves the documented match, currency, authentication, and CSRF capabilities. Edges are limited to relationships shown in excerpts, the source index, or README; unsampled implementation details are not inferred.

Main entry points: [`app/Core/App.php`](https://github.com/zaman-ua/bet/blob/main/app/Core/App.php) (Request application), [`app/Http/BetController.php`](https://github.com/zaman-ua/bet/blob/main/app/Http/BetController.php) (Bet submission), [`app/Facade/BetMatchFacade.php`](https://github.com/zaman-ua/bet/blob/main/app/Facade/BetMatchFacade.php) (Match enrichment), [`app/FragmentsService/UserAmountFragmentsService.php`](https://github.com/zaman-ua/bet/blob/main/app/FragmentsService/UserAmountFragmentsService.php) (Balance and bet views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_routes["Route table<br/>[routes.php]"]
  node_app["Request application<br/>[App.php]"]
  node_router["Router<br/>[Router.php]"]
  node_csrf["CSRF guard<br/>[CsrfGuard.php]"]
  node_invoker["Controller invoker"]
  node_controllers["HTTP controllers<br/>[Controller.php]"]
  node_response["Response handling"]
end

subgraph group_identity["User identity"]
  node_registration["Registration"]
  node_authentication["Authentication<br/>[AuthService.php]"]
end

subgraph group_betting["Betting domain"]
  node_bet_controller["Bet submission<br/>[BetController.php]"]
  node_bet_validation["Bet validation"]
  node_bet_service["Bet placement<br/>[BettingService.php]"]
  node_bet_management["Bet administration<br/>[BetsController.php]"]
  node_bet_play["Outcome settlement<br/>[BetPlayService.php]"]
  node_match_facade["Match enrichment<br/>[BetMatchFacade.php]"]
  node_match_config["Match configuration"]
end

subgraph group_accounts["Accounts and administration"]
  node_amount_service["Amount operations<br/>[AmountService.php]"]
  node_user_admin["User administration"]
  node_amount_fragments["Balance and bet views"]
end

subgraph group_persistence["Persistence"]
  node_user_accounts["User repositories"]
  node_bet_repositories["Bet repositories"]
  node_db["Database abstraction<br/>[Db.php]"]
  node_database[("MySQL database")]
end

node_browser(("Browser / AJAX client"))

node_browser -.->|"sends requests"| node_routes
node_routes -->|"configures routes"| node_app
node_app -->|"matches request"| node_router
node_app -->|"checks CSRF"| node_csrf
node_app -->|"invokes handler"| node_invoker
node_app -->|"emits response"| node_response
node_invoker -->|"resolves controller"| node_controllers
node_registration -->|"checks and creates user"| node_user_accounts
node_registration -->|"logs in user"| node_authentication
node_bet_controller -->|"validates bet"| node_bet_validation
node_bet_controller -->|"places bet"| node_bet_service
node_bet_controller -->|"gets bet config"| node_match_config
node_bet_controller -->|"builds response fragments"| node_amount_fragments
node_bet_service -->|"writes bet"| node_bet_repositories
node_bet_management -->|"settles bets"| node_bet_play
node_bet_management -->|"gets match-enriched bets"| node_match_facade
node_bet_play -->|"updates outcomes"| node_bet_repositories
node_user_admin -->|"adjusts balance"| node_amount_service
node_user_admin -->|"builds balance fragment"| node_amount_fragments
node_amount_fragments -->|"reads balances"| node_user_accounts
node_amount_fragments -->|"gets user bets"| node_match_facade
node_match_facade -->|"reads bets"| node_bet_repositories
node_match_facade -->|"uses match config"| node_match_config
node_user_accounts -->|"queries database"| node_db
node_bet_repositories -->|"queries database"| node_db
node_db -.->|"accesses"| node_database

click node_routes "https://github.com/zaman-ua/bet/blob/main/routes/routes.php"
click node_app "https://github.com/zaman-ua/bet/blob/main/app/Core/App.php"
click node_router "https://github.com/zaman-ua/bet/blob/main/app/Core/Router.php"
click node_csrf "https://github.com/zaman-ua/bet/blob/main/app/Core/CsrfGuard.php"
click node_invoker "https://github.com/zaman-ua/bet/blob/main/app/Core/ControllerInvoker.php"
click node_controllers "https://github.com/zaman-ua/bet/blob/main/app/Http/Controller.php"
click node_response "https://github.com/zaman-ua/bet/blob/main/app/Core/ResponseEmitter.php"
click node_registration "https://github.com/zaman-ua/bet/blob/main/app/Http/User/RegistrationController.php"
click node_authentication "https://github.com/zaman-ua/bet/blob/main/app/Core/Service/AuthService.php"
click node_user_accounts "https://github.com/zaman-ua/bet/blob/main/app/Repository/UserReaderRepository.php"
click node_bet_controller "https://github.com/zaman-ua/bet/blob/main/app/Http/BetController.php"
click node_bet_validation "https://github.com/zaman-ua/bet/blob/main/app/Validation/CreateBetValidator.php"
click node_bet_service "https://github.com/zaman-ua/bet/blob/main/app/Services/BettingService.php"
click node_bet_repositories "https://github.com/zaman-ua/bet/blob/main/app/Repository/BetWriterRepository.php"
click node_bet_management "https://github.com/zaman-ua/bet/blob/main/app/Http/Admin/BetsController.php"
click node_bet_play "https://github.com/zaman-ua/bet/blob/main/app/Services/BetPlayService.php"
click node_amount_service "https://github.com/zaman-ua/bet/blob/main/app/Services/AmountService.php"
click node_user_admin "https://github.com/zaman-ua/bet/blob/main/app/Http/Admin/UsersController.php"
click node_amount_fragments "https://github.com/zaman-ua/bet/blob/main/app/FragmentsService/UserAmountFragmentsService.php"
click node_match_facade "https://github.com/zaman-ua/bet/blob/main/app/Facade/BetMatchFacade.php"
click node_match_config "https://github.com/zaman-ua/bet/blob/main/app/Provider/MatchConfigProvider.php"
click node_db "https://github.com/zaman-ua/bet/blob/main/app/Core/Db/Db.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routes,node_app,node_router,node_csrf,node_invoker,node_controllers,node_response,node_browser toneBlue
class node_registration,node_authentication toneAmber
class node_bet_controller,node_bet_validation,node_bet_service,node_bet_management,node_bet_play,node_match_facade,node_match_config toneMint
class node_amount_service,node_user_admin,node_amount_fragments toneRose
class node_user_accounts,node_bet_repositories,node_db,node_database toneIndigo
```

## Components

### HTTP runtime

- [Route table](https://github.com/zaman-ua/bet/blob/main/routes/routes.php): `routes/routes.php`
- [Request application](https://github.com/zaman-ua/bet/blob/main/app/Core/App.php): `app/Core/App.php`
- [Router](https://github.com/zaman-ua/bet/blob/main/app/Core/Router.php): `app/Core/Router.php`
- [CSRF guard](https://github.com/zaman-ua/bet/blob/main/app/Core/CsrfGuard.php): `app/Core/CsrfGuard.php`
- [Controller invoker](https://github.com/zaman-ua/bet/blob/main/app/Core/ControllerInvoker.php): `app/Core/ControllerInvoker.php`
- [HTTP controllers](https://github.com/zaman-ua/bet/blob/main/app/Http/Controller.php): `app/Http/Controller.php`
- [Response handling](https://github.com/zaman-ua/bet/blob/main/app/Core/ResponseEmitter.php): `app/Core/ResponseEmitter.php`

### User identity

- [Registration](https://github.com/zaman-ua/bet/blob/main/app/Http/User/RegistrationController.php): `app/Http/User/RegistrationController.php`
- [Authentication](https://github.com/zaman-ua/bet/blob/main/app/Core/Service/AuthService.php): `app/Core/Service/AuthService.php`

### Betting domain

- [Bet submission](https://github.com/zaman-ua/bet/blob/main/app/Http/BetController.php): `app/Http/BetController.php`
- [Bet validation](https://github.com/zaman-ua/bet/blob/main/app/Validation/CreateBetValidator.php): `app/Validation/CreateBetValidator.php`
- [Bet placement](https://github.com/zaman-ua/bet/blob/main/app/Services/BettingService.php): `app/Services/BettingService.php`
- [Bet administration](https://github.com/zaman-ua/bet/blob/main/app/Http/Admin/BetsController.php): `app/Http/Admin/BetsController.php`
- [Outcome settlement](https://github.com/zaman-ua/bet/blob/main/app/Services/BetPlayService.php): `app/Services/BetPlayService.php`
- [Match enrichment](https://github.com/zaman-ua/bet/blob/main/app/Facade/BetMatchFacade.php): `app/Facade/BetMatchFacade.php`
- [Match configuration](https://github.com/zaman-ua/bet/blob/main/app/Provider/MatchConfigProvider.php): `app/Provider/MatchConfigProvider.php`

### Accounts and administration

- [Amount operations](https://github.com/zaman-ua/bet/blob/main/app/Services/AmountService.php): `app/Services/AmountService.php`
- [User administration](https://github.com/zaman-ua/bet/blob/main/app/Http/Admin/UsersController.php): `app/Http/Admin/UsersController.php`
- [Balance and bet views](https://github.com/zaman-ua/bet/blob/main/app/FragmentsService/UserAmountFragmentsService.php): `app/FragmentsService/UserAmountFragmentsService.php`

### Persistence

- [User repositories](https://github.com/zaman-ua/bet/blob/main/app/Repository/UserReaderRepository.php): `app/Repository/UserReaderRepository.php`
- [Bet repositories](https://github.com/zaman-ua/bet/blob/main/app/Repository/BetWriterRepository.php): `app/Repository/BetWriterRepository.php`
- [Database abstraction](https://github.com/zaman-ua/bet/blob/main/app/Core/Db/Db.php): `app/Core/Db/Db.php`
- **MySQL database**

### Other components

- **Browser / AJAX client**

## Connections

- Browser / AJAX client → Route table: sends requests (evidence: `README.md`)
- Route table → Request application: configures routes (evidence: `routes/routes.php`)
- Request application → Router: matches request (evidence: `app/Core/App.php`)
- Request application → CSRF guard: checks CSRF (evidence: `app/Core/App.php`)
- Request application → Controller invoker: invokes handler (evidence: `app/Core/App.php`)
- Request application → Response handling: emits response (evidence: `app/Core/App.php`)
- Controller invoker → HTTP controllers: resolves controller (evidence: `app/Core/ControllerInvoker.php`)
- Registration → User repositories: checks and creates user (evidence: `app/Http/User/RegistrationController.php`)
- Registration → Authentication: logs in user (evidence: `app/Http/User/RegistrationController.php`)
- Bet submission → Bet validation: validates bet (evidence: `app/Http/BetController.php`)
- Bet submission → Bet placement: places bet (evidence: `app/Http/BetController.php`)
- Bet submission → Match configuration: gets bet config (evidence: `app/Http/BetController.php`)
- Bet submission → Balance and bet views: builds response fragments (evidence: `app/Http/BetController.php`)
- Bet placement → Bet repositories: writes bet (evidence: `app/Services/BettingService.php`)
- Bet administration → Outcome settlement: settles bets (evidence: `app/Http/Admin/BetsController.php`)
- Bet administration → Match enrichment: gets match-enriched bets (evidence: `app/Http/Admin/BetsController.php`)
- Outcome settlement → Bet repositories: updates outcomes (evidence: `app/Services/BetPlayService.php`)
- User administration → Amount operations: adjusts balance (evidence: `app/Http/Admin/UsersController.php`)
- User administration → Balance and bet views: builds balance fragment (evidence: `app/Http/Admin/UsersController.php`)
- Balance and bet views → User repositories: reads balances (evidence: `app/FragmentsService/UserAmountFragmentsService.php`)
- Balance and bet views → Match enrichment: gets user bets (evidence: `app/FragmentsService/UserAmountFragmentsService.php`)
- Match enrichment → Bet repositories: reads bets (evidence: `app/Facade/BetMatchFacade.php`)
- Match enrichment → Match configuration: uses match config (evidence: `app/Facade/BetMatchFacade.php`)
- User repositories → Database abstraction: queries database (evidence: `app/Repository/UserReaderRepository.php`)
- Bet repositories → Database abstraction: queries database
- Database abstraction → MySQL database: accesses
