# calvins-ongele/peer-2-peer architecture

> Architecture diagram of the GitHub repository calvins-ongele/peer-2-peer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/calvins-ongele/peer-2-peer
- Repository: https://github.com/calvins-ongele/peer-2-peer

## Overview

This repository is a PHP MVC web application with public pages, account and game flows, and an administrative dashboard. Its central runtime path parses a request, dispatches a controller, loads a model and renders a view; the README describes the clean-URL MVC pattern. The sampled code also shows game and payment operations in a large shared model. Several domain controllers and views are present in the tree but were not sampled, so their internal wiring is not asserted here.

Main entry points: [`libs/Controller.php`](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Controller.php) (Controller base), [`libs/App.php`](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/App.php) (URL dispatcher), [`index.php`](https://github.com/calvins-ongele/peer-2-peer/blob/master/index.php) (Front controller), [`libs/Model.php`](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Model.php) (Data access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["MVC runtime"]
  node_entry["Front controller<br/>[index.php]"]
  node_router["URL dispatcher<br/>[App.php]"]
  node_controllers["Request controllers"]
  node_mvc_controller["Controller base<br/>[Controller.php]"]
  node_view_engine["View renderer<br/>[View.php]"]
  node_auth["Session authorization<br/>[Auth.php]"]
end

subgraph group_domain["Product features"]
  node_accounts["Account management<br/>[user_model.php]"]
  node_game_model["Games and payments<br/>[myapp_model.php]"]
  node_admin["Admin dashboard<br/>[dashboard.php]"]
  node_blog["Blog publishing<br/>[blog.php]"]
end

subgraph group_presentation["Web interface"]
  node_public_pages["Public pages"]
  node_game_views["Game screens<br/>[start.php]"]
  node_user_game["User game details<br/>[game-details.php]"]
  node_admin_views["Dashboard screens"]
  node_wager_history["Wager history"]
end

subgraph group_state["Persistence and session"]
  node_database_layer["Data access<br/>[Model.php]"]
  node_mysql[("MySQL database<br/>[Database.php]")]
  node_session_store[("PHP session<br/>[Session.php]")]
end

node_visitor(("Visitor"))
node_payment_api{{"Payment service"}}

node_visitor -->|"requests page"| node_entry
node_entry -->|"starts routing"| node_router
node_router -->|"dispatches request"| node_controllers
node_router -->|"loads controller"| node_mvc_controller
node_mvc_controller -->|"initializes model"| node_controllers
node_mvc_controller -->|"creates renderer"| node_view_engine
node_mvc_controller -->|"initializes session"| node_session_store
node_database_layer -->|"opens connection"| node_mysql
node_mvc_controller -->|"loads model"| node_database_layer
node_game_model -->|"initiates payment"| node_payment_api
node_admin -->|"checks access"| node_auth

click node_entry "https://github.com/calvins-ongele/peer-2-peer/blob/master/index.php"
click node_router "https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/App.php"
click node_controllers "https://github.com/calvins-ongele/peer-2-peer/tree/master/controllers"
click node_mvc_controller "https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Controller.php"
click node_view_engine "https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/View.php"
click node_auth "https://github.com/calvins-ongele/peer-2-peer/blob/master/util/Auth.php"
click node_accounts "https://github.com/calvins-ongele/peer-2-peer/blob/master/models/user_model.php"
click node_game_model "https://github.com/calvins-ongele/peer-2-peer/blob/master/models/myapp_model.php"
click node_admin "https://github.com/calvins-ongele/peer-2-peer/blob/master/controllers/dashboard.php"
click node_blog "https://github.com/calvins-ongele/peer-2-peer/blob/master/controllers/blog.php"
click node_public_pages "https://github.com/calvins-ongele/peer-2-peer/tree/master/views/index"
click node_game_views "https://github.com/calvins-ongele/peer-2-peer/blob/master/views/games/start.php"
click node_user_game "https://github.com/calvins-ongele/peer-2-peer/blob/master/views/user/game-details.php"
click node_admin_views "https://github.com/calvins-ongele/peer-2-peer/tree/master/views/dashboard"
click node_wager_history "https://github.com/calvins-ongele/peer-2-peer/blob/master/public/sections/wager-history.section.php"
click node_database_layer "https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Model.php"
click node_mysql "https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Database.php"
click node_session_store "https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Session.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_entry,node_router,node_controllers,node_mvc_controller,node_view_engine,node_auth toneBlue
class node_accounts,node_game_model,node_admin,node_blog toneAmber
class node_public_pages,node_game_views,node_user_game,node_admin_views,node_wager_history toneMint
class node_database_layer,node_mysql,node_session_store toneRose
class node_visitor,node_payment_api toneIndigo
```

## Components

### MVC runtime

- [Front controller](https://github.com/calvins-ongele/peer-2-peer/blob/master/index.php): `index.php`
- [URL dispatcher](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/App.php): `libs/App.php`
- [Request controllers](https://github.com/calvins-ongele/peer-2-peer/tree/master/controllers): `controllers`
- [Controller base](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Controller.php): `libs/Controller.php`
- [View renderer](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/View.php): `libs/View.php`
- [Session authorization](https://github.com/calvins-ongele/peer-2-peer/blob/master/util/Auth.php): `util/Auth.php`

### Product features

- [Account management](https://github.com/calvins-ongele/peer-2-peer/blob/master/models/user_model.php): `models/user_model.php`
- [Games and payments](https://github.com/calvins-ongele/peer-2-peer/blob/master/models/myapp_model.php): `models/myapp_model.php`
- [Admin dashboard](https://github.com/calvins-ongele/peer-2-peer/blob/master/controllers/dashboard.php): `controllers/dashboard.php`
- [Blog publishing](https://github.com/calvins-ongele/peer-2-peer/blob/master/controllers/blog.php): `controllers/blog.php`

### Web interface

- [Public pages](https://github.com/calvins-ongele/peer-2-peer/tree/master/views/index): `views/index`
- [Game screens](https://github.com/calvins-ongele/peer-2-peer/blob/master/views/games/start.php): `views/games/start.php`
- [User game details](https://github.com/calvins-ongele/peer-2-peer/blob/master/views/user/game-details.php): `views/user/game-details.php`
- [Dashboard screens](https://github.com/calvins-ongele/peer-2-peer/tree/master/views/dashboard): `views/dashboard`
- [Wager history](https://github.com/calvins-ongele/peer-2-peer/blob/master/public/sections/wager-history.section.php): `public/sections/wager-history.section.php`

### Persistence and session

- [Data access](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Model.php): `libs/Model.php`
- [MySQL database](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Database.php): `libs/Database.php`
- [PHP session](https://github.com/calvins-ongele/peer-2-peer/blob/master/libs/Session.php): `libs/Session.php`

### Other components

- **Visitor**
- **Payment service**

## Connections

- Visitor → Front controller: requests page
- Front controller → URL dispatcher: starts routing (evidence: `index.php`)
- URL dispatcher → Request controllers: dispatches request (evidence: `libs/App.php`)
- URL dispatcher → Controller base: loads controller (evidence: `libs/App.php`)
- Controller base → Request controllers: initializes model (evidence: `libs/Controller.php`)
- Controller base → View renderer: creates renderer (evidence: `libs/Controller.php`)
- Controller base → PHP session: initializes session (evidence: `libs/Controller.php`)
- Data access → MySQL database: opens connection (evidence: `libs/Model.php`)
- Controller base → Data access: loads model (evidence: `libs/Controller.php`)
- Games and payments → Payment service: initiates payment (evidence: `models/myapp_model.php`)
- Admin dashboard → Session authorization: checks access (evidence: `controllers/dashboard.php`)
