# leonardomacedocano/pipehero architecture

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

- Interactive diagram: https://gitdiagram.com/leonardomacedocano/pipehero
- Repository: https://github.com/leonardomacedocano/pipehero

## Overview

PipeHero is a browser-based rhythm game with optional self-hosted server features. The main player flow is song selection, chart/audio loading, live input and timing judgment, then score/results; settings and touch/gamepad controls support that loop. The server adds accounts, score persistence, achievements, friends, missions, coins, and cosmetics. Edges reflect excerpted calls, the source index, or README statements; several UI and server subsystems are represented at their implementation paths because their detailed source was not sampled.

Main entry points: [`src/server/db.ts`](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/db.ts) (PostgreSQL), [`src/ui/hooks/useGamePlaythrough.ts`](https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/hooks/useGamePlaythrough.ts) (Playthrough controls), [`src/server/scoreRoutes.ts`](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/scoreRoutes.ts) (Scores and missions), [`src/engine/gameEngine.ts`](https://github.com/leonardomacedocano/pipehero/blob/main/src/engine/gameEngine.ts) (Game rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_app["App navigation<br/>[App.tsx]"]
  node_songmenu["Song selection<br/>[SongMenuPage.tsx]"]
  node_gamepage["Game screen<br/>[GamePage.tsx]"]
  node_results["Results screen<br/>[ResultsOverlay.tsx]"]
end

subgraph group_play["Rhythm gameplay"]
  node_playthrough["Playthrough controls"]
  node_engine["Game rules<br/>[gameEngine.ts]"]
  node_judge["Timing judgment<br/>[judge.ts]"]
  node_power["Star Power<br/>[starPower.ts]"]
  node_canvas["Gameplay rendering<br/>[draw.ts]"]
end

subgraph group_server["Server platform"]
  node_songlib["Song library<br/>[songLibrary.ts]"]
  node_server["HTTP server<br/>[server.ts]"]
  node_api["API dispatch<br/>[apiDispatch.ts]"]
  node_auth["Authentication<br/>[authRoutes.ts]"]
  node_db[("PostgreSQL<br/>[db.ts]")]
end

subgraph group_social["Player services"]
  node_scores["Scores and missions<br/>[scoreRoutes.ts]"]
  node_achievements["Achievements<br/>[achievements.ts]"]
  node_friends["Friends and rankings<br/>[friendsRoutes.ts]"]
  node_economy["Missions and coins<br/>[economy.ts]"]
  node_shop["Shop and cosmetics<br/>[shop.ts]"]
  node_settings["Settings sync<br/>[settingsRoutes.ts]"]
end

node_player(("Player"))

node_player -->|"opens"| node_app
node_app -->|"navigates"| node_songmenu
node_songmenu -.->|"browses songs"| node_songlib
node_player -->|"plays"| node_playthrough
node_playthrough -->|"updates rules"| node_engine
node_engine -->|"classifies timing"| node_judge
node_engine -->|"checks phrases"| node_power
node_playthrough -->|"renders frames"| node_canvas
node_gamepage -.->|"hosts gameplay"| node_playthrough
node_playthrough -.->|"shows outcome"| node_results
node_server -->|"loads library"| node_songlib
node_server -->|"dispatches requests"| node_api
node_api -.->|"routes auth"| node_auth
node_auth -->|"persists sessions"| node_db
node_scores -->|"reads and writes"| node_db
node_scores -->|"evaluates unlocks"| node_achievements
node_scores -->|"updates missions"| node_economy
node_friends -->|"evaluates unlocks"| node_achievements
node_friends -->|"queries records"| node_db
node_economy -->|"stores balances"| node_db
node_settings -->|"stores preferences"| node_db
node_settings -->|"checks ownership"| node_shop
node_shop -.->|"stores purchases"| node_db

click node_app "https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/App.tsx"
click node_songmenu "https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/pages/SongMenuPage.tsx"
click node_songlib "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/songLibrary.ts"
click node_playthrough "https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/hooks/useGamePlaythrough.ts"
click node_engine "https://github.com/leonardomacedocano/pipehero/blob/main/src/engine/gameEngine.ts"
click node_judge "https://github.com/leonardomacedocano/pipehero/blob/main/src/engine/judge.ts"
click node_power "https://github.com/leonardomacedocano/pipehero/blob/main/src/engine/starPower.ts"
click node_canvas "https://github.com/leonardomacedocano/pipehero/blob/main/src/render/draw.ts"
click node_gamepage "https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/pages/GamePage.tsx"
click node_results "https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/components/ResultsOverlay.tsx"
click node_server "https://github.com/leonardomacedocano/pipehero/blob/main/server.ts"
click node_api "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/apiDispatch.ts"
click node_auth "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/authRoutes.ts"
click node_db "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/db.ts"
click node_scores "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/scoreRoutes.ts"
click node_achievements "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/achievements.ts"
click node_friends "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/friendsRoutes.ts"
click node_economy "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/economy.ts"
click node_shop "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/shop.ts"
click node_settings "https://github.com/leonardomacedocano/pipehero/blob/main/src/server/settingsRoutes.ts"

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_songmenu,node_gamepage,node_results toneBlue
class node_playthrough,node_engine,node_judge,node_power,node_canvas toneAmber
class node_songlib,node_server,node_api,node_auth,node_db toneMint
class node_scores,node_achievements,node_friends,node_economy,node_shop,node_settings toneRose
class node_player toneIndigo
```

## Components

### Browser experience

- [App navigation](https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/App.tsx): `src/ui/App.tsx`
- [Song selection](https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/pages/SongMenuPage.tsx): `src/ui/pages/SongMenuPage.tsx`
- [Game screen](https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/pages/GamePage.tsx): `src/ui/pages/GamePage.tsx`
- [Results screen](https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/components/ResultsOverlay.tsx): `src/ui/components/ResultsOverlay.tsx`

### Rhythm gameplay

- [Playthrough controls](https://github.com/leonardomacedocano/pipehero/blob/main/src/ui/hooks/useGamePlaythrough.ts): `src/ui/hooks/useGamePlaythrough.ts`
- [Game rules](https://github.com/leonardomacedocano/pipehero/blob/main/src/engine/gameEngine.ts): `src/engine/gameEngine.ts`
- [Timing judgment](https://github.com/leonardomacedocano/pipehero/blob/main/src/engine/judge.ts): `src/engine/judge.ts`
- [Star Power](https://github.com/leonardomacedocano/pipehero/blob/main/src/engine/starPower.ts): `src/engine/starPower.ts`
- [Gameplay rendering](https://github.com/leonardomacedocano/pipehero/blob/main/src/render/draw.ts): `src/render/draw.ts`

### Server platform

- [Song library](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/songLibrary.ts): `src/server/songLibrary.ts`
- [HTTP server](https://github.com/leonardomacedocano/pipehero/blob/main/server.ts): `server.ts`
- [API dispatch](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/apiDispatch.ts): `src/server/apiDispatch.ts`
- [Authentication](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/authRoutes.ts): `src/server/authRoutes.ts`
- [PostgreSQL](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/db.ts): `src/server/db.ts`

### Player services

- [Scores and missions](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/scoreRoutes.ts): `src/server/scoreRoutes.ts`
- [Achievements](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/achievements.ts): `src/server/achievements.ts`
- [Friends and rankings](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/friendsRoutes.ts): `src/server/friendsRoutes.ts`
- [Missions and coins](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/economy.ts): `src/server/economy.ts`
- [Shop and cosmetics](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/shop.ts): `src/server/shop.ts`
- [Settings sync](https://github.com/leonardomacedocano/pipehero/blob/main/src/server/settingsRoutes.ts): `src/server/settingsRoutes.ts`

### Other components

- **Player**

## Connections

- Player → App navigation: opens (evidence: `README.md`)
- App navigation → Song selection: navigates (evidence: `src/ui/App.tsx`)
- Song selection → Song library: browses songs
- Player → Playthrough controls: plays (evidence: `README.md`)
- Playthrough controls → Game rules: updates rules (evidence: `src/ui/hooks/useGamePlaythrough.ts`)
- Game rules → Timing judgment: classifies timing (evidence: `src/engine/gameEngine.ts`)
- Game rules → Star Power: checks phrases (evidence: `src/engine/gameEngine.ts`)
- Playthrough controls → Gameplay rendering: renders frames (evidence: `src/ui/hooks/useGamePlaythrough.ts`)
- Game screen → Playthrough controls: hosts gameplay
- Playthrough controls → Results screen: shows outcome
- HTTP server → Song library: loads library (evidence: `server.ts`)
- HTTP server → API dispatch: dispatches requests (evidence: `server.ts`)
- API dispatch → Authentication: routes auth
- Authentication → PostgreSQL: persists sessions
- Scores and missions → PostgreSQL: reads and writes (evidence: `src/server/scoreRoutes.ts`)
- Scores and missions → Achievements: evaluates unlocks (evidence: `src/server/scoreRoutes.ts`)
- Scores and missions → Missions and coins: updates missions (evidence: `src/server/scoreRoutes.ts`)
- Friends and rankings → Achievements: evaluates unlocks (evidence: `src/server/friendsRoutes.ts`)
- Friends and rankings → PostgreSQL: queries records (evidence: `src/server/friendsRoutes.ts`)
- Missions and coins → PostgreSQL: stores balances (evidence: `src/server/economy.ts`)
- Settings sync → PostgreSQL: stores preferences (evidence: `src/server/settingsRoutes.ts`)
- Settings sync → Shop and cosmetics: checks ownership (evidence: `src/server/settingsRoutes.ts`)
- Shop and cosmetics → PostgreSQL: stores purchases
