# jworkss/socketio architecture

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

- Interactive diagram: https://gitdiagram.com/jworkss/socketio
- Repository: https://github.com/jworkss/socketio

## Overview

Onda en Juego is a real-time multiplayer sound-and-wave drawing game. Players authenticate or enter as guests, join a 3–5-player room, configure and calibrate the microphone, then take turns recording audio while others draw waveforms; the server compares submissions, awards points, and broadcasts results. The diagram separates browser interaction, server-side domain handling, and JSON persistence. README documents the overall Socket.IO flow; some client/server event wiring and portions of game logic were not sampled, so those links rely on that documentation.

Main entry points: [`public/main.js`](https://github.com/jworkss/socketio/blob/main/public/main.js) (Client startup), [`public/mic-calibration.js`](https://github.com/jworkss/socketio/blob/main/public/mic-calibration.js) (Mic calibration), [`public/rooms.js`](https://github.com/jworkss/socketio/blob/main/public/rooms.js) (Lobby and rooms), [`public/game.js`](https://github.com/jworkss/socketio/blob/main/public/game.js) (Round and drawing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_webapp["Game interface<br/>[index.html]"]
  node_client_entry["Client startup<br/>[main.js]"]
  node_session_state["Session and views<br/>[app-state.js]"]
  node_auth_ui["Access and admin<br/>[auth.js]"]
  node_room_ui["Lobby and rooms<br/>[rooms.js]"]
  node_mic_ui["Mic calibration<br/>[mic-calibration.js]"]
  node_audio_engine["Audio engine<br/>[audioEngine.js]"]
  node_game_ui["Round and drawing<br/>[game.js]"]
end

subgraph group_server["Game server"]
  node_server_entry["HTTPS and Socket.IO<br/>[server.js]"]
  node_auth_handlers["Authentication handlers<br/>[auth.js]"]
  node_room_handlers["Room management<br/>[rooms.js]"]
  node_game_service["Rounds and scoring<br/>[game.js]"]
end

subgraph group_storage["JSON storage"]
  node_persistence["JSON persistence<br/>[persistence.js]"]
  node_users_data[("Users and scores<br/>[users.json]")]
  node_audio_data[("Audio metadata<br/>[audioData.json]")]
end

node_player(("Player"))
node_microphone(("Browser microphone"))

node_player -->|"uses"| node_webapp
node_webapp -->|"loads"| node_client_entry
node_client_entry -->|"initializes"| node_auth_ui
node_client_entry -->|"initializes"| node_room_ui
node_client_entry -->|"initializes"| node_mic_ui
node_client_entry -->|"initializes"| node_game_ui
node_auth_ui -->|"updates"| node_session_state
node_room_ui -->|"updates"| node_session_state
node_room_ui -->|"opens"| node_mic_ui
node_mic_ui -->|"controls"| node_audio_engine
node_game_ui -->|"records and plays"| node_audio_engine
node_game_ui -->|"closes calibration"| node_mic_ui
node_auth_ui -->|"sends auth events"| node_auth_handlers
node_room_ui -->|"sends room events"| node_room_handlers
node_game_ui -->|"sends game events"| node_game_service
node_server_entry -->|"registers"| node_auth_handlers
node_server_entry -->|"registers"| node_room_handlers
node_server_entry -->|"creates and registers"| node_game_service
node_auth_handlers -->|"reads and writes users"| node_persistence
node_game_service -->|"reads and writes data"| node_persistence
node_persistence -->|"reads and writes"| node_users_data
node_persistence -->|"reads and writes"| node_audio_data
node_mic_ui -->|"requests access"| node_microphone

click node_webapp "https://github.com/jworkss/socketio/blob/main/public/index.html"
click node_client_entry "https://github.com/jworkss/socketio/blob/main/public/main.js"
click node_session_state "https://github.com/jworkss/socketio/blob/main/public/app-state.js"
click node_auth_ui "https://github.com/jworkss/socketio/blob/main/public/auth.js"
click node_room_ui "https://github.com/jworkss/socketio/blob/main/public/rooms.js"
click node_mic_ui "https://github.com/jworkss/socketio/blob/main/public/mic-calibration.js"
click node_audio_engine "https://github.com/jworkss/socketio/blob/main/public/audioEngine.js"
click node_game_ui "https://github.com/jworkss/socketio/blob/main/public/game.js"
click node_server_entry "https://github.com/jworkss/socketio/blob/main/server.js"
click node_auth_handlers "https://github.com/jworkss/socketio/blob/main/server/auth.js"
click node_room_handlers "https://github.com/jworkss/socketio/blob/main/server/rooms.js"
click node_game_service "https://github.com/jworkss/socketio/blob/main/server/game.js"
click node_persistence "https://github.com/jworkss/socketio/blob/main/server/persistence.js"
click node_users_data "https://github.com/jworkss/socketio/blob/main/data/users.json"
click node_audio_data "https://github.com/jworkss/socketio/blob/main/data/audioData.json"

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_webapp,node_client_entry,node_session_state,node_auth_ui,node_room_ui,node_mic_ui,node_audio_engine,node_game_ui,node_microphone toneBlue
class node_server_entry,node_auth_handlers,node_room_handlers,node_game_service toneAmber
class node_persistence,node_users_data,node_audio_data toneMint
class node_player toneIndigo
```

## Components

### Browser experience

- [Game interface](https://github.com/jworkss/socketio/blob/main/public/index.html): `public/index.html`
- [Client startup](https://github.com/jworkss/socketio/blob/main/public/main.js): `public/main.js`
- [Session and views](https://github.com/jworkss/socketio/blob/main/public/app-state.js): `public/app-state.js`
- [Access and admin](https://github.com/jworkss/socketio/blob/main/public/auth.js): `public/auth.js`
- [Lobby and rooms](https://github.com/jworkss/socketio/blob/main/public/rooms.js): `public/rooms.js`
- [Mic calibration](https://github.com/jworkss/socketio/blob/main/public/mic-calibration.js): `public/mic-calibration.js`
- [Audio engine](https://github.com/jworkss/socketio/blob/main/public/audioEngine.js): `public/audioEngine.js`
- [Round and drawing](https://github.com/jworkss/socketio/blob/main/public/game.js): `public/game.js`

### Game server

- [HTTPS and Socket.IO](https://github.com/jworkss/socketio/blob/main/server.js): `server.js`
- [Authentication handlers](https://github.com/jworkss/socketio/blob/main/server/auth.js): `server/auth.js`
- [Room management](https://github.com/jworkss/socketio/blob/main/server/rooms.js): `server/rooms.js`
- [Rounds and scoring](https://github.com/jworkss/socketio/blob/main/server/game.js): `server/game.js`

### JSON storage

- [JSON persistence](https://github.com/jworkss/socketio/blob/main/server/persistence.js): `server/persistence.js`
- [Users and scores](https://github.com/jworkss/socketio/blob/main/data/users.json): `data/users.json`
- [Audio metadata](https://github.com/jworkss/socketio/blob/main/data/audioData.json): `data/audioData.json`

### Other components

- **Player**
- **Browser microphone**

## Connections

- Player → Game interface: uses (evidence: `README.md`)
- Game interface → Client startup: loads (evidence: `README.md`)
- Client startup → Access and admin: initializes (evidence: `public/main.js`)
- Client startup → Lobby and rooms: initializes (evidence: `public/main.js`)
- Client startup → Mic calibration: initializes (evidence: `public/main.js`)
- Client startup → Round and drawing: initializes (evidence: `public/main.js`)
- Access and admin → Session and views: updates (evidence: `public/auth.js`)
- Lobby and rooms → Session and views: updates (evidence: `public/rooms.js`)
- Lobby and rooms → Mic calibration: opens (evidence: `public/rooms.js`)
- Mic calibration → Audio engine: controls (evidence: `public/mic-calibration.js`)
- Round and drawing → Audio engine: records and plays (evidence: `public/game.js`)
- Round and drawing → Mic calibration: closes calibration (evidence: `public/game.js`)
- Access and admin → Authentication handlers: sends auth events (evidence: `README.md`)
- Lobby and rooms → Room management: sends room events (evidence: `README.md`)
- Round and drawing → Rounds and scoring: sends game events (evidence: `README.md`)
- HTTPS and Socket.IO → Authentication handlers: registers (evidence: `server.js`)
- HTTPS and Socket.IO → Room management: registers (evidence: `server.js`)
- HTTPS and Socket.IO → Rounds and scoring: creates and registers (evidence: `server.js`)
- Authentication handlers → JSON persistence: reads and writes users (evidence: `server/auth.js`)
- Rounds and scoring → JSON persistence: reads and writes data (evidence: `server/game.js`)
- JSON persistence → Users and scores: reads and writes (evidence: `server/persistence.js`)
- JSON persistence → Audio metadata: reads and writes (evidence: `server/persistence.js`)
- Mic calibration → Browser microphone: requests access (evidence: `README.md`)
