# sunn4es/spaceinvaders architecture

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

- Interactive diagram: https://gitdiagram.com/sunn4es/spaceinvaders
- Repository: https://github.com/sunn4es/spaceinvaders

## Overview

This is an SFML desktop alien-shooter game with player profiles, gameplay, and score viewing. The principal workflow is selecting a profile, starting a game, controlling the cannon while avoiding alien fire, and recording a higher score when play ends. Profile creation, deletion, selection, and binary-file persistence form a separate branch. The README is empty; unsampled window implementations are represented only where the tree and sampled callers support them.

Main entry points: [`gameWindowUnit.cpp`](https://github.com/sunn4es/spaceinvaders/blob/main/gameWindowUnit.cpp) (Game loop), [`main.cpp`](https://github.com/sunn4es/spaceinvaders/blob/main/main.cpp) (Main menu), [`fileModule.cpp`](https://github.com/sunn4es/spaceinvaders/blob/main/fileModule.cpp) (Player records), [`chosePlayerWindow.cpp`](https://github.com/sunn4es/spaceinvaders/blob/main/chosePlayerWindow.cpp) (Choose player)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App flow"]
  node_main["Main menu<br/>[main.cpp]"]
  node_scoreboard["Scoreboard"]
end

subgraph group_profiles["Player profiles"]
  node_choose["Choose player"]
  node_newplayer["Create player"]
  node_dropdown["Player dropdown<br/>[DropBox.cpp]"]
  node_profiles_store[("Player records<br/>[fileModule.cpp]")]
  node_player_file["Player data file"]
end

subgraph group_gameplay["Gameplay"]
  node_game["Game loop<br/>[gameWindowUnit.cpp]"]
  node_cannon["Cannon<br/>[CannonClass.cpp]"]
  node_rocket["Player rockets<br/>[RocketClass.cpp]"]
  node_alien["Aliens<br/>[AlienClass.cpp]"]
end

subgraph group_ui["Game interface"]
  node_gameover["Game over"]
  node_pause["Pause screen"]
  node_texture["Texture cache"]
end

node_player(("Player"))

node_player -->|"selects actions"| node_main
node_main -->|"opens selection"| node_choose
node_main -->|"starts game"| node_game
node_main -->|"opens scores"| node_scoreboard
node_main -->|"loads and saves"| node_profiles_store
node_choose -->|"opens creation"| node_newplayer
node_choose -->|"handles selection"| node_dropdown
node_choose -->|"manages profiles"| node_profiles_store
node_newplayer -->|"adds and saves"| node_profiles_store
node_profiles_store -->|"reads and writes"| node_player_file
node_game -->|"updates and moves"| node_cannon
node_game -->|"updates rockets"| node_rocket
node_game -->|"updates aliens"| node_alien
node_game -->|"opens on defeat"| node_gameover
node_game -->|"updates player score"| node_profiles_store
node_game -->|"loads textures"| node_texture

click node_main "https://github.com/sunn4es/spaceinvaders/blob/main/main.cpp"
click node_choose "https://github.com/sunn4es/spaceinvaders/blob/main/chosePlayerWindow.cpp"
click node_newplayer "https://github.com/sunn4es/spaceinvaders/blob/main/newPlayerWindowUnit.cpp"
click node_dropdown "https://github.com/sunn4es/spaceinvaders/blob/main/DropBox.cpp"
click node_profiles_store "https://github.com/sunn4es/spaceinvaders/blob/main/fileModule.cpp"
click node_scoreboard "https://github.com/sunn4es/spaceinvaders/blob/main/scoreBoardWindowUnit.cpp"
click node_game "https://github.com/sunn4es/spaceinvaders/blob/main/gameWindowUnit.cpp"
click node_cannon "https://github.com/sunn4es/spaceinvaders/blob/main/CannonClass.cpp"
click node_rocket "https://github.com/sunn4es/spaceinvaders/blob/main/RocketClass.cpp"
click node_alien "https://github.com/sunn4es/spaceinvaders/blob/main/AlienClass.cpp"
click node_gameover "https://github.com/sunn4es/spaceinvaders/blob/main/gameOverWindowUnit.cpp"
click node_pause "https://github.com/sunn4es/spaceinvaders/blob/main/pauseWindowUnit.cpp"
click node_texture "https://github.com/sunn4es/spaceinvaders/blob/main/TextureManagerClass.h"

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_scoreboard toneBlue
class node_choose,node_newplayer,node_dropdown,node_profiles_store,node_player_file toneAmber
class node_game,node_cannon,node_rocket,node_alien toneMint
class node_gameover,node_pause,node_texture toneRose
class node_player toneIndigo
```

## Components

### App flow

- [Main menu](https://github.com/sunn4es/spaceinvaders/blob/main/main.cpp): `main.cpp`
- [Scoreboard](https://github.com/sunn4es/spaceinvaders/blob/main/scoreBoardWindowUnit.cpp): `scoreBoardWindowUnit.cpp`

### Player profiles

- [Choose player](https://github.com/sunn4es/spaceinvaders/blob/main/chosePlayerWindow.cpp): `chosePlayerWindow.cpp`
- [Create player](https://github.com/sunn4es/spaceinvaders/blob/main/newPlayerWindowUnit.cpp): `newPlayerWindowUnit.cpp`
- [Player dropdown](https://github.com/sunn4es/spaceinvaders/blob/main/DropBox.cpp): `DropBox.cpp`
- [Player records](https://github.com/sunn4es/spaceinvaders/blob/main/fileModule.cpp): `fileModule.cpp`
- **Player data file**

### Gameplay

- [Game loop](https://github.com/sunn4es/spaceinvaders/blob/main/gameWindowUnit.cpp): `gameWindowUnit.cpp`
- [Cannon](https://github.com/sunn4es/spaceinvaders/blob/main/CannonClass.cpp): `CannonClass.cpp`
- [Player rockets](https://github.com/sunn4es/spaceinvaders/blob/main/RocketClass.cpp): `RocketClass.cpp`
- [Aliens](https://github.com/sunn4es/spaceinvaders/blob/main/AlienClass.cpp): `AlienClass.cpp`

### Game interface

- [Game over](https://github.com/sunn4es/spaceinvaders/blob/main/gameOverWindowUnit.cpp): `gameOverWindowUnit.cpp`
- [Pause screen](https://github.com/sunn4es/spaceinvaders/blob/main/pauseWindowUnit.cpp): `pauseWindowUnit.cpp`
- [Texture cache](https://github.com/sunn4es/spaceinvaders/blob/main/TextureManagerClass.h): `TextureManagerClass.h`

### Other components

- **Player**

## Connections

- Player → Main menu: selects actions
- Main menu → Choose player: opens selection
- Main menu → Game loop: starts game
- Main menu → Scoreboard: opens scores
- Main menu → Player records: loads and saves
- Choose player → Create player: opens creation
- Choose player → Player dropdown: handles selection
- Choose player → Player records: manages profiles
- Create player → Player records: adds and saves
- Player records → Player data file: reads and writes
- Game loop → Cannon: updates and moves
- Game loop → Player rockets: updates rockets
- Game loop → Aliens: updates aliens
- Game loop → Game over: opens on defeat
- Game loop → Player records: updates player score
- Game loop → Texture cache: loads textures
