# joaoparis/go-pong architecture

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

- Interactive diagram: https://gitdiagram.com/joaoparis/go-pong
- Repository: https://github.com/joaoparis/go-pong
- Video tour (about a minute): https://gitdiagram.com/joaoparis/go-pong/video

## Overview

go-pong is a local two-player Pong game built on Ebiten. The documented workflow is to launch into a menu, select Local Game, then play; the menu also exposes host and join choices, but the sampled handlers are placeholders. The sampled code confirms game initialization, state dispatch, menu rendering, and ball/player setup. The playing-state source was not sampled, so gameplay update and draw wiring is not inferred.

Main entry points: [`internal/game/game.go`](https://github.com/joaoparis/go-pong/blob/master/internal/game/game.go) (Game Engine), [`internal/app/app.go`](https://github.com/joaoparis/go-pong/blob/master/internal/app/app.go) (App Setup), [`internal/game/lobby_state.go`](https://github.com/joaoparis/go-pong/blob/master/internal/game/lobby_state.go) (Lobby State), [`internal/game/engine.go`](https://github.com/joaoparis/go-pong/blob/master/internal/game/engine.go) (State Dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Launch and Menu"]
  node_main["Program Entry<br/>[main.go]"]
  node_app["App Setup<br/>[app.go]"]
  node_lobby["Lobby State<br/>[lobby_state.go]"]
end

subgraph group_gameplay["Game State"]
  node_game["Game Engine<br/>[game.go]"]
  node_engine["State Dispatch<br/>[engine.go]"]
  node_playing["Playing State<br/>[playing_state.go]"]
  node_ball["Ball Physics<br/>[ball.go]"]
  node_player["Paddles<br/>[player.go]"]
  node_types["Game Types<br/>[types.go]"]
end

subgraph group_render["Rendering"]
  node_menu["Menu Drawing<br/>[text_draw.go]"]
end

node_user(("Player"))
node_ebiten["Ebiten Runtime"]

node_user -->|"uses controls"| node_ebiten
node_main -->|"starts app"| node_app
node_app -->|"creates game"| node_game
node_app -->|"sets initial state"| node_lobby
node_app -->|"runs game"| node_ebiten
node_ebiten -->|"calls callbacks"| node_engine
node_engine -->|"dispatches state"| node_game
node_game -->|"starts play"| node_playing
node_game -->|"initializes"| node_ball
node_game -->|"initializes"| node_player
node_game -->|"uses game screen"| node_types
node_lobby -->|"reads menu keys"| node_user
node_lobby -->|"starts local game"| node_game
node_lobby -->|"draws menu"| node_menu
node_menu -->|"draws text"| node_ebiten

click node_main "https://github.com/joaoparis/go-pong/blob/master/main.go"
click node_app "https://github.com/joaoparis/go-pong/blob/master/internal/app/app.go"
click node_lobby "https://github.com/joaoparis/go-pong/blob/master/internal/game/lobby_state.go"
click node_game "https://github.com/joaoparis/go-pong/blob/master/internal/game/game.go"
click node_engine "https://github.com/joaoparis/go-pong/blob/master/internal/game/engine.go"
click node_playing "https://github.com/joaoparis/go-pong/blob/master/internal/game/playing_state.go"
click node_ball "https://github.com/joaoparis/go-pong/blob/master/internal/game/ball.go"
click node_player "https://github.com/joaoparis/go-pong/blob/master/internal/game/player.go"
click node_types "https://github.com/joaoparis/go-pong/blob/master/internal/types/types.go"
click node_menu "https://github.com/joaoparis/go-pong/blob/master/internal/text_draw/text_draw.go"

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_main,node_app,node_lobby toneBlue
class node_game,node_engine,node_playing,node_ball,node_player,node_types toneAmber
class node_menu toneMint
class node_user,node_ebiten toneIndigo
```

## Components

### Launch and Menu

- [Program Entry](https://github.com/joaoparis/go-pong/blob/master/main.go): `main.go`
- [App Setup](https://github.com/joaoparis/go-pong/blob/master/internal/app/app.go): `internal/app/app.go`
- [Lobby State](https://github.com/joaoparis/go-pong/blob/master/internal/game/lobby_state.go): `internal/game/lobby_state.go`

### Game State

- [Game Engine](https://github.com/joaoparis/go-pong/blob/master/internal/game/game.go): `internal/game/game.go`
- [State Dispatch](https://github.com/joaoparis/go-pong/blob/master/internal/game/engine.go): `internal/game/engine.go`
- [Playing State](https://github.com/joaoparis/go-pong/blob/master/internal/game/playing_state.go): `internal/game/playing_state.go`
- [Ball Physics](https://github.com/joaoparis/go-pong/blob/master/internal/game/ball.go): `internal/game/ball.go`
- [Paddles](https://github.com/joaoparis/go-pong/blob/master/internal/game/player.go): `internal/game/player.go`
- [Game Types](https://github.com/joaoparis/go-pong/blob/master/internal/types/types.go): `internal/types/types.go`

### Rendering

- [Menu Drawing](https://github.com/joaoparis/go-pong/blob/master/internal/text_draw/text_draw.go): `internal/text_draw/text_draw.go`

### Other components

- **Player**
- **Ebiten Runtime**

## Connections

- Player → Ebiten Runtime: uses controls
- Program Entry → App Setup: starts app
- App Setup → Game Engine: creates game
- App Setup → Lobby State: sets initial state
- App Setup → Ebiten Runtime: runs game
- Ebiten Runtime → State Dispatch: calls callbacks
- State Dispatch → Game Engine: dispatches state
- Game Engine → Playing State: starts play
- Game Engine → Ball Physics: initializes
- Game Engine → Paddles: initializes
- Game Engine → Game Types: uses game screen
- Lobby State → Player: reads menu keys
- Lobby State → Game Engine: starts local game
- Lobby State → Menu Drawing: draws menu
- Menu Drawing → Ebiten Runtime: draws text
