# mattsurabian/duckhunt-js architecture

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

- Interactive diagram: https://gitdiagram.com/mattsurabian/duckhunt-js
- Repository: https://github.com/mattsurabian/duckhunt-js

## Overview

Duck Hunt JS is a browser-based arcade game. A player starts the game in the browser; Game loads Pixi assets, coordinates levels and input, and delegates scene behavior to Stage, which manages ducks, dog animations, and the HUD. Game also owns scoring, wave progression, and win/loss outcomes. The README documents Canvas/WebGL rendering, sprite-based animation and tweening, and Howler audio; the graph includes these runtime capabilities. Source evidence is sampled, so links to unsampled level data and optional rendering details are limited to documented relationships.

Main entry points: [`src/modules/Game.js`](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Game.js) (Game controller), [`src/modules/Stage.js`](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Stage.js) (Game stage), [`src/modules/Sound.js`](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Sound.js) (Sound playback), [`src/modules/Duck.js`](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Duck.js) (Duck flight and hit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Game flow"]
  node_game["Game controller<br/>[Game.js]"]
  node_levels["Level definitions<br/>[levels.json]"]
  node_levelcreator["Level creator parsing<br/>[levelCreator.js]"]
end

subgraph group_scene["Scene and actors"]
  node_stage["Game stage<br/>[Stage.js]"]
  node_duck["Duck flight and hit<br/>[Duck.js]"]
  node_dog["Dog animations<br/>[Dog.js]"]
  node_character["Character animation base<br/>[Character.js]"]
end

subgraph group_presentation["Presentation"]
  node_hud["HUD display<br/>[Hud.js]"]
  node_sound["Sound playback<br/>[Sound.js]"]
  node_sprites["Sprite assets"]
  node_audio["Audio assets"]
  node_pixi["PixiJS renderer"]
  node_howler["Howler audio"]
end

subgraph group_support["Game support"]
  node_utils["Geometry and fullscreen<br/>[utils.js]"]
end

node_player(("Player"))

node_player -->|"starts"| node_game
node_game -->|"loads assets"| node_pixi
node_game -->|"uses levels"| node_levels
node_game -->|"creates stage"| node_stage
node_game -->|"uses query parser"| node_levelcreator
node_game -->|"updates display"| node_hud
node_game -->|"plays effects"| node_sound
node_game -->|"uses helpers"| node_utils
node_stage -->|"creates ducks"| node_duck
node_stage -->|"creates dog"| node_dog
node_stage -->|"creates HUD"| node_hud
node_stage -->|"uses geometry"| node_utils
node_duck -->|"extends"| node_character
node_dog -->|"extends"| node_character
node_duck -->|"uses geometry"| node_utils
node_duck -->|"plays effects"| node_sound
node_dog -->|"plays effects"| node_sound
node_character -->|"uses sprites"| node_pixi
node_hud -->|"renders display"| node_pixi
node_sound -->|"configures playback"| node_howler
node_game -.->|"loads spritesheet"| node_sprites
node_sound -->|"uses audio data"| node_audio
node_game -.->|"plays audio"| node_audio

click node_game "https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Game.js"
click node_levels "https://github.com/mattsurabian/duckhunt-js/blob/master/src/data/levels.json"
click node_levelcreator "https://github.com/mattsurabian/duckhunt-js/blob/master/src/libs/levelCreator.js"
click node_stage "https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Stage.js"
click node_duck "https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Duck.js"
click node_dog "https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Dog.js"
click node_character "https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Character.js"
click node_hud "https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Hud.js"
click node_sound "https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Sound.js"
click node_sprites "https://github.com/mattsurabian/duckhunt-js/tree/master/src/assets/images"
click node_audio "https://github.com/mattsurabian/duckhunt-js/tree/master/src/assets/sounds"
click node_utils "https://github.com/mattsurabian/duckhunt-js/blob/master/src/libs/utils.js"

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,node_levels,node_levelcreator toneBlue
class node_stage,node_duck,node_dog,node_character toneAmber
class node_hud,node_sound,node_sprites,node_audio,node_pixi,node_howler toneMint
class node_utils toneRose
class node_player toneIndigo
```

## Components

### Game flow

- [Game controller](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Game.js): `src/modules/Game.js`
- [Level definitions](https://github.com/mattsurabian/duckhunt-js/blob/master/src/data/levels.json): `src/data/levels.json`
- [Level creator parsing](https://github.com/mattsurabian/duckhunt-js/blob/master/src/libs/levelCreator.js): `src/libs/levelCreator.js`

### Scene and actors

- [Game stage](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Stage.js): `src/modules/Stage.js`
- [Duck flight and hit](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Duck.js): `src/modules/Duck.js`
- [Dog animations](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Dog.js): `src/modules/Dog.js`
- [Character animation base](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Character.js): `src/modules/Character.js`

### Presentation

- [HUD display](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Hud.js): `src/modules/Hud.js`
- [Sound playback](https://github.com/mattsurabian/duckhunt-js/blob/master/src/modules/Sound.js): `src/modules/Sound.js`
- [Sprite assets](https://github.com/mattsurabian/duckhunt-js/tree/master/src/assets/images): `src/assets/images`
- [Audio assets](https://github.com/mattsurabian/duckhunt-js/tree/master/src/assets/sounds): `src/assets/sounds`
- **PixiJS renderer**
- **Howler audio**

### Game support

- [Geometry and fullscreen](https://github.com/mattsurabian/duckhunt-js/blob/master/src/libs/utils.js): `src/libs/utils.js`

### Other components

- **Player**

## Connections

- Player → Game controller: starts
- Game controller → PixiJS renderer: loads assets (evidence: `src/modules/Game.js`)
- Game controller → Level definitions: uses levels (evidence: `src/modules/Game.js`)
- Game controller → Game stage: creates stage (evidence: `src/modules/Game.js`)
- Game controller → Level creator parsing: uses query parser (evidence: `src/modules/Game.js`)
- Game controller → HUD display: updates display (evidence: `src/modules/Game.js`)
- Game controller → Sound playback: plays effects (evidence: `src/modules/Game.js`)
- Game controller → Geometry and fullscreen: uses helpers (evidence: `src/modules/Game.js`)
- Game stage → Duck flight and hit: creates ducks (evidence: `src/modules/Stage.js`)
- Game stage → Dog animations: creates dog (evidence: `src/modules/Stage.js`)
- Game stage → HUD display: creates HUD (evidence: `src/modules/Stage.js`)
- Game stage → Geometry and fullscreen: uses geometry (evidence: `src/modules/Stage.js`)
- Duck flight and hit → Character animation base: extends (evidence: `src/modules/Duck.js`)
- Dog animations → Character animation base: extends (evidence: `src/modules/Dog.js`)
- Duck flight and hit → Geometry and fullscreen: uses geometry (evidence: `src/modules/Duck.js`)
- Duck flight and hit → Sound playback: plays effects (evidence: `src/modules/Duck.js`)
- Dog animations → Sound playback: plays effects (evidence: `src/modules/Dog.js`)
- Character animation base → PixiJS renderer: uses sprites (evidence: `src/modules/Character.js`)
- HUD display → PixiJS renderer: renders display (evidence: `src/modules/Hud.js`)
- Sound playback → Howler audio: configures playback (evidence: `src/modules/Sound.js`)
- Game controller → Sprite assets: loads spritesheet
- Sound playback → Audio assets: uses audio data (evidence: `src/modules/Sound.js`)
- Game controller → Audio assets: plays audio
