# ezcraftid/taopat architecture

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

- Interactive diagram: https://gitdiagram.com/ezcraftid/taopat
- Repository: https://github.com/ezcraftid/taopat

## Overview

TaoPat is a realtime browser patting game: a player interacts with the character, the client sends pat activity to the server, and server-validated totals feed live regional leaderboard updates. The client also presents local combo, records, stamps, visual/audio effects, and background music. The graph includes server-side abuse controls, SQLite-backed state, and deployment path handling. Server excerpts are partial, so several detailed routes and persistence relationships are omitted rather than inferred.

Main entry points: [`server.js`](https://github.com/ezcraftid/taopat/blob/main/server.js) (HTTP and socket server), [`public/js/app.js`](https://github.com/ezcraftid/taopat/blob/main/public/js/app.js) (Pat input and live UI), [`public/index.html`](https://github.com/ezcraftid/taopat/blob/main/public/index.html) (Game page), [`config.js`](https://github.com/ezcraftid/taopat/blob/main/config.js) (Runtime configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser game"]
  node_page["Game page<br/>[index.html]"]
  node_client_events["Pat input and live UI<br/>[app.js]"]
  node_local_game["Combos and records<br/>[game.js]"]
  node_effects["Pat effects and audio<br/>[fx.js]"]
  node_music["Background music<br/>[music.js]"]
  node_menu["Menu controls<br/>[menu.js]"]
  node_static_assets["Game assets"]
end

subgraph group_server["Realtime server"]
  node_server["HTTP and socket server<br/>[server.js]"]
  node_guard["Abuse controls<br/>[guard.js]"]
  node_sqlite[("Game state store<br/>[server.js]")]
  node_leaderboard["Regional leaderboard<br/>[server.js]"]
  node_region_service["IP region lookup<br/>[server.js]"]
end

subgraph group_shared["Shared services"]
  node_basepath["Base-path handling<br/>[basepath.js]"]
  node_core["Shared game rules<br/>[tao-core.js]"]
end

subgraph group_runtime["Runtime support"]
  node_config["Runtime configuration<br/>[config.js]"]
  node_shutdown["Graceful shutdown<br/>[shutdown.js]"]
end

node_player(("Player"))
node_browser(("Web browser"))

node_player -->|"opens"| node_page
node_player -->|"pats"| node_client_events
node_page -.->|"loads"| node_client_events
node_client_events -.->|"sends pats"| node_server
node_server -.->|"pushes updates"| node_client_events
node_client_events -.->|"updates stats"| node_local_game
node_client_events -.->|"triggers"| node_effects
node_client_events -.->|"enables playback"| node_music
node_page -.->|"loads"| node_menu
node_effects -->|"loads audio and images"| node_static_assets
node_music -->|"loads tracks"| node_static_assets
node_server -->|"checks connections"| node_guard
node_server -->|"limits activity"| node_guard
node_server -.->|"reads and saves"| node_sqlite
node_server -.->|"publishes totals"| node_leaderboard
node_leaderboard -->|"streams regions"| node_client_events
node_server -->|"looks up regions"| node_region_service
node_server -->|"loads settings"| node_config
node_server -->|"handles prefixes"| node_basepath
node_basepath -->|"uses helpers"| node_core
node_config -->|"loads limits"| node_guard
node_config -->|"normalizes paths"| node_core
node_server -->|"runs teardown"| node_shutdown
node_browser -.->|"renders"| node_page

click node_page "https://github.com/ezcraftid/taopat/blob/main/public/index.html"
click node_client_events "https://github.com/ezcraftid/taopat/blob/main/public/js/app.js"
click node_local_game "https://github.com/ezcraftid/taopat/blob/main/public/js/game.js"
click node_effects "https://github.com/ezcraftid/taopat/blob/main/public/js/fx.js"
click node_music "https://github.com/ezcraftid/taopat/blob/main/public/js/music.js"
click node_menu "https://github.com/ezcraftid/taopat/blob/main/public/js/menu.js"
click node_static_assets "https://github.com/ezcraftid/taopat/tree/main/public/assets"
click node_server "https://github.com/ezcraftid/taopat/blob/main/server.js"
click node_guard "https://github.com/ezcraftid/taopat/blob/main/lib/guard.js"
click node_sqlite "https://github.com/ezcraftid/taopat/blob/main/server.js"
click node_leaderboard "https://github.com/ezcraftid/taopat/blob/main/server.js"
click node_config "https://github.com/ezcraftid/taopat/blob/main/config.js"
click node_shutdown "https://github.com/ezcraftid/taopat/blob/main/lib/shutdown.js"
click node_basepath "https://github.com/ezcraftid/taopat/blob/main/lib/basepath.js"
click node_core "https://github.com/ezcraftid/taopat/blob/main/public/js/tao-core.js"
click node_region_service "https://github.com/ezcraftid/taopat/blob/main/server.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_page,node_client_events,node_local_game,node_effects,node_music,node_menu,node_static_assets,node_browser toneBlue
class node_server,node_guard,node_sqlite,node_leaderboard,node_region_service toneAmber
class node_basepath,node_core toneMint
class node_config,node_shutdown toneRose
class node_player toneIndigo
```

## Components

### Browser game

- [Game page](https://github.com/ezcraftid/taopat/blob/main/public/index.html): `public/index.html`
- [Pat input and live UI](https://github.com/ezcraftid/taopat/blob/main/public/js/app.js): `public/js/app.js`
- [Combos and records](https://github.com/ezcraftid/taopat/blob/main/public/js/game.js): `public/js/game.js`
- [Pat effects and audio](https://github.com/ezcraftid/taopat/blob/main/public/js/fx.js): `public/js/fx.js`
- [Background music](https://github.com/ezcraftid/taopat/blob/main/public/js/music.js): `public/js/music.js`
- [Menu controls](https://github.com/ezcraftid/taopat/blob/main/public/js/menu.js): `public/js/menu.js`
- [Game assets](https://github.com/ezcraftid/taopat/tree/main/public/assets): `public/assets`

### Realtime server

- [HTTP and socket server](https://github.com/ezcraftid/taopat/blob/main/server.js): `server.js`
- [Abuse controls](https://github.com/ezcraftid/taopat/blob/main/lib/guard.js): `lib/guard.js`
- [Game state store](https://github.com/ezcraftid/taopat/blob/main/server.js): `server.js`
- [Regional leaderboard](https://github.com/ezcraftid/taopat/blob/main/server.js): `server.js`
- [IP region lookup](https://github.com/ezcraftid/taopat/blob/main/server.js): `server.js`

### Shared services

- [Base-path handling](https://github.com/ezcraftid/taopat/blob/main/lib/basepath.js): `lib/basepath.js`
- [Shared game rules](https://github.com/ezcraftid/taopat/blob/main/public/js/tao-core.js): `public/js/tao-core.js`

### Runtime support

- [Runtime configuration](https://github.com/ezcraftid/taopat/blob/main/config.js): `config.js`
- [Graceful shutdown](https://github.com/ezcraftid/taopat/blob/main/lib/shutdown.js): `lib/shutdown.js`

### Other components

- **Player**
- **Web browser**

## Connections

- Player → Game page: opens (evidence: `README.md`)
- Player → Pat input and live UI: pats (evidence: `README.md`)
- Game page → Pat input and live UI: loads
- Pat input and live UI → HTTP and socket server: sends pats
- HTTP and socket server → Pat input and live UI: pushes updates (evidence: `README.md`)
- Pat input and live UI → Combos and records: updates stats
- Pat input and live UI → Pat effects and audio: triggers (evidence: `public/js/fx.js`)
- Pat input and live UI → Background music: enables playback (evidence: `public/js/music.js`)
- Game page → Menu controls: loads
- Pat effects and audio → Game assets: loads audio and images (evidence: `public/js/fx.js`)
- Background music → Game assets: loads tracks (evidence: `public/js/music.js`)
- HTTP and socket server → Abuse controls: checks connections (evidence: `server.js`)
- HTTP and socket server → Abuse controls: limits activity (evidence: `server.js`)
- HTTP and socket server → Game state store: reads and saves (evidence: `server.js`)
- HTTP and socket server → Regional leaderboard: publishes totals (evidence: `server.js`)
- Regional leaderboard → Pat input and live UI: streams regions (evidence: `README.md`)
- HTTP and socket server → IP region lookup: looks up regions (evidence: `server.js`)
- HTTP and socket server → Runtime configuration: loads settings (evidence: `server.js`)
- HTTP and socket server → Base-path handling: handles prefixes (evidence: `server.js`)
- Base-path handling → Shared game rules: uses helpers (evidence: `lib/basepath.js`)
- Runtime configuration → Abuse controls: loads limits (evidence: `config.js`)
- Runtime configuration → Shared game rules: normalizes paths (evidence: `config.js`)
- HTTP and socket server → Graceful shutdown: runs teardown (evidence: `server.js`)
- Web browser → Game page: renders
