# zanctarian/fos architecture

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

- Interactive diagram: https://gitdiagram.com/zanctarian/fos
- Repository: https://github.com/zanctarian/fos

## Overview

This is a browser-based, multiplayer social game: players enter a Phaser world, move between rooms, customize avatars, and interact through chat and emotes. The client also includes mini-games and a Sun Block shop; the server provides room and account services backed by Firebase. The graph preserves these major capabilities, but not every connection is visible in the excerpts: unsampled features are included only where the tree or README supports their existence, and uncertain links are omitted.

Main entry points: [`client/game.js`](https://github.com/zanctarian/fos/blob/main/client/game.js) (Game bootstrap), [`client/scenes/Forest.js`](https://github.com/zanctarian/fos/blob/main/client/scenes/Forest.js) (Forest scene), [`client/world/UIManager.js`](https://github.com/zanctarian/fos/blob/main/client/world/UIManager.js) (Chat and menus), [`server/server.js`](https://github.com/zanctarian/fos/blob/main/server/server.js) (Server entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_world["Game world"]
  node_game["Game bootstrap<br/>[game.js]"]
  node_preloader["Asset preloader<br/>[Preloader.js]"]
  node_forest["Forest scene<br/>[Forest.js]"]
  node_uptown["Uptown scenes<br/>[Uptown.js]"]
  node_other_scenes["Other world scenes"]
  node_transitions["Room transitions<br/>[roomTransition.js]"]
  node_movement["Player movement<br/>[playerMovement.js]"]
end

subgraph group_social["Social play"]
  node_ui["Chat and menus<br/>[UIManager.js]"]
  node_animations["Emotes and animations<br/>[animations.js]"]
  node_players["Remote players<br/>[playerManager.js]"]
  node_socket["Room networking<br/>[socket.js]"]
end

subgraph group_features["Player features"]
  node_avatar["Avatar builder<br/>[avatar.js]"]
  node_inventory["Wardrobe inventory<br/>[inventory.js]"]
  node_sunblock["Sun Block shop<br/>[sunBlock.js]"]
  node_shops["Shop support<br/>[shops.js]"]
  node_minigames["Mini-games"]
  node_mouseout["Mouse Out<br/>[mouseOut.js]"]
  node_typeboo["Type Boo<br/>[typeBoo.js]"]
end

subgraph group_backend["Game services"]
  node_server["Server entry<br/>[server.js]"]
  node_room["Game room<br/>[GameRoom.ts]"]
  node_roomstate["Room state<br/>[RoomState.ts]"]
  node_playerstate["Player state<br/>[PlayerState.ts]"]
  node_auth["Authentication routes<br/>[auth.js]"]
  node_user["User routes<br/>[user.js]"]
end

subgraph group_persistence["Account storage"]
  node_firebase[("Firebase services<br/>[firebaseAdmin.js]")]
end

node_player(("Player"))
node_firebase_service[("Firebase")]

node_player -->|"opens"| node_game
node_game -->|"registers"| node_preloader
node_game -->|"registers"| node_forest
node_game -->|"registers"| node_uptown
node_game -->|"registers"| node_other_scenes
node_forest -->|"joins room"| node_socket
node_uptown -->|"joins room"| node_socket
node_forest -->|"sets up"| node_movement
node_uptown -->|"creates"| node_transitions
node_forest -->|"creates"| node_transitions
node_ui -->|"maps to"| node_transitions
node_ui -->|"toggles"| node_animations
node_ui -->|"opens"| node_inventory
node_player -->|"chats through"| node_ui
node_socket -->|"displays chat"| node_ui
node_socket -->|"plays"| node_animations
node_forest -->|"initializes"| node_players
node_players -->|"creates"| node_animations
node_player -.->|"plays"| node_minigames
node_minigames -->|"includes"| node_mouseout
node_minigames -->|"includes"| node_typeboo
node_player -.->|"customizes"| node_inventory
node_player -.->|"shops"| node_sunblock
node_shops -.->|"supports"| node_sunblock
node_game -->|"checks account"| node_server
node_server -->|"registers"| node_room
node_server -->|"routes to"| node_auth
node_server -->|"routes to"| node_user
node_room -->|"uses state"| node_roomstate
node_room -->|"uses state"| node_playerstate
node_auth -->|"uses"| node_firebase
node_user -->|"uses"| node_firebase
node_firebase -->|"connects"| node_firebase_service

click node_game "https://github.com/zanctarian/fos/blob/main/client/game.js"
click node_preloader "https://github.com/zanctarian/fos/blob/main/client/scenes/Preloader.js"
click node_forest "https://github.com/zanctarian/fos/blob/main/client/scenes/Forest.js"
click node_uptown "https://github.com/zanctarian/fos/blob/main/client/scenes/Uptown.js"
click node_other_scenes "https://github.com/zanctarian/fos/tree/main/client/scenes"
click node_transitions "https://github.com/zanctarian/fos/blob/main/client/world/roomTransition.js"
click node_movement "https://github.com/zanctarian/fos/blob/main/client/world/playerMovement.js"
click node_avatar "https://github.com/zanctarian/fos/blob/main/client/world/avatar.js"
click node_inventory "https://github.com/zanctarian/fos/blob/main/client/world/inventory.js"
click node_sunblock "https://github.com/zanctarian/fos/blob/main/client/world/sunBlock.js"
click node_shops "https://github.com/zanctarian/fos/blob/main/client/world/shops.js"
click node_minigames "https://github.com/zanctarian/fos/tree/main/client/minigames"
click node_mouseout "https://github.com/zanctarian/fos/blob/main/client/minigames/mouseOut.js"
click node_typeboo "https://github.com/zanctarian/fos/blob/main/client/minigames/typeBoo.js"
click node_ui "https://github.com/zanctarian/fos/blob/main/client/world/UIManager.js"
click node_animations "https://github.com/zanctarian/fos/blob/main/client/world/animations.js"
click node_players "https://github.com/zanctarian/fos/blob/main/client/world/playerManager.js"
click node_socket "https://github.com/zanctarian/fos/blob/main/client/network/socket.js"
click node_server "https://github.com/zanctarian/fos/blob/main/server/server.js"
click node_room "https://github.com/zanctarian/fos/blob/main/server/rooms/GameRoom.ts"
click node_roomstate "https://github.com/zanctarian/fos/blob/main/server/schema/RoomState.ts"
click node_playerstate "https://github.com/zanctarian/fos/blob/main/server/schema/PlayerState.ts"
click node_auth "https://github.com/zanctarian/fos/blob/main/server/routes/auth.js"
click node_user "https://github.com/zanctarian/fos/blob/main/server/routes/user.js"
click node_firebase "https://github.com/zanctarian/fos/blob/main/server/firebase/firebaseAdmin.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_game,node_preloader,node_forest,node_uptown,node_other_scenes,node_transitions,node_movement toneBlue
class node_ui,node_animations,node_players,node_socket,node_firebase_service toneAmber
class node_avatar,node_inventory,node_sunblock,node_shops,node_minigames,node_mouseout,node_typeboo toneMint
class node_server,node_room,node_roomstate,node_playerstate,node_auth,node_user toneRose
class node_firebase,node_player toneIndigo
```

## Components

### Game world

- [Game bootstrap](https://github.com/zanctarian/fos/blob/main/client/game.js): `client/game.js`
- [Asset preloader](https://github.com/zanctarian/fos/blob/main/client/scenes/Preloader.js): `client/scenes/Preloader.js`
- [Forest scene](https://github.com/zanctarian/fos/blob/main/client/scenes/Forest.js): `client/scenes/Forest.js`
- [Uptown scenes](https://github.com/zanctarian/fos/blob/main/client/scenes/Uptown.js): `client/scenes/Uptown.js`
- [Other world scenes](https://github.com/zanctarian/fos/tree/main/client/scenes): `client/scenes`
- [Room transitions](https://github.com/zanctarian/fos/blob/main/client/world/roomTransition.js): `client/world/roomTransition.js`
- [Player movement](https://github.com/zanctarian/fos/blob/main/client/world/playerMovement.js): `client/world/playerMovement.js`

### Social play

- [Chat and menus](https://github.com/zanctarian/fos/blob/main/client/world/UIManager.js): `client/world/UIManager.js`
- [Emotes and animations](https://github.com/zanctarian/fos/blob/main/client/world/animations.js): `client/world/animations.js`
- [Remote players](https://github.com/zanctarian/fos/blob/main/client/world/playerManager.js): `client/world/playerManager.js`
- [Room networking](https://github.com/zanctarian/fos/blob/main/client/network/socket.js): `client/network/socket.js`

### Player features

- [Avatar builder](https://github.com/zanctarian/fos/blob/main/client/world/avatar.js): `client/world/avatar.js`
- [Wardrobe inventory](https://github.com/zanctarian/fos/blob/main/client/world/inventory.js): `client/world/inventory.js`
- [Sun Block shop](https://github.com/zanctarian/fos/blob/main/client/world/sunBlock.js): `client/world/sunBlock.js`
- [Shop support](https://github.com/zanctarian/fos/blob/main/client/world/shops.js): `client/world/shops.js`
- [Mini-games](https://github.com/zanctarian/fos/tree/main/client/minigames): `client/minigames`
- [Mouse Out](https://github.com/zanctarian/fos/blob/main/client/minigames/mouseOut.js): `client/minigames/mouseOut.js`
- [Type Boo](https://github.com/zanctarian/fos/blob/main/client/minigames/typeBoo.js): `client/minigames/typeBoo.js`

### Game services

- [Server entry](https://github.com/zanctarian/fos/blob/main/server/server.js): `server/server.js`
- [Game room](https://github.com/zanctarian/fos/blob/main/server/rooms/GameRoom.ts): `server/rooms/GameRoom.ts`
- [Room state](https://github.com/zanctarian/fos/blob/main/server/schema/RoomState.ts): `server/schema/RoomState.ts`
- [Player state](https://github.com/zanctarian/fos/blob/main/server/schema/PlayerState.ts): `server/schema/PlayerState.ts`
- [Authentication routes](https://github.com/zanctarian/fos/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [User routes](https://github.com/zanctarian/fos/blob/main/server/routes/user.js): `server/routes/user.js`

### Account storage

- [Firebase services](https://github.com/zanctarian/fos/blob/main/server/firebase/firebaseAdmin.js): `server/firebase/firebaseAdmin.js`

### Other components

- **Player**
- **Firebase**

## Connections

- Player → Game bootstrap: opens (evidence: `client/game.js`)
- Game bootstrap → Asset preloader: registers (evidence: `client/game.js`)
- Game bootstrap → Forest scene: registers (evidence: `client/game.js`)
- Game bootstrap → Uptown scenes: registers (evidence: `client/game.js`)
- Game bootstrap → Other world scenes: registers (evidence: `client/game.js`)
- Forest scene → Room networking: joins room (evidence: `client/scenes/Forest.js`)
- Uptown scenes → Room networking: joins room (evidence: `client/scenes/Uptown.js`)
- Forest scene → Player movement: sets up (evidence: `client/scenes/Forest.js`)
- Uptown scenes → Room transitions: creates (evidence: `client/scenes/Uptown.js`)
- Forest scene → Room transitions: creates (evidence: `client/scenes/Forest.js`)
- Chat and menus → Room transitions: maps to (evidence: `client/world/UIManager.js`)
- Chat and menus → Emotes and animations: toggles (evidence: `client/world/UIManager.js`)
- Chat and menus → Wardrobe inventory: opens (evidence: `client/world/UIManager.js`)
- Player → Chat and menus: chats through (evidence: `client/world/UIManager.js`)
- Room networking → Chat and menus: displays chat (evidence: `client/network/socket.js`)
- Room networking → Emotes and animations: plays (evidence: `client/network/socket.js`)
- Forest scene → Remote players: initializes (evidence: `client/scenes/Forest.js`)
- Remote players → Emotes and animations: creates (evidence: `client/world/playerManager.js`)
- Player → Mini-games: plays
- Mini-games → Mouse Out: includes
- Mini-games → Type Boo: includes
- Player → Wardrobe inventory: customizes
- Player → Sun Block shop: shops
- Shop support → Sun Block shop: supports
- Game bootstrap → Server entry: checks account (evidence: `client/game.js`)
- Server entry → Game room: registers (evidence: `server/server.js`)
- Server entry → Authentication routes: routes to (evidence: `server/server.js`)
- Server entry → User routes: routes to (evidence: `server/server.js`)
- Game room → Room state: uses state (evidence: `server/rooms/GameRoom.ts`)
- Game room → Player state: uses state (evidence: `server/rooms/GameRoom.ts`)
- Authentication routes → Firebase services: uses (evidence: `server/routes/auth.js`)
- User routes → Firebase services: uses (evidence: `server/routes/user.js`)
- Firebase services → Firebase: connects (evidence: `README.md`)
