# loupi233rb/boids architecture

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

## Overview

Boids is a C++ OpenGL flocking simulation. The visible entry point initializes the application, polls window events, and starts separate timing, rendering, and AI threads; it then stops and joins them and deletes the birds. The README identifies the product and notes high CPU usage. The main source is sampled, but the simulation, rendering, input, and settings implementations are not, so their internal call paths and data flow cannot be established here.

Main entry points: [`src/main.cpp`](https://github.com/loupi233rb/boids/blob/main/src/main.cpp) (Application entry), [`external/glfw-3.4/include/GLFW/glfw3.h`](https://github.com/loupi233rb/boids/blob/main/external/glfw-3.4/include/GLFW/glfw3.h) (GLFW windowing), [`src/render.cpp`](https://github.com/loupi233rb/boids/blob/main/src/render.cpp) (Render loop), [`include/render.h`](https://github.com/loupi233rb/boids/blob/main/include/render.h) (OpenGL renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application lifecycle"]
  node_entry["Application entry<br/>[main.cpp]"]
  node_settings["Initial settings<br/>[info.cpp]"]
  node_thread_control["Thread control<br/>[funcThread.h]"]
end

subgraph group_simulation["Simulation runtime"]
  node_timer["Simulation timing<br/>[timer.cpp]"]
  node_ai["Flock AI<br/>[bird.cpp]"]
  node_bird_model["Bird model<br/>[bird.h]"]
  node_bird_state["Bird collection<br/>[info.h]"]
end

subgraph group_presentation["Window and rendering"]
  node_render_loop["Render loop<br/>[render.cpp]"]
  node_renderer["OpenGL renderer<br/>[render.h]"]
  node_shader["Shader support<br/>[shader.h]"]
end

subgraph group_controls["Input and state"]
  node_keyboard["Keyboard input<br/>[key.cpp]"]
  node_keyboard_api["Keyboard declarations<br/>[key.h]"]
  node_mouse["Mouse input<br/>[mouse.cpp]"]
  node_mouse_api["Mouse declarations<br/>[mouse.h]"]
end

node_user(("User"))
node_glfw["GLFW windowing<br/>[glfw3.h]"]
node_opengl["OpenGL API<br/>[gl.h]"]

node_user -->|"provides events"| node_glfw
node_entry -->|"initializes"| node_settings
node_entry -->|"starts and stops"| node_thread_control
node_entry -->|"starts tick"| node_timer
node_entry -->|"starts rendering"| node_render_loop
node_entry -->|"starts AI"| node_ai
node_entry -->|"polls events"| node_glfw
node_entry -->|"deletes birds"| node_bird_state
node_keyboard -.->|"reads keys"| node_glfw
node_mouse -.->|"reads pointer"| node_glfw
node_render_loop -.->|"renders"| node_renderer
node_renderer -.->|"draws with"| node_opengl

click node_entry "https://github.com/loupi233rb/boids/blob/main/src/main.cpp"
click node_settings "https://github.com/loupi233rb/boids/blob/main/src/info.cpp"
click node_thread_control "https://github.com/loupi233rb/boids/blob/main/include/funcThread.h"
click node_timer "https://github.com/loupi233rb/boids/blob/main/src/timer.cpp"
click node_ai "https://github.com/loupi233rb/boids/blob/main/src/bird.cpp"
click node_bird_model "https://github.com/loupi233rb/boids/blob/main/include/bird.h"
click node_bird_state "https://github.com/loupi233rb/boids/blob/main/include/info.h"
click node_render_loop "https://github.com/loupi233rb/boids/blob/main/src/render.cpp"
click node_renderer "https://github.com/loupi233rb/boids/blob/main/include/render.h"
click node_shader "https://github.com/loupi233rb/boids/blob/main/include/shader.h"
click node_glfw "https://github.com/loupi233rb/boids/blob/main/external/glfw-3.4/include/GLFW/glfw3.h"
click node_opengl "https://github.com/loupi233rb/boids/blob/main/external/glad/include/glad/gl.h"
click node_keyboard "https://github.com/loupi233rb/boids/blob/main/src/key.cpp"
click node_keyboard_api "https://github.com/loupi233rb/boids/blob/main/include/key.h"
click node_mouse "https://github.com/loupi233rb/boids/blob/main/src/mouse.cpp"
click node_mouse_api "https://github.com/loupi233rb/boids/blob/main/include/mouse.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_entry,node_settings,node_thread_control,node_user toneBlue
class node_timer,node_ai,node_bird_model,node_bird_state toneAmber
class node_render_loop,node_renderer,node_shader,node_opengl toneMint
class node_keyboard,node_keyboard_api,node_mouse,node_mouse_api toneRose
class node_glfw toneTeal
```

## Components

### Application lifecycle

- [Application entry](https://github.com/loupi233rb/boids/blob/main/src/main.cpp): `src/main.cpp`
- [Initial settings](https://github.com/loupi233rb/boids/blob/main/src/info.cpp): `src/info.cpp`
- [Thread control](https://github.com/loupi233rb/boids/blob/main/include/funcThread.h): `include/funcThread.h`

### Simulation runtime

- [Simulation timing](https://github.com/loupi233rb/boids/blob/main/src/timer.cpp): `src/timer.cpp`
- [Flock AI](https://github.com/loupi233rb/boids/blob/main/src/bird.cpp): `src/bird.cpp`
- [Bird model](https://github.com/loupi233rb/boids/blob/main/include/bird.h): `include/bird.h`
- [Bird collection](https://github.com/loupi233rb/boids/blob/main/include/info.h): `include/info.h`

### Window and rendering

- [Render loop](https://github.com/loupi233rb/boids/blob/main/src/render.cpp): `src/render.cpp`
- [OpenGL renderer](https://github.com/loupi233rb/boids/blob/main/include/render.h): `include/render.h`
- [Shader support](https://github.com/loupi233rb/boids/blob/main/include/shader.h): `include/shader.h`

### Input and state

- [Keyboard input](https://github.com/loupi233rb/boids/blob/main/src/key.cpp): `src/key.cpp`
- [Keyboard declarations](https://github.com/loupi233rb/boids/blob/main/include/key.h): `include/key.h`
- [Mouse input](https://github.com/loupi233rb/boids/blob/main/src/mouse.cpp): `src/mouse.cpp`
- [Mouse declarations](https://github.com/loupi233rb/boids/blob/main/include/mouse.h): `include/mouse.h`

### Other components

- **User**
- [GLFW windowing](https://github.com/loupi233rb/boids/blob/main/external/glfw-3.4/include/GLFW/glfw3.h): `external/glfw-3.4/include/GLFW/glfw3.h`
- [OpenGL API](https://github.com/loupi233rb/boids/blob/main/external/glad/include/glad/gl.h): `external/glad/include/glad/gl.h`

## Connections

- User → GLFW windowing: provides events
- Application entry → Initial settings: initializes
- Application entry → Thread control: starts and stops
- Application entry → Simulation timing: starts tick
- Application entry → Render loop: starts rendering
- Application entry → Flock AI: starts AI
- Application entry → GLFW windowing: polls events
- Application entry → Bird collection: deletes birds
- Keyboard input → GLFW windowing: reads keys
- Mouse input → GLFW windowing: reads pointer
- Render loop → OpenGL renderer: renders
- OpenGL renderer → OpenGL API: draws with
