# utkarshpathrabe/pong-game-using-python architecture

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

- Interactive diagram: https://gitdiagram.com/utkarshpathrabe/pong-game-using-python
- Repository: https://github.com/utkarshpathrabe/pong-game-using-python

## Overview

This is a small, single-file Pong game. A player uses keyboard controls to move two paddles; the SimpleGUI frame dispatches input and draw events, while the draw handler advances the game, detects collisions and scores, and renders the result. Restart resets the game and spawns a new ball. The README also describes the educational and two-player aspects; the source shows both players’ controls in one game. All implementation paths below are supported by the tree; unsampled assets are not modeled.

Main entry points: [`Pong.py`](https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py) (Frame setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime setup"]
  node_startup["Frame setup<br/>[Pong.py]"]
end

subgraph group_game["Game logic"]
  node_game_state[("Game state<br/>[Pong.py]")]
  node_new_game["New game<br/>[Pong.py]"]
  node_spawn_ball["Spawn ball<br/>[Pong.py]"]
end

subgraph group_interaction["Input and display"]
  node_draw["Draw and update<br/>[Pong.py]"]
  node_key_handlers["Keyboard handlers<br/>[Pong.py]"]
  node_restart["Restart handler<br/>[Pong.py]"]
end

node_player(("Players"))
node_simplegui["SimpleGUI"]

node_startup -->|"creates frame"| node_simplegui
node_startup -->|"registers draw"| node_draw
node_startup -->|"registers keys"| node_key_handlers
node_startup -->|"registers button"| node_restart
node_startup -->|"starts game"| node_new_game
node_player -->|"presses keys"| node_simplegui
node_simplegui -->|"dispatches keys"| node_key_handlers
node_simplegui -->|"dispatches draw"| node_draw
node_simplegui -->|"dispatches button"| node_restart
node_key_handlers -->|"sets paddle velocity"| node_game_state
node_draw -->|"updates and reads"| node_game_state
node_draw -->|"spawns after miss"| node_spawn_ball
node_new_game -->|"resets state"| node_game_state
node_new_game -->|"starts rally"| node_spawn_ball
node_restart -->|"resets game"| node_new_game

click node_startup "https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py"
click node_game_state "https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py"
click node_new_game "https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py"
click node_spawn_ball "https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py"
click node_draw "https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py"
click node_key_handlers "https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py"
click node_restart "https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py"

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_startup,node_simplegui toneBlue
class node_game_state,node_new_game,node_spawn_ball toneAmber
class node_draw,node_key_handlers,node_restart toneMint
class node_player toneIndigo
```

## Components

### Runtime setup

- [Frame setup](https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py): `Pong.py`

### Game logic

- [Game state](https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py): `Pong.py`
- [New game](https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py): `Pong.py`
- [Spawn ball](https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py): `Pong.py`

### Input and display

- [Draw and update](https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py): `Pong.py`
- [Keyboard handlers](https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py): `Pong.py`
- [Restart handler](https://github.com/utkarshpathrabe/pong-game-using-python/blob/main/Pong.py): `Pong.py`

### Other components

- **Players**
- **SimpleGUI**

## Connections

- Frame setup → SimpleGUI: creates frame
- Frame setup → Draw and update: registers draw
- Frame setup → Keyboard handlers: registers keys
- Frame setup → Restart handler: registers button
- Frame setup → New game: starts game
- Players → SimpleGUI: presses keys
- SimpleGUI → Keyboard handlers: dispatches keys
- SimpleGUI → Draw and update: dispatches draw
- SimpleGUI → Restart handler: dispatches button
- Keyboard handlers → Game state: sets paddle velocity
- Draw and update → Game state: updates and reads
- Draw and update → Spawn ball: spawns after miss
- New game → Game state: resets state
- New game → Spawn ball: starts rally
- Restart handler → New game: resets game
