# belkhiriam/pong architecture

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

- Interactive diagram: https://gitdiagram.com/belkhiriam/pong
- Repository: https://github.com/belkhiriam/pong

## Overview

Pong is a raylib game with native and browser entry points. Players choose local 1v1 or VS AI, play rallies, score points, and can restart after game over; the game draws the field, score, and hit/scoring particle effects while playing music and sound effects. The README also documents browser mobile touch controls. The sampled entry points show keyboard and mouse input, AI paddle tracking, rendering, and audio; the browser touch implementation is not shown, so that capability is documented but not separately wired here.

Main entry points: [`src/web_main.c`](https://github.com/belkhiriam/pong/blob/main/src/web_main.c) (Web game), [`src/main.c`](https://github.com/belkhiriam/pong/blob/main/src/main.c) (Native game), [`src/ball.c`](https://github.com/belkhiriam/pong/blob/main/src/ball.c) (Ball physics), [`src/paddle.c`](https://github.com/belkhiriam/pong/blob/main/src/paddle.c) (Paddle control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_native_app["Native game<br/>[main.c]"]
  node_web_app["Web game<br/>[web_main.c]"]
end

subgraph group_gameplay["Gameplay systems"]
  node_ball_logic["Ball physics<br/>[ball.c]"]
  node_paddle_logic["Paddle control<br/>[paddle.c]"]
  node_particles["Particle effects<br/>[particles.c]"]
end

subgraph group_presentation["Presentation and audio"]
  node_ui["Game UI<br/>[ui.c]"]
end

subgraph group_platform["Platform assets"]
  node_visual_assets["Visual assets"]
  node_audio_assets["Audio assets"]
end

node_desktop_player(("Desktop player"))
node_browser_player(("Browser player"))
node_browser_host["WebAssembly browser"]

node_desktop_player -->|"plays"| node_native_app
node_browser_player -->|"plays"| node_web_app
node_native_app -->|"updates and draws"| node_ball_logic
node_native_app -->|"updates and draws"| node_paddle_logic
node_native_app -->|"spawns, updates, draws"| node_particles
node_native_app -->|"draws screens"| node_ui
node_web_app -->|"updates and draws"| node_ball_logic
node_web_app -->|"updates and draws"| node_paddle_logic
node_web_app -->|"spawns, updates, draws"| node_particles
node_web_app -->|"draws screens"| node_ui
node_ball_logic -->|"reads bounds"| node_paddle_logic
node_native_app -->|"loads textures"| node_visual_assets
node_web_app -->|"loads textures"| node_visual_assets
node_native_app -->|"loads sounds and music"| node_audio_assets
node_web_app -->|"loads sounds and music"| node_audio_assets
node_web_app -->|"runs as WebAssembly"| node_browser_host

click node_native_app "https://github.com/belkhiriam/pong/blob/main/src/main.c"
click node_web_app "https://github.com/belkhiriam/pong/blob/main/src/web_main.c"
click node_ball_logic "https://github.com/belkhiriam/pong/blob/main/src/ball.c"
click node_paddle_logic "https://github.com/belkhiriam/pong/blob/main/src/paddle.c"
click node_particles "https://github.com/belkhiriam/pong/blob/main/src/particles.c"
click node_ui "https://github.com/belkhiriam/pong/blob/main/src/ui.c"
click node_visual_assets "https://github.com/belkhiriam/pong/tree/main/assets"
click node_audio_assets "https://github.com/belkhiriam/pong/tree/main/assets"

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_native_app,node_web_app,node_browser_player,node_browser_host toneBlue
class node_ball_logic,node_paddle_logic,node_particles toneAmber
class node_ui toneMint
class node_visual_assets,node_audio_assets toneRose
class node_desktop_player toneIndigo
```

## Components

### Game runtime

- [Native game](https://github.com/belkhiriam/pong/blob/main/src/main.c): `src/main.c`
- [Web game](https://github.com/belkhiriam/pong/blob/main/src/web_main.c): `src/web_main.c`

### Gameplay systems

- [Ball physics](https://github.com/belkhiriam/pong/blob/main/src/ball.c): `src/ball.c`
- [Paddle control](https://github.com/belkhiriam/pong/blob/main/src/paddle.c): `src/paddle.c`
- [Particle effects](https://github.com/belkhiriam/pong/blob/main/src/particles.c): `src/particles.c`

### Presentation and audio

- [Game UI](https://github.com/belkhiriam/pong/blob/main/src/ui.c): `src/ui.c`

### Platform assets

- [Visual assets](https://github.com/belkhiriam/pong/tree/main/assets): `assets`
- [Audio assets](https://github.com/belkhiriam/pong/tree/main/assets): `assets`

### Other components

- **Desktop player**
- **Browser player**
- **WebAssembly browser**

## Connections

- Desktop player → Native game: plays (evidence: `README.md`)
- Browser player → Web game: plays (evidence: `README.md`)
- Native game → Ball physics: updates and draws (evidence: `src/main.c`)
- Native game → Paddle control: updates and draws (evidence: `src/main.c`)
- Native game → Particle effects: spawns, updates, draws (evidence: `src/main.c`)
- Native game → Game UI: draws screens (evidence: `src/main.c`)
- Web game → Ball physics: updates and draws (evidence: `src/web_main.c`)
- Web game → Paddle control: updates and draws (evidence: `src/web_main.c`)
- Web game → Particle effects: spawns, updates, draws (evidence: `src/web_main.c`)
- Web game → Game UI: draws screens (evidence: `src/web_main.c`)
- Ball physics → Paddle control: reads bounds (evidence: `src/ball.c`)
- Native game → Visual assets: loads textures (evidence: `src/main.c`)
- Web game → Visual assets: loads textures (evidence: `src/web_main.c`)
- Native game → Audio assets: loads sounds and music (evidence: `src/main.c`)
- Web game → Audio assets: loads sounds and music (evidence: `src/web_main.c`)
- Web game → WebAssembly browser: runs as WebAssembly (evidence: `README.md`)
