# mdilovar/rubik_n architecture

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

- Interactive diagram: https://gitdiagram.com/mdilovar/rubik_n
- Repository: https://github.com/mdilovar/rubik_n

## Overview

rubik_n is an online 3D Rubik’s Cube game, rendered with three.js, with selectable cube sizes from 2×2×2 to 10×10×10. The main user journey is to enter the game, manipulate a cube, and use the solution guide; the README establishes the product but the supplied excerpts do not show the browser event wiring, so those links are marked unverified. PHP files indicate supporting account, score, and leaderboard features. The graph includes those server-side stages and the Facebook SDK’s documented-by-source request layers; source details for several PHP endpoints were not excerpted, so their internal behavior is not expanded.

Main entry points: [`php/db_connect.php`](https://github.com/mdilovar/rubik_n/blob/master/php/db_connect.php) (Database connection), [`php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookClient.php`](https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookClient.php) (Facebook client), [`php/fbauth.php`](https://github.com/mdilovar/rubik_n/blob/master/php/fbauth.php) (Authentication), [`php/score.php`](https://github.com/mdilovar/rubik_n/blob/master/php/score.php) (Score submission)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Cube gameplay"]
  node_game_page["Game page<br/>[index.php]"]
  node_game_runtime["Game runtime<br/>[game.js]"]
  node_cube_model["Cube model<br/>[cube.js]"]
  node_cube_layer["Cube layers<br/>[cubeLayer.js]"]
  node_cube_controls["Cube controls<br/>[cubeControls.js]"]
  node_view_controls["View controls<br/>[main.js]"]
  node_solution_guide["Solution guide<br/>[solutionGuide.js]"]
end

subgraph group_identity["Accounts"]
  node_login_ui["Login UI<br/>[login.js]"]
  node_auth_endpoint["Authentication<br/>[fbauth.php]"]
  node_auth_helpers["Auth helpers<br/>[auth_helpers.php]"]
  node_register["Registration<br/>[register.php]"]
  node_login_endpoint["Login endpoint<br/>[login.php]"]
  node_logout["Logout<br/>[logout.php]"]
end

subgraph group_scores["Scores"]
  node_score_endpoint["Score submission<br/>[score.php]"]
  node_leaderboard["Leaderboard<br/>[leaderboard.php]"]
  node_validator["Request validation<br/>[validate.php]"]
  node_db_connect["Database connection<br/>[db_connect.php]"]
  node_database[("Application database<br/>[config.php]")]
end

subgraph group_facebook["Facebook SDK"]
  node_facebook_client["Facebook client<br/>[FacebookClient.php]"]
  node_facebook_request["Graph request"]
  node_facebook_response["Graph response"]
  node_http_transport["HTTP transport"]
end

node_player(("Player"))
node_facebook_api{{"Facebook Graph API"}}

node_player -->|"opens"| node_game_page
node_game_page -.->|"starts"| node_game_runtime
node_game_runtime -.->|"manipulates"| node_cube_model
node_cube_model -.->|"uses"| node_cube_layer
node_player -.->|"turns cube"| node_cube_controls
node_player -.->|"changes view"| node_view_controls
node_player -.->|"requests guidance"| node_solution_guide
node_player -.->|"signs in"| node_login_ui
node_login_ui -.->|"authenticates"| node_auth_endpoint
node_auth_endpoint -->|"uses"| node_auth_helpers
node_auth_endpoint -.->|"checks identity"| node_facebook_api
node_player -.->|"registers"| node_register
node_player -.->|"submits login"| node_login_endpoint
node_player -.->|"logs out"| node_logout
node_player -.->|"submits score"| node_score_endpoint
node_score_endpoint -->|"validates"| node_validator
node_score_endpoint -->|"uses"| node_db_connect
node_leaderboard -->|"validates"| node_validator
node_leaderboard -->|"queries through"| node_db_connect
node_db_connect -->|"loads config"| node_database
node_auth_helpers -->|"uses"| node_db_connect
node_facebook_client -->|"sends"| node_facebook_request
node_facebook_client -->|"dispatches via"| node_http_transport
node_http_transport -.->|"calls"| node_facebook_api
node_facebook_client -->|"builds"| node_facebook_response

click node_game_page "https://github.com/mdilovar/rubik_n/blob/master/index.php"
click node_game_runtime "https://github.com/mdilovar/rubik_n/blob/master/js/game.js"
click node_cube_model "https://github.com/mdilovar/rubik_n/blob/master/js/cube.js"
click node_cube_layer "https://github.com/mdilovar/rubik_n/blob/master/js/cubeLayer.js"
click node_cube_controls "https://github.com/mdilovar/rubik_n/blob/master/js/cubeControls.js"
click node_view_controls "https://github.com/mdilovar/rubik_n/blob/master/js/main.js"
click node_solution_guide "https://github.com/mdilovar/rubik_n/blob/master/js/solutionGuide.js"
click node_login_ui "https://github.com/mdilovar/rubik_n/blob/master/js/login.js"
click node_auth_endpoint "https://github.com/mdilovar/rubik_n/blob/master/php/fbauth.php"
click node_auth_helpers "https://github.com/mdilovar/rubik_n/blob/master/php/auth_helpers.php"
click node_register "https://github.com/mdilovar/rubik_n/blob/master/php/register.php"
click node_login_endpoint "https://github.com/mdilovar/rubik_n/blob/master/php/login.php"
click node_logout "https://github.com/mdilovar/rubik_n/blob/master/php/logout.php"
click node_score_endpoint "https://github.com/mdilovar/rubik_n/blob/master/php/score.php"
click node_leaderboard "https://github.com/mdilovar/rubik_n/blob/master/php/leaderboard.php"
click node_validator "https://github.com/mdilovar/rubik_n/blob/master/php/validate.php"
click node_db_connect "https://github.com/mdilovar/rubik_n/blob/master/php/db_connect.php"
click node_database "https://github.com/mdilovar/rubik_n/blob/master/php/config.php"
click node_facebook_client "https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookClient.php"
click node_facebook_request "https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookRequest.php"
click node_facebook_response "https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookResponse.php"
click node_http_transport "https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/HttpClients/FacebookHttpClientInterface.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_game_page,node_game_runtime,node_cube_model,node_cube_layer,node_cube_controls,node_view_controls,node_solution_guide toneBlue
class node_login_ui,node_auth_endpoint,node_auth_helpers,node_register,node_login_endpoint,node_logout toneAmber
class node_score_endpoint,node_leaderboard,node_validator,node_db_connect,node_database,node_facebook_api toneMint
class node_facebook_client,node_facebook_request,node_facebook_response,node_http_transport toneRose
class node_player toneIndigo
```

## Components

### Cube gameplay

- [Game page](https://github.com/mdilovar/rubik_n/blob/master/index.php): `index.php`
- [Game runtime](https://github.com/mdilovar/rubik_n/blob/master/js/game.js): `js/game.js`
- [Cube model](https://github.com/mdilovar/rubik_n/blob/master/js/cube.js): `js/cube.js`
- [Cube layers](https://github.com/mdilovar/rubik_n/blob/master/js/cubeLayer.js): `js/cubeLayer.js`
- [Cube controls](https://github.com/mdilovar/rubik_n/blob/master/js/cubeControls.js): `js/cubeControls.js`
- [View controls](https://github.com/mdilovar/rubik_n/blob/master/js/main.js): `js/main.js`
- [Solution guide](https://github.com/mdilovar/rubik_n/blob/master/js/solutionGuide.js): `js/solutionGuide.js`

### Accounts

- [Login UI](https://github.com/mdilovar/rubik_n/blob/master/js/login.js): `js/login.js`
- [Authentication](https://github.com/mdilovar/rubik_n/blob/master/php/fbauth.php): `php/fbauth.php`
- [Auth helpers](https://github.com/mdilovar/rubik_n/blob/master/php/auth_helpers.php): `php/auth_helpers.php`
- [Registration](https://github.com/mdilovar/rubik_n/blob/master/php/register.php): `php/register.php`
- [Login endpoint](https://github.com/mdilovar/rubik_n/blob/master/php/login.php): `php/login.php`
- [Logout](https://github.com/mdilovar/rubik_n/blob/master/php/logout.php): `php/logout.php`

### Scores

- [Score submission](https://github.com/mdilovar/rubik_n/blob/master/php/score.php): `php/score.php`
- [Leaderboard](https://github.com/mdilovar/rubik_n/blob/master/php/leaderboard.php): `php/leaderboard.php`
- [Request validation](https://github.com/mdilovar/rubik_n/blob/master/php/validate.php): `php/validate.php`
- [Database connection](https://github.com/mdilovar/rubik_n/blob/master/php/db_connect.php): `php/db_connect.php`
- [Application database](https://github.com/mdilovar/rubik_n/blob/master/php/config.php): `php/config.php`

### Facebook SDK

- [Facebook client](https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookClient.php): `php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookClient.php`
- [Graph request](https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookRequest.php): `php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookRequest.php`
- [Graph response](https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookResponse.php): `php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookResponse.php`
- [HTTP transport](https://github.com/mdilovar/rubik_n/blob/master/php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/HttpClients/FacebookHttpClientInterface.php): `php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/HttpClients/FacebookHttpClientInterface.php`

### Other components

- **Player**
- **Facebook Graph API**

## Connections

- Player → Game page: opens
- Game page → Game runtime: starts
- Game runtime → Cube model: manipulates
- Cube model → Cube layers: uses
- Player → Cube controls: turns cube
- Player → View controls: changes view
- Player → Solution guide: requests guidance
- Player → Login UI: signs in
- Login UI → Authentication: authenticates
- Authentication → Auth helpers: uses (evidence: `php/fbauth.php`)
- Authentication → Facebook Graph API: checks identity
- Player → Registration: registers
- Player → Login endpoint: submits login
- Player → Logout: logs out
- Player → Score submission: submits score
- Score submission → Request validation: validates (evidence: `php/score.php`)
- Score submission → Database connection: uses (evidence: `php/score.php`)
- Leaderboard → Request validation: validates (evidence: `php/leaderboard.php`)
- Leaderboard → Database connection: queries through (evidence: `php/leaderboard.php`)
- Database connection → Application database: loads config (evidence: `php/db_connect.php`)
- Auth helpers → Database connection: uses (evidence: `php/auth_helpers.php`)
- Facebook client → Graph request: sends (evidence: `php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookClient.php`)
- Facebook client → HTTP transport: dispatches via (evidence: `php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookClient.php`)
- HTTP transport → Facebook Graph API: calls
- Facebook client → Graph response: builds (evidence: `php/lib/facebook-php-sdk-v4-5.0.0/src/Facebook/FacebookClient.php`)
