# dongpal0825/toy-playground architecture

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

- Interactive diagram: https://gitdiagram.com/dongpal0825/toy-playground
- Repository: https://github.com/dongpal0825/toy-playground

## Overview

Toy Playground is a browser-based multiplayer 3D game. Users register or log in, choose a toy, color, and room, then enter a playground where Socket.IO shares room-scoped movement, chat, emotes, and ride state. The site also provides a shared posts board and account/admin workflows. The graph retains the documented 3D assets and fallback map. Some client and route details are represented from README descriptions and the source index; unsampled implementation links are omitted where evidence is insufficient.

Main entry points: [`app.js`](https://github.com/dongpal0825/toy-playground/blob/main/app.js) (Express app), [`sockets/index.js`](https://github.com/dongpal0825/toy-playground/blob/main/sockets/index.js) (Realtime events), [`schema.sql`](https://github.com/dongpal0825/toy-playground/blob/main/schema.sql) (MariaDB), [`lib/accounts.js`](https://github.com/dongpal0825/toy-playground/blob/main/lib/accounts.js) (Account services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web and Accounts"]
  node_app["Express app<br/>[app.js]"]
  node_auth["Authentication<br/>[auth.js]"]
  node_lobby["Room selection<br/>[lobby.js]"]
  node_account["Account deletion<br/>[account.js]"]
  node_database[("MariaDB<br/>[schema.sql]")]
end

subgraph group_multiplayer["Multiplayer Runtime"]
  node_socket["Realtime events<br/>[index.js]"]
  node_rooms["Room state<br/>[rooms.js]"]
  node_rides["Ride seats<br/>[rides.js]"]
  node_accounts["Account services<br/>[accounts.js]"]
  node_realtime["Socket access<br/>[realtime.js]"]
end

subgraph group_playground["Playground Client"]
  node_play["Play interface<br/>[play.js]"]
  node_scene["3D scene<br/>[game3d.js]"]
  node_characters["Toy characters<br/>[characters.js]"]
  node_loader["GLB loader<br/>[loader.js]"]
  node_map["Map fallback<br/>[map.js]"]
  node_rideview["Ride animation<br/>[rides.js]"]
  node_models["3D assets"]
end

subgraph group_content["Posts and Administration"]
  node_board["Board interface<br/>[board.js]"]
  node_posts["Posts API<br/>[posts.js]"]
  node_admin["Admin tools<br/>[admin.js]"]
  node_erd["ERD display<br/>[admin-erd.js]"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens site"| node_app
node_app -->|"mounts routes"| node_auth
node_app -->|"mounts routes"| node_lobby
node_app -->|"mounts routes"| node_account
node_app -->|"mounts routes"| node_admin
node_app -->|"mounts API"| node_posts
node_app -->|"starts sockets"| node_socket
node_app -->|"connects pool"| node_database
node_auth -->|"reads and writes"| node_database
node_lobby -->|"reads and updates"| node_database
node_lobby -->|"reads counts"| node_rooms
node_account -->|"deletes account"| node_accounts
node_accounts -->|"deletes user"| node_database
node_accounts -->|"finds session"| node_rooms
node_accounts -->|"gets socket server"| node_realtime
node_socket -->|"stores chat and logs"| node_database
node_socket -->|"updates room state"| node_rooms
node_socket -->|"updates ride seats"| node_rides
node_socket -->|"checks account"| node_accounts
node_socket -->|"registers server"| node_realtime
node_play -->|"exchanges events"| node_socket
node_play -->|"starts scene"| node_scene
node_play -->|"opens board"| node_board
node_board -->|"calls API"| node_posts
node_posts -->|"stores posts"| node_database
node_posts -->|"announces new posts"| node_realtime
node_scene -->|"creates characters"| node_characters
node_scene -->|"loads models"| node_loader
node_scene -->|"falls back to map"| node_map
node_scene -->|"creates rides"| node_rideview
node_characters -->|"loads toy models"| node_loader
node_loader -->|"fetches GLB"| node_models
node_admin -->|"deletes users"| node_accounts
node_admin -->|"reads schema"| node_database
node_admin -->|"renders ERD"| node_erd

click node_app "https://github.com/dongpal0825/toy-playground/blob/main/app.js"
click node_auth "https://github.com/dongpal0825/toy-playground/blob/main/routes/auth.js"
click node_lobby "https://github.com/dongpal0825/toy-playground/blob/main/routes/lobby.js"
click node_account "https://github.com/dongpal0825/toy-playground/blob/main/routes/account.js"
click node_database "https://github.com/dongpal0825/toy-playground/blob/main/schema.sql"
click node_socket "https://github.com/dongpal0825/toy-playground/blob/main/sockets/index.js"
click node_rooms "https://github.com/dongpal0825/toy-playground/blob/main/game/rooms.js"
click node_rides "https://github.com/dongpal0825/toy-playground/blob/main/game/rides.js"
click node_accounts "https://github.com/dongpal0825/toy-playground/blob/main/lib/accounts.js"
click node_realtime "https://github.com/dongpal0825/toy-playground/blob/main/lib/realtime.js"
click node_play "https://github.com/dongpal0825/toy-playground/blob/main/public/js/play.js"
click node_scene "https://github.com/dongpal0825/toy-playground/blob/main/public/js/game3d.js"
click node_characters "https://github.com/dongpal0825/toy-playground/blob/main/public/js/characters.js"
click node_loader "https://github.com/dongpal0825/toy-playground/blob/main/public/js/loader.js"
click node_map "https://github.com/dongpal0825/toy-playground/blob/main/public/js/map.js"
click node_rideview "https://github.com/dongpal0825/toy-playground/blob/main/public/js/rides.js"
click node_models "https://github.com/dongpal0825/toy-playground/tree/main/public/models"
click node_board "https://github.com/dongpal0825/toy-playground/blob/main/public/js/board.js"
click node_posts "https://github.com/dongpal0825/toy-playground/blob/main/routes/posts.js"
click node_admin "https://github.com/dongpal0825/toy-playground/blob/main/routes/admin.js"
click node_erd "https://github.com/dongpal0825/toy-playground/blob/main/public/js/admin-erd.js"

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_app,node_auth,node_lobby,node_account,node_database toneBlue
class node_socket,node_rooms,node_rides,node_accounts,node_realtime toneAmber
class node_play,node_scene,node_characters,node_loader,node_map,node_rideview,node_models toneMint
class node_board,node_posts,node_admin,node_erd toneRose
class node_visitor toneIndigo
```

## Components

### Web and Accounts

- [Express app](https://github.com/dongpal0825/toy-playground/blob/main/app.js): `app.js`
- [Authentication](https://github.com/dongpal0825/toy-playground/blob/main/routes/auth.js): `routes/auth.js`
- [Room selection](https://github.com/dongpal0825/toy-playground/blob/main/routes/lobby.js): `routes/lobby.js`
- [Account deletion](https://github.com/dongpal0825/toy-playground/blob/main/routes/account.js): `routes/account.js`
- [MariaDB](https://github.com/dongpal0825/toy-playground/blob/main/schema.sql): `schema.sql`

### Multiplayer Runtime

- [Realtime events](https://github.com/dongpal0825/toy-playground/blob/main/sockets/index.js): `sockets/index.js`
- [Room state](https://github.com/dongpal0825/toy-playground/blob/main/game/rooms.js): `game/rooms.js`
- [Ride seats](https://github.com/dongpal0825/toy-playground/blob/main/game/rides.js): `game/rides.js`
- [Account services](https://github.com/dongpal0825/toy-playground/blob/main/lib/accounts.js): `lib/accounts.js`
- [Socket access](https://github.com/dongpal0825/toy-playground/blob/main/lib/realtime.js): `lib/realtime.js`

### Playground Client

- [Play interface](https://github.com/dongpal0825/toy-playground/blob/main/public/js/play.js): `public/js/play.js`
- [3D scene](https://github.com/dongpal0825/toy-playground/blob/main/public/js/game3d.js): `public/js/game3d.js`
- [Toy characters](https://github.com/dongpal0825/toy-playground/blob/main/public/js/characters.js): `public/js/characters.js`
- [GLB loader](https://github.com/dongpal0825/toy-playground/blob/main/public/js/loader.js): `public/js/loader.js`
- [Map fallback](https://github.com/dongpal0825/toy-playground/blob/main/public/js/map.js): `public/js/map.js`
- [Ride animation](https://github.com/dongpal0825/toy-playground/blob/main/public/js/rides.js): `public/js/rides.js`
- [3D assets](https://github.com/dongpal0825/toy-playground/tree/main/public/models): `public/models`

### Posts and Administration

- [Board interface](https://github.com/dongpal0825/toy-playground/blob/main/public/js/board.js): `public/js/board.js`
- [Posts API](https://github.com/dongpal0825/toy-playground/blob/main/routes/posts.js): `routes/posts.js`
- [Admin tools](https://github.com/dongpal0825/toy-playground/blob/main/routes/admin.js): `routes/admin.js`
- [ERD display](https://github.com/dongpal0825/toy-playground/blob/main/public/js/admin-erd.js): `public/js/admin-erd.js`

### Other components

- **Visitor**

## Connections

- Visitor → Express app: opens site (evidence: `README.md`)
- Express app → Authentication: mounts routes (evidence: `app.js`)
- Express app → Room selection: mounts routes (evidence: `app.js`)
- Express app → Account deletion: mounts routes (evidence: `app.js`)
- Express app → Admin tools: mounts routes (evidence: `app.js`)
- Express app → Posts API: mounts API (evidence: `app.js`)
- Express app → Realtime events: starts sockets (evidence: `app.js`)
- Express app → MariaDB: connects pool (evidence: `app.js`)
- Authentication → MariaDB: reads and writes (evidence: `routes/auth.js`)
- Room selection → MariaDB: reads and updates (evidence: `routes/lobby.js`)
- Room selection → Room state: reads counts (evidence: `routes/lobby.js`)
- Account deletion → Account services: deletes account (evidence: `routes/account.js`)
- Account services → MariaDB: deletes user (evidence: `lib/accounts.js`)
- Account services → Room state: finds session (evidence: `lib/accounts.js`)
- Account services → Socket access: gets socket server (evidence: `lib/accounts.js`)
- Realtime events → MariaDB: stores chat and logs (evidence: `sockets/index.js`)
- Realtime events → Room state: updates room state (evidence: `sockets/index.js`)
- Realtime events → Ride seats: updates ride seats (evidence: `sockets/index.js`)
- Realtime events → Account services: checks account (evidence: `sockets/index.js`)
- Realtime events → Socket access: registers server (evidence: `sockets/index.js`)
- Play interface → Realtime events: exchanges events (evidence: `README.md`)
- Play interface → 3D scene: starts scene (evidence: `public/js/play.js`)
- Play interface → Board interface: opens board (evidence: `public/js/play.js`)
- Board interface → Posts API: calls API (evidence: `README.md`)
- Posts API → MariaDB: stores posts (evidence: `README.md`)
- Posts API → Socket access: announces new posts (evidence: `README.md`)
- 3D scene → Toy characters: creates characters (evidence: `public/js/game3d.js`)
- 3D scene → GLB loader: loads models (evidence: `public/js/game3d.js`)
- 3D scene → Map fallback: falls back to map (evidence: `public/js/game3d.js`)
- 3D scene → Ride animation: creates rides (evidence: `public/js/game3d.js`)
- Toy characters → GLB loader: loads toy models (evidence: `public/js/characters.js`)
- GLB loader → 3D assets: fetches GLB (evidence: `README.md`)
- Admin tools → Account services: deletes users (evidence: `routes/admin.js`)
- Admin tools → MariaDB: reads schema (evidence: `routes/admin.js`)
- Admin tools → ERD display: renders ERD (evidence: `README.md`)
