# spacesinmotion/beat architecture

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

- Interactive diagram: https://gitdiagram.com/spacesinmotion/beat
- Repository: https://github.com/spacesinmotion/beat

## Overview

This is a small graphical incremental game: players gain beats by clicking or pressing Space, spend them to unlock producers and buy enhancements, and see progress through a rendered interface. Timed updates add producer output to the beat total. The repository also contains dr_wav, a standalone WAV read/write library; the shown game source has its include and implementation lines commented out, so no runtime connection is established. The source excerpts show the game callbacks and state changes; unsampled code may add details, so unsupported links are omitted.

Main entry points: [`beat.c`](https://github.com/spacesinmotion/beat/blob/main/beat.c) (Button Events)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game Runtime"]
  node_game_loop["Game Callbacks<br/>[beat.c]"]
  node_game_state[("Game State<br/>[beat.c]")]
  node_beat_economy["Beat Economy<br/>[beat.c]"]
  node_producer_system["Producers<br/>[beat.c]"]
  node_enhancement_system["Enhancements<br/>[beat.c]"]
end

subgraph group_interface["Input and Display"]
  node_button_input["Button Events<br/>[beat.c]"]
  node_screen_render["Screen Rendering<br/>[beat.c]"]
  node_sokol_app["Sokol App"]
  node_sokol_graphics["Sokol Graphics"]
end

subgraph group_audio["WAV Library"]
  node_wav_library["WAV Read/Write<br/>[dr_wav.h]"]
end

node_player(("Player"))

node_player -->|"sends input"| node_sokol_app
node_sokol_app -->|"runs callbacks"| node_game_loop
node_game_loop -->|"dispatches events"| node_button_input
node_button_input -->|"increments beats"| node_beat_economy
node_button_input -->|"buys producers"| node_producer_system
node_button_input -->|"buys upgrades"| node_enhancement_system
node_producer_system -->|"updates counts"| node_game_state
node_enhancement_system -->|"updates levels"| node_game_state
node_beat_economy -->|"updates total"| node_game_state
node_game_loop -->|"draws frame"| node_screen_render
node_screen_render -->|"renders display"| node_sokol_graphics

click node_game_loop "https://github.com/spacesinmotion/beat/blob/main/beat.c"
click node_game_state "https://github.com/spacesinmotion/beat/blob/main/beat.c"
click node_beat_economy "https://github.com/spacesinmotion/beat/blob/main/beat.c"
click node_producer_system "https://github.com/spacesinmotion/beat/blob/main/beat.c"
click node_enhancement_system "https://github.com/spacesinmotion/beat/blob/main/beat.c"
click node_button_input "https://github.com/spacesinmotion/beat/blob/main/beat.c"
click node_screen_render "https://github.com/spacesinmotion/beat/blob/main/beat.c"
click node_wav_library "https://github.com/spacesinmotion/beat/blob/main/dr/dr_wav.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_game_loop,node_game_state,node_beat_economy,node_producer_system,node_enhancement_system toneBlue
class node_button_input,node_screen_render,node_sokol_app,node_sokol_graphics toneAmber
class node_wav_library toneMint
class node_player toneIndigo
```

## Components

### Game Runtime

- [Game Callbacks](https://github.com/spacesinmotion/beat/blob/main/beat.c): `beat.c`
- [Game State](https://github.com/spacesinmotion/beat/blob/main/beat.c): `beat.c`
- [Beat Economy](https://github.com/spacesinmotion/beat/blob/main/beat.c): `beat.c`
- [Producers](https://github.com/spacesinmotion/beat/blob/main/beat.c): `beat.c`
- [Enhancements](https://github.com/spacesinmotion/beat/blob/main/beat.c): `beat.c`

### Input and Display

- [Button Events](https://github.com/spacesinmotion/beat/blob/main/beat.c): `beat.c`
- [Screen Rendering](https://github.com/spacesinmotion/beat/blob/main/beat.c): `beat.c`
- **Sokol App**
- **Sokol Graphics**

### WAV Library

- [WAV Read/Write](https://github.com/spacesinmotion/beat/blob/main/dr/dr_wav.h): `dr/dr_wav.h`

### Other components

- **Player**

## Connections

- Player → Sokol App: sends input
- Sokol App → Game Callbacks: runs callbacks (evidence: `beat.c`)
- Game Callbacks → Button Events: dispatches events (evidence: `beat.c`)
- Button Events → Beat Economy: increments beats (evidence: `beat.c`)
- Button Events → Producers: buys producers (evidence: `beat.c`)
- Button Events → Enhancements: buys upgrades (evidence: `beat.c`)
- Producers → Game State: updates counts (evidence: `beat.c`)
- Enhancements → Game State: updates levels (evidence: `beat.c`)
- Beat Economy → Game State: updates total (evidence: `beat.c`)
- Game Callbacks → Screen Rendering: draws frame (evidence: `beat.c`)
- Screen Rendering → Sokol Graphics: renders display (evidence: `beat.c`)
