# afterflow-gd/afterflow architecture

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

- Interactive diagram: https://gitdiagram.com/afterflow-gd/afterflow
- Repository: https://github.com/afterflow-gd/afterflow

## Overview

Afterflow is a Geometry Dash/Geode mod that predicts whether a press or release would be fatal, tests delayed ticks in a detached ghost simulation, and holds input until a surviving tick when possible. Its main runtime is concentrated in one source file, so several responsibilities below share that path. The same mod provides stage selection, a customizable in-game panel and logging, plus platform-specific terminal viewing. Workflow links are grounded in the README; sampled source excerpts show stage persistence and input handling, but not the full prediction implementation.

Main entry points: [`src/main.cpp`](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp) (Terminal launcher), [`afterflow-terminal-watch.sh`](https://github.com/afterflow-gd/afterflow/blob/main/afterflow-terminal-watch.sh) (Linux terminal watcher), [`afterflow-terminal.service`](https://github.com/afterflow-gd/afterflow/blob/main/afterflow-terminal.service) (User service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prediction["Input prediction"]
  node_input_hook["Input interception<br/>[main.cpp]"]
  node_ghost["Ghost simulation<br/>[main.cpp]"]
  node_tick_delay["Tick delay<br/>[main.cpp]"]
end

subgraph group_controls["Stages and settings"]
  node_stage_control["Stage controls<br/>[main.cpp]"]
  node_stage_state[("Saved stage<br/>[main.cpp]")]
  node_mod_settings["Mod settings<br/>[main.cpp]"]
end

subgraph group_interface["In-game interface"]
  node_control_panel["Control panel<br/>[main.cpp]"]
  node_mobile_button["Mobile AF button<br/>[main.cpp]"]
  node_prediction_log["Prediction log<br/>[main.cpp]"]
end

subgraph group_terminal["Terminal logging"]
  node_terminal_bridge["Terminal launcher<br/>[main.cpp]"]
  node_runtime_log["Runtime log<br/>[main.cpp]"]
  node_linux_watcher["Linux terminal watcher"]
  node_systemd_service["User service"]
end

node_player(("Player input"))
node_game["Geometry Dash"]
node_kitty["Kitty viewer"]
node_windows_viewer["Windows viewer"]
node_macos_viewer["macOS viewer"]

node_player -->|"sends input"| node_input_hook
node_input_hook -->|"tests timing"| node_ghost
node_ghost -->|"finds survival tick"| node_tick_delay
node_tick_delay -->|"delivers input"| node_game
node_input_hook -->|"reads play state"| node_game
node_stage_control -->|"persists selection"| node_stage_state
node_stage_control -->|"sets prediction stage"| node_input_hook
node_player -->|"cycles stage"| node_stage_control
node_mod_settings -->|"configures keybinds"| node_stage_control
node_player -->|"opens panel"| node_control_panel
node_mobile_button -->|"opens panel"| node_control_panel
node_control_panel -->|"shows recent log"| node_prediction_log
node_control_panel -->|"changes UI settings"| node_mod_settings
node_control_panel -->|"opens terminal"| node_terminal_bridge
node_terminal_bridge -->|"writes log"| node_runtime_log
node_terminal_bridge -.->|"drops trigger"| node_linux_watcher
node_systemd_service -->|"runs watcher"| node_linux_watcher
node_linux_watcher -->|"tails log"| node_runtime_log
node_linux_watcher -->|"toggles viewer"| node_kitty
node_terminal_bridge -->|"launches viewer"| node_windows_viewer
node_terminal_bridge -->|"opens viewer"| node_macos_viewer

click node_input_hook "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_ghost "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_tick_delay "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_stage_control "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_stage_state "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_mod_settings "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_control_panel "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_mobile_button "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_prediction_log "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_terminal_bridge "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_runtime_log "https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp"
click node_linux_watcher "https://github.com/afterflow-gd/afterflow/blob/main/afterflow-terminal-watch.sh"
click node_systemd_service "https://github.com/afterflow-gd/afterflow/blob/main/afterflow-terminal.service"

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_input_hook,node_ghost,node_tick_delay,node_kitty,node_windows_viewer,node_macos_viewer toneBlue
class node_stage_control,node_stage_state,node_mod_settings toneAmber
class node_control_panel,node_mobile_button,node_prediction_log toneMint
class node_terminal_bridge,node_runtime_log,node_linux_watcher,node_systemd_service toneRose
class node_player,node_game toneIndigo
```

## Components

### Input prediction

- [Input interception](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`
- [Ghost simulation](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`
- [Tick delay](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`

### Stages and settings

- [Stage controls](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`
- [Saved stage](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`
- [Mod settings](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`

### In-game interface

- [Control panel](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`
- [Mobile AF button](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`
- [Prediction log](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`

### Terminal logging

- [Terminal launcher](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`
- [Runtime log](https://github.com/afterflow-gd/afterflow/blob/main/src/main.cpp): `src/main.cpp`
- [Linux terminal watcher](https://github.com/afterflow-gd/afterflow/blob/main/afterflow-terminal-watch.sh): `afterflow-terminal-watch.sh`
- [User service](https://github.com/afterflow-gd/afterflow/blob/main/afterflow-terminal.service): `afterflow-terminal.service`

### Other components

- **Player input**
- **Geometry Dash**
- **Kitty viewer**
- **Windows viewer**
- **macOS viewer**

## Connections

- Player input → Input interception: sends input (evidence: `README.md`)
- Input interception → Ghost simulation: tests timing (evidence: `README.md`)
- Ghost simulation → Tick delay: finds survival tick (evidence: `README.md`)
- Tick delay → Geometry Dash: delivers input (evidence: `README.md`)
- Input interception → Geometry Dash: reads play state (evidence: `src/main.cpp`)
- Stage controls → Saved stage: persists selection (evidence: `src/main.cpp`)
- Stage controls → Input interception: sets prediction stage (evidence: `src/main.cpp`)
- Player input → Stage controls: cycles stage (evidence: `README.md`)
- Mod settings → Stage controls: configures keybinds (evidence: `README.md`)
- Player input → Control panel: opens panel (evidence: `README.md`)
- Mobile AF button → Control panel: opens panel (evidence: `README.md`)
- Control panel → Prediction log: shows recent log (evidence: `README.md`)
- Control panel → Mod settings: changes UI settings (evidence: `README.md`)
- Control panel → Terminal launcher: opens terminal (evidence: `README.md`)
- Terminal launcher → Runtime log: writes log (evidence: `README.md`)
- Terminal launcher → Linux terminal watcher: drops trigger (evidence: `README.md`)
- User service → Linux terminal watcher: runs watcher (evidence: `README.md`)
- Linux terminal watcher → Runtime log: tails log (evidence: `README.md`)
- Linux terminal watcher → Kitty viewer: toggles viewer (evidence: `README.md`)
- Terminal launcher → Windows viewer: launches viewer (evidence: `README.md`)
- Terminal launcher → macOS viewer: opens viewer (evidence: `README.md`)
