# pjconcepcion/flappy-bird architecture

> Architecture diagram of the GitHub repository pjconcepcion/flappy-bird, 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/pjconcepcion/flappy-bird
- Repository: https://github.com/pjconcepcion/flappy-bird

## Overview

Flappy Bird is a small Pygame game: the player uses Space to flap past pipes, scores by passing through gaps, and can restart or quit after a collision. The runtime loop in Main handles input, advances game state, and renders the screen. GameManager owns pipe spawning, movement, collision, and scoring; Player models movement, while Screen and the shape/text classes provide display elements. The README documents controls and mechanics; the graph follows sampled source for internal wiring.

Main entry points: [`src/main.py`](https://github.com/pjconcepcion/flappy-bird/blob/master/src/main.py) (Game Loop), [`src/game_manager.py`](https://github.com/pjconcepcion/flappy-bird/blob/master/src/game_manager.py) (Game Manager), [`src/screen.py`](https://github.com/pjconcepcion/flappy-bird/blob/master/src/screen.py) (Screen), [`src/player.py`](https://github.com/pjconcepcion/flappy-bird/blob/master/src/player.py) (Player)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["Game Loop<br/>[main.py]"]
end

subgraph group_gameplay["Gameplay"]
  node_player["Player<br/>[player.py]"]
  node_game_manager["Game Manager<br/>[game_manager.py]"]
  node_pipe["Pipe Motion<br/>[game_manager.py]"]
end

subgraph group_display["Display"]
  node_screen["Screen<br/>[screen.py]"]
  node_shape["Shapes<br/>[shape.py]"]
  node_text["Text Labels<br/>[canvas.py]"]
end

node_pygame["Pygame"]
node_player_actor(("Player"))

node_player_actor -->|"sends controls"| node_main
node_main -->|"polls events"| node_pygame
node_main -->|"initializes"| node_player
node_main -->|"initializes"| node_screen
node_main -->|"initializes"| node_game_manager
node_main -->|"dispatches jump"| node_player
node_main -->|"advances state"| node_game_manager
node_main -->|"renders"| node_screen
node_game_manager -->|"updates and checks"| node_player
node_game_manager -->|"reads floor"| node_screen
node_game_manager -->|"registers and removes"| node_screen
node_game_manager -->|"creates and moves"| node_pipe
node_game_manager -->|"creates pipe shapes"| node_shape
node_game_manager -->|"creates and updates labels"| node_text
node_pipe -->|"moves geometry"| node_shape
node_screen -->|"creates background and floor"| node_shape
node_screen -->|"blits and flips"| node_pygame
node_player -->|"loads and scales image"| node_pygame
node_shape -->|"creates surfaces"| node_pygame
node_text -->|"renders fonts"| node_pygame

click node_player "https://github.com/pjconcepcion/flappy-bird/blob/master/src/player.py"
click node_game_manager "https://github.com/pjconcepcion/flappy-bird/blob/master/src/game_manager.py"
click node_pipe "https://github.com/pjconcepcion/flappy-bird/blob/master/src/game_manager.py"
click node_main "https://github.com/pjconcepcion/flappy-bird/blob/master/src/main.py"
click node_screen "https://github.com/pjconcepcion/flappy-bird/blob/master/src/screen.py"
click node_shape "https://github.com/pjconcepcion/flappy-bird/blob/master/src/shape.py"
click node_text "https://github.com/pjconcepcion/flappy-bird/blob/master/src/canvas.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_main toneBlue
class node_player,node_game_manager,node_pipe toneAmber
class node_screen,node_shape,node_text toneMint
class node_pygame,node_player_actor toneIndigo
```

## Components

### Runtime

- [Game Loop](https://github.com/pjconcepcion/flappy-bird/blob/master/src/main.py): `src/main.py`

### Gameplay

- [Player](https://github.com/pjconcepcion/flappy-bird/blob/master/src/player.py): `src/player.py`
- [Game Manager](https://github.com/pjconcepcion/flappy-bird/blob/master/src/game_manager.py): `src/game_manager.py`
- [Pipe Motion](https://github.com/pjconcepcion/flappy-bird/blob/master/src/game_manager.py): `src/game_manager.py`

### Display

- [Screen](https://github.com/pjconcepcion/flappy-bird/blob/master/src/screen.py): `src/screen.py`
- [Shapes](https://github.com/pjconcepcion/flappy-bird/blob/master/src/shape.py): `src/shape.py`
- [Text Labels](https://github.com/pjconcepcion/flappy-bird/blob/master/src/canvas.py): `src/canvas.py`

### Other components

- **Pygame**
- **Player**

## Connections

- Player → Game Loop: sends controls
- Game Loop → Pygame: polls events
- Game Loop → Player: initializes
- Game Loop → Screen: initializes
- Game Loop → Game Manager: initializes
- Game Loop → Player: dispatches jump
- Game Loop → Game Manager: advances state
- Game Loop → Screen: renders
- Game Manager → Player: updates and checks
- Game Manager → Screen: reads floor
- Game Manager → Screen: registers and removes
- Game Manager → Pipe Motion: creates and moves
- Game Manager → Shapes: creates pipe shapes
- Game Manager → Text Labels: creates and updates labels
- Pipe Motion → Shapes: moves geometry
- Screen → Shapes: creates background and floor
- Screen → Pygame: blits and flips
- Player → Pygame: loads and scales image
- Shapes → Pygame: creates surfaces
- Text Labels → Pygame: renders fonts
