# nmvteam/nightmarevision architecture

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

- Interactive diagram: https://gitdiagram.com/nmvteam/nightmarevision
- Repository: https://github.com/nmvteam/nightmarevision

## Overview

1. This repository is a Haxe-based rhythm game engine, built on the Funkin/Psych Engine lineage. The runtime stack is centered on HaxeFlixel with Lime/OpenFL and hxcpp for native desktop builds. The README also shows a strict local dependency workflow via hxpkg/hmm, which is part of the build architecture.

2. The application entry path is small and bootstraps into the game framework: `Main.hx`, `Init.hx`, and `Splash.hx` lead into the engine’s main game object and state system. From there, `source/funkin/backend/FunkinGame.hx` and related backend classes coordinate startup, scaling, input, logging, crash handling, and transitions.

3. The engine is organized around a state machine. The main user-facing flow is `TitleState -> MainMenuState -> StoryMenuState / FreeplayState / ModsState / OptionsState -> PlayState`, with dedicated substates for pause, game over, prompts, resets, and gameplay modifiers. This is the primary navigation and screen architecture to diagram.

4. Actual gameplay is concentrated in `PlayState` and the `objects/note` and `game/huds` packages. Notes, strums, sustains, splashes, countdown, rating logic, and HUD rendering are separate components, with the `Conductor` handling song timing and beat/step synchronization. This is the core real-time loop of the engine.

5. Game content is data-driven. Runtime definitions come from files under `assets/game/data` such as characters, stages, weeks, song metadata, note skins, intro text, and high scores/prefs-backed data models in `source/funkin/data`. The architecture expects content to be swapped or extended via these external data files rather than hardcoded scenes.

6. Visual presentation is split into reusable objects and stage-specific actors. Core objects like `Character`, `Stage`, `BGSprite`, `MenuItem`, `Alphabet`, and `HealthIcon` are shared across screens, while stage decorations and special animated characters live under `objects/stageobjects` and the `assets/game/images` sprite/XML sets.

7. Audio is a first-class subsystem. Music, SFX, sound trays, intro/game-over tracks, and song stems live in the asset tree, while code in `source/funkin/audio` and `source/funkin/audio/visualize` handles playback wrappers, synchronized sound groups, waveform data, and spectrum/FFT visualization. This supports both gameplay timing and UI/audio feedback.

8. Modding and scripting are a major architectural boundary. `source/funkin/scripting`, `source/funkin/scripts`, and `source/extensions/hscript` support scripted states, substates, and extensible logic, while `source/funkin/game/modchart` implements the note-modifier/event timeline system. This layer is where custom gameplay effects and chart-driven transformations plug into the core engine.

9. The codebase includes a substantial editor subsystem, not just a game runtime. Editor states for charts, characters, song metadata, weeks, and note skins live under `source/funkin/states/editors`, with shared UI kits underneath. The `assets/excluded` tree suggests optional editor-only UI resources that are kept separate from standard gameplay assets.

10. Platform and tooling integrations matter here. There are extensions for Discord presence, fullscreen, hot reload, enhanced camera/sound/UI behavior, plus native memory and HL-specific fixes. Macros and utility code in `source/funkin/backend/macro` and `source/hl` indicate compile-time and target-specific support is part of the architecture, not an afterthought.

11. Asset layout is deliberately partitioned by purpose: `assets/embeds` for bundled media, `assets/game` for core runtime content, and `assets/excluded` for non-shipped/editor assets. This separation is important for understanding what is embedded at build time versus what is treated as game content the engine loads from disk.

12. Overall, the repository is best diagrammed as a layered engine: bootstrap/runtime core at the bottom, a data-driven gameplay state machine in the middle, and optional scripting/editing/modding systems layered on top. The main external boundaries are the filesystem asset packs, compiled native libraries, and any runtime integrations like Discord or profiling.

Main entry points: [`source/funkin/states/PlayState.hx`](https://github.com/nmvteam/nightmarevision/blob/dev/source/funkin/states/PlayState.hx) (PlayState), [`source/funkin/data`](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/data) (Game data), [`source/funkin/states`](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states) (State flow), [`source/funkin/backend`](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/backend) (Backend core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap & runtime"]
  node_source_main["Main<br/>entrypoint<br/>[Main.hx]"]
  node_source_init["Init<br/>bootstrap<br/>[Init.hx]"]
  node_source_splash["Splash<br/>bootstrap<br/>[Splash.hx]"]
  node_funkin_game["FunkinGame<br/>engine core<br/>[FunkinGame.hx]"]
  node_backend_services["Backend core<br/>runtime services"]
  node_platform_ext["Platform plugins<br/>platform hooks"]
end

subgraph group_gameplay["Gameplay engine"]
  node_state_flow["State flow<br/>state machine"]
  node_play_state["PlayState<br/>gameplay state<br/>[PlayState.hx]"]
  node_ui_states["Menu states<br/>ui states"]
  node_substates["Substates<br/>overlay states"]
  node_hud["HUD<br/>render overlay"]
  node_notesystem["Note system<br/>playfield"]
  node_timing["Conductor<br/>timing sync<br/>[Conductor.hx]"]
end

subgraph group_content["Data & assets"]
  node_content_data["Game data<br/>data models"]
  node_assets_game["Game assets<br/>runtime content"]
  node_assets_embeds["Embedded assets<br/>bundled media"]
  node_assets_excluded["Excluded assets<br/>editor content"]
end

subgraph group_ext["Scripting & modding"]
  node_scripting_modding["Scripting layer<br/>extensibility"]
  node_modchart["Modchart<br/>chart effects"]
end

subgraph group_editors["Editors"]
  node_editor_states["Editors<br/>authoring tools"]
  node_editor_ui["Editor UI<br/>ui kits"]
end

node_source_main -->|"boots"| node_source_init
node_source_init -->|"loads"| node_source_splash
node_source_splash -->|"starts"| node_funkin_game
node_funkin_game -->|"uses"| node_backend_services
node_backend_services -->|"syncs"| node_timing
node_backend_services -->|"extends"| node_platform_ext
node_funkin_game -->|"drives"| node_state_flow
node_state_flow -->|"navigates"| node_ui_states
node_state_flow -->|"enters"| node_play_state
node_state_flow -->|"overlays"| node_substates
node_play_state -->|"renders"| node_notesystem
node_play_state -->|"shows"| node_hud
node_play_state -->|"consumes"| node_timing
node_play_state -->|"loads"| node_content_data
node_content_data -->|"maps to"| node_assets_game
node_content_data -->|"bundles"| node_assets_embeds
node_editor_states -->|"edits"| node_content_data
node_editor_states -->|"shares"| node_editor_ui
node_editor_states -->|"uses"| node_assets_excluded
node_scripting_modding -->|"augments"| node_play_state
node_scripting_modding -->|"injects"| node_substates
node_scripting_modding -->|"configures"| node_modchart
node_modchart -->|"affects"| node_notesystem
node_assets_game -->|"contains"| node_content_data
node_assets_embeds -->|"supplies"| node_backend_services

click node_source_main "https://github.com/nmvteam/nightmarevision/blob/dev/source/Main.hx"
click node_source_init "https://github.com/nmvteam/nightmarevision/blob/dev/source/Init.hx"
click node_source_splash "https://github.com/nmvteam/nightmarevision/blob/dev/source/Splash.hx"
click node_funkin_game "https://github.com/nmvteam/nightmarevision/blob/dev/source/funkin/backend/FunkinGame.hx"
click node_backend_services "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/backend"
click node_platform_ext "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/backend/plugins"
click node_state_flow "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states"
click node_play_state "https://github.com/nmvteam/nightmarevision/blob/dev/source/funkin/states/PlayState.hx"
click node_ui_states "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states"
click node_substates "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states/substates"
click node_hud "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/game/huds"
click node_notesystem "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/objects/note"
click node_timing "https://github.com/nmvteam/nightmarevision/blob/dev/source/funkin/backend/Conductor.hx"
click node_content_data "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/data"
click node_assets_game "https://github.com/nmvteam/nightmarevision/tree/dev/assets/game"
click node_assets_embeds "https://github.com/nmvteam/nightmarevision/tree/dev/assets/embeds"
click node_assets_excluded "https://github.com/nmvteam/nightmarevision/tree/dev/assets/excluded"
click node_scripting_modding "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/scripting"
click node_modchart "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/game/modchart"
click node_editor_states "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states/editors"
click node_editor_ui "https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states/editors/ui"

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_source_main,node_source_init,node_source_splash,node_funkin_game,node_backend_services,node_platform_ext toneBlue
class node_state_flow,node_play_state,node_ui_states,node_substates,node_hud,node_notesystem,node_timing toneAmber
class node_content_data,node_assets_game,node_assets_embeds,node_assets_excluded toneMint
class node_scripting_modding,node_modchart toneRose
class node_editor_states,node_editor_ui toneIndigo
```

## Components

### Bootstrap & runtime

Entry points, engine bootstrap, and platform/runtime integration.

- [Main](https://github.com/nmvteam/nightmarevision/blob/dev/source/Main.hx): entrypoint · Application entry that starts the Haxe runtime. · `source/Main.hx`
- [Init](https://github.com/nmvteam/nightmarevision/blob/dev/source/Init.hx): bootstrap · Early initialization and startup wiring. · `source/Init.hx`
- [Splash](https://github.com/nmvteam/nightmarevision/blob/dev/source/Splash.hx): bootstrap · Splash/loading state before the main game framework. · `source/Splash.hx`
- [FunkinGame](https://github.com/nmvteam/nightmarevision/blob/dev/source/funkin/backend/FunkinGame.hx): engine core · Main game object coordinating boot, scaling, input, logging, and transitions. · `source/funkin/backend/FunkinGame.hx`
- [Backend core](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/backend): runtime services · Conductor, controls, crash handling, cache, input, logging, and transition support. · `source/funkin/backend`
- [Platform plugins](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/backend/plugins): platform hooks · Discord, fullscreen, hot reload, camera/sound/UI extensions, and target-specific fixes. · `source/funkin/backend/plugins`

### Gameplay engine

Core state machine, gameplay loop, HUD, and note systems.

- [State flow](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states): state machine · Top-level menu and gameplay navigation states. · `source/funkin/states`
- [PlayState](https://github.com/nmvteam/nightmarevision/blob/dev/source/funkin/states/PlayState.hx): gameplay state · Primary real-time song and chart gameplay loop. · `source/funkin/states/PlayState.hx`
- [Menu states](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states): ui states · Title, main menu, story, freeplay, mods, options, and credits screens. · `source/funkin/states`
- [Substates](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states/substates): overlay states · Pause, game over, prompts, reset score, and gameplay changer overlays. · `source/funkin/states/substates`
- [HUD](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/game/huds): render overlay · Gameplay heads-up display and score/rating presentation. · `source/funkin/game/huds`
- [Note system](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/objects/note): playfield · Notes, strums, sustains, splashes, and playfield behavior. · `source/funkin/objects/note`
- [Conductor](https://github.com/nmvteam/nightmarevision/blob/dev/source/funkin/backend/Conductor.hx): timing sync · Song timing, beat/step synchronization, and gameplay clocking. · `source/funkin/backend/Conductor.hx`

### Data & assets

Externalized game content and asset partitions.

- [Game data](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/data): data models · Character, song, chart, stage, week, skin, prefs, and metadata models. · `source/funkin/data`
- [Game assets](https://github.com/nmvteam/nightmarevision/tree/dev/assets/game): runtime content · Primary shipped content: characters, stages, songs, UI sprites, music, and sounds. · `assets/game`
- [Embedded assets](https://github.com/nmvteam/nightmarevision/tree/dev/assets/embeds): bundled media · Packaged media included at build time. · `assets/embeds`
- [Excluded assets](https://github.com/nmvteam/nightmarevision/tree/dev/assets/excluded): editor content · Editor-only or non-shipped resources separated from runtime content. · `assets/excluded`

### Scripting & modding

Script execution, modifiers, and extension boundaries.

- [Scripting layer](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/scripting): extensibility · Scripted states, substates, plugin management, and script runtime helpers. · `source/funkin/scripting`
- [Modchart](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/game/modchart): chart effects · Note modifiers, event timelines, and chart-driven transformations. · `source/funkin/game/modchart`

### Editors

Built-in authoring tools and shared editor UI.

- [Editors](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states/editors): authoring tools · Chart, character, week, metadata, and noteskin editors. · `source/funkin/states/editors`
- [Editor UI](https://github.com/nmvteam/nightmarevision/tree/dev/source/funkin/states/editors/ui): ui kits · Shared editor widgets and toolkits. · `source/funkin/states/editors/ui`

## Connections

- Main → Init: boots · Entry hands off to initialization.
- Init → Splash: loads · Startup flow continues through splash/loading.
- Splash → FunkinGame: starts · Splash transitions into the main engine object.
- FunkinGame → Backend core: uses · Game object relies on backend services for runtime coordination.
- Backend core → Conductor: syncs · Backend timing drives beat/step logic.
- Backend core → Platform plugins: extends · Runtime plugins add platform and UX integrations.
- FunkinGame → State flow: drives · Core game object owns the active state machine.
- State flow → Menu states: navigates · Menu/state navigation covers title and selection screens.
- State flow → PlayState: enters · Gameplay state is the main destination from menus.
- State flow → Substates: overlays · Transient overlays branch off the primary state flow.
- PlayState → Note system: renders · Play state instantiates and updates playfield notes.
- PlayState → HUD: shows · Gameplay overlays are rendered through the HUD layer.
- PlayState → Conductor: consumes · Play state uses song timing and synchronization.
- PlayState → Game data: loads · Gameplay content is resolved from data models.
- Game data → Game assets: maps to · Runtime data points to disk-backed game content.
- Game data → Embedded assets: bundles · Some content ships as embedded media.
- Editors → Game data: edits · Editors author the same underlying game data models.
- Editors → Editor UI: shares · Editor screens reuse common UI toolkits.
- Editors → Excluded assets: uses · Editor-only resources are kept separate from shipped assets.
- Scripting layer → PlayState: augments · Scripts can alter runtime behavior and states.
- Scripting layer → Substates: injects · Scripted substates and overlays hook into the state machine.
- Scripting layer → Modchart: configures · Modding layer powers chart modifiers and event timelines.
- Modchart → Note system: affects · Modifiers reshape note and receptor behavior.
- Game assets → Game data: contains · Game content directories store the authoritative runtime files.
- Embedded assets → Backend core: supplies · Bundled media and sounds support startup and UI/runtime feedback.
