# franciscoj-p/snake-mds architecture

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

- Interactive diagram: https://gitdiagram.com/franciscoj-p/snake-mds
- Repository: https://github.com/franciscoj-p/snake-mds

## Overview

Snake is a small Pygame game: the player starts a session and supplies direction keys through the main loop; the game advances the snake, checks collisions, updates food and score, and the presentation draws the menu or board. The runtime is split among input/loop orchestration, game rules, snake movement, world and score logic, and rendering/configuration. The README documents restart and game-over controls, but the provided screen excerpt shows only the menu, so that behavior is not expanded into an inferred flow.

Main entry points: [`snake/main.py`](https://github.com/franciscoj-p/snake-mds/blob/main/snake/main.py) (Game loop), [`snake/game.py`](https://github.com/franciscoj-p/snake-mds/blob/main/snake/game.py) (Game state), [`snake/config.py`](https://github.com/franciscoj-p/snake-mds/blob/main/snake/config.py) (Game settings), [`snake/world.py`](https://github.com/franciscoj-p/snake-mds/blob/main/snake/world.py) (Board and food)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["Game loop<br/>[main.py]"]
  node_config["Game settings<br/>[config.py]"]
end

subgraph group_domain["Game domain"]
  node_game["Game state<br/>[game.py]"]
  node_snake["Snake movement<br/>[snake_logic.py]"]
  node_world["Board and food<br/>[world.py]"]
  node_score["Score<br/>[world.py]"]
end

subgraph group_presentation["Presentation"]
  node_menu["Menu screen<br/>[screens.py]"]
  node_renderer["Board renderer<br/>[ui.py]"]
end

node_player(("Player"))

node_player -->|"starts and controls"| node_main
node_main -->|"creates, updates"| node_game
node_main -->|"draws menu"| node_menu
node_main -->|"draws game"| node_renderer
node_main -->|"configures display"| node_config
node_main -->|"uses directions"| node_snake
node_game -->|"moves and checks"| node_snake
node_game -->|"checks and spawns"| node_world
node_game -->|"updates score"| node_score
node_game -->|"reads settings"| node_config
node_renderer -->|"reads layout"| node_config
node_menu -->|"reads layout"| node_config
node_world -->|"reads board limits"| node_config

click node_main "https://github.com/franciscoj-p/snake-mds/blob/main/snake/main.py"
click node_game "https://github.com/franciscoj-p/snake-mds/blob/main/snake/game.py"
click node_snake "https://github.com/franciscoj-p/snake-mds/blob/main/snake/snake_logic.py"
click node_world "https://github.com/franciscoj-p/snake-mds/blob/main/snake/world.py"
click node_score "https://github.com/franciscoj-p/snake-mds/blob/main/snake/world.py"
click node_menu "https://github.com/franciscoj-p/snake-mds/blob/main/snake/screens.py"
click node_renderer "https://github.com/franciscoj-p/snake-mds/blob/main/snake/ui.py"
click node_config "https://github.com/franciscoj-p/snake-mds/blob/main/snake/config.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,node_config toneBlue
class node_game,node_snake,node_world,node_score toneAmber
class node_menu,node_renderer toneMint
class node_player toneIndigo
```

## Components

### Runtime

- [Game loop](https://github.com/franciscoj-p/snake-mds/blob/main/snake/main.py): `snake/main.py`
- [Game settings](https://github.com/franciscoj-p/snake-mds/blob/main/snake/config.py): `snake/config.py`

### Game domain

- [Game state](https://github.com/franciscoj-p/snake-mds/blob/main/snake/game.py): `snake/game.py`
- [Snake movement](https://github.com/franciscoj-p/snake-mds/blob/main/snake/snake_logic.py): `snake/snake_logic.py`
- [Board and food](https://github.com/franciscoj-p/snake-mds/blob/main/snake/world.py): `snake/world.py`
- [Score](https://github.com/franciscoj-p/snake-mds/blob/main/snake/world.py): `snake/world.py`

### Presentation

- [Menu screen](https://github.com/franciscoj-p/snake-mds/blob/main/snake/screens.py): `snake/screens.py`
- [Board renderer](https://github.com/franciscoj-p/snake-mds/blob/main/snake/ui.py): `snake/ui.py`

### Other components

- **Player**

## Connections

- Player → Game loop: starts and controls (evidence: `README.md`)
- Game loop → Game state: creates, updates (evidence: `snake/main.py`)
- Game loop → Menu screen: draws menu (evidence: `snake/main.py`)
- Game loop → Board renderer: draws game (evidence: `snake/main.py`)
- Game loop → Game settings: configures display (evidence: `snake/main.py`)
- Game loop → Snake movement: uses directions (evidence: `snake/main.py`)
- Game state → Snake movement: moves and checks (evidence: `snake/game.py`)
- Game state → Board and food: checks and spawns (evidence: `snake/game.py`)
- Game state → Score: updates score (evidence: `snake/game.py`)
- Game state → Game settings: reads settings (evidence: `snake/game.py`)
- Board renderer → Game settings: reads layout (evidence: `snake/ui.py`)
- Menu screen → Game settings: reads layout (evidence: `snake/screens.py`)
- Board and food → Game settings: reads board limits (evidence: `snake/world.py`)
