# zadnap/odin-battleship architecture

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

- Interactive diagram: https://gitdiagram.com/zadnap/odin-battleship
- Repository: https://github.com/zadnap/odin-battleship

## Overview

Odin Battleship is a browser-based human-versus-computer Battleship game. The player enters a name, starts a match, arranges ships, and selects opponent-grid cells; the DOM controller coordinates turns and game messages while the game controller and domain models resolve attacks and victory. Rendering builds the two boards, grids, and ship status displays, and a separate control toggles background music. The graph follows the sampled imports and calls; some start-screen and rendering details are connected using SOURCE INDEX references rather than inspected implementation excerpts.

Main entry points: [`src/controllers/domController.js`](https://github.com/zadnap/odin-battleship/blob/main/src/controllers/domController.js) (DOM controller), [`src/controllers/gameController.js`](https://github.com/zadnap/odin-battleship/blob/main/src/controllers/gameController.js) (Game controller), [`src/index.js`](https://github.com/zadnap/odin-battleship/blob/main/src/index.js) (App entry), [`src/components/gameboard/board.js`](https://github.com/zadnap/odin-battleship/blob/main/src/components/gameboard/board.js) (Player board view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Game interface"]
  node_start["Start screen<br/>[startScreen.js]"]
  node_form["Player start form<br/>[startForm.js]"]
  node_loading["Loading view<br/>[loading.js]"]
  node_host["Game operator<br/>[gameHost.js]"]
  node_boardview["Gameboard view<br/>[gameboard.js]"]
  node_board["Player board view<br/>[board.js]"]
  node_grid["Grid view<br/>[grid.js]"]
  node_cell["Grid cell<br/>[cell.js]"]
  node_shipyard["Ship status list<br/>[shipyard.js]"]
  node_shipinfo["Ship status item<br/>[shipInfo.js]"]
  node_title["Board title<br/>[title.js]"]
end

subgraph group_flow["Match orchestration"]
  node_entry["App entry<br/>[index.js]"]
  node_dom["DOM controller<br/>[domController.js]"]
  node_game["Game controller<br/>[gameController.js]"]
end

subgraph group_domain["Game domain"]
  node_playermodel["Player model<br/>[player.js]"]
  node_gameboard["Gameboard model<br/>[gameboard.js]"]
  node_ship["Ship model<br/>[ship.js]"]
end

subgraph group_audio["Audio"]
  node_music["Music toggle<br/>[musicButton.js]"]
  node_track["Background track"]
end

node_player(("Player"))

node_player -->|"enters name"| node_start
node_entry -->|"creates"| node_game
node_entry -->|"creates"| node_dom
node_entry -->|"renders start"| node_dom
node_entry -->|"renders music"| node_dom
node_dom -->|"renders"| node_start
node_start -->|"includes"| node_form
node_start -->|"uses"| node_loading
node_form -->|"adds players"| node_game
node_form -->|"opens match"| node_dom
node_dom -->|"renders messages"| node_host
node_dom -->|"renders boards"| node_boardview
node_dom -->|"starts and plays"| node_game
node_game -->|"creates players"| node_playermodel
node_game -->|"resolves attacks"| node_gameboard
node_boardview -->|"renders"| node_board
node_board -->|"renders"| node_grid
node_board -->|"renders"| node_shipyard
node_board -->|"renders"| node_title
node_grid -->|"creates cells"| node_cell
node_shipyard -->|"creates items"| node_shipinfo
node_playermodel -->|"owns board"| node_gameboard
node_gameboard -->|"creates ships"| node_ship
node_music -->|"loads audio"| node_track

click node_entry "https://github.com/zadnap/odin-battleship/blob/main/src/index.js"
click node_dom "https://github.com/zadnap/odin-battleship/blob/main/src/controllers/domController.js"
click node_game "https://github.com/zadnap/odin-battleship/blob/main/src/controllers/gameController.js"
click node_start "https://github.com/zadnap/odin-battleship/blob/main/src/components/startScreen/startScreen.js"
click node_form "https://github.com/zadnap/odin-battleship/blob/main/src/components/startScreen/startForm.js"
click node_loading "https://github.com/zadnap/odin-battleship/blob/main/src/components/startScreen/loading.js"
click node_host "https://github.com/zadnap/odin-battleship/blob/main/src/components/gameHost/gameHost.js"
click node_boardview "https://github.com/zadnap/odin-battleship/blob/main/src/components/gameboard/gameboard.js"
click node_board "https://github.com/zadnap/odin-battleship/blob/main/src/components/gameboard/board.js"
click node_grid "https://github.com/zadnap/odin-battleship/blob/main/src/components/grid/grid.js"
click node_cell "https://github.com/zadnap/odin-battleship/blob/main/src/components/grid/cell.js"
click node_shipyard "https://github.com/zadnap/odin-battleship/blob/main/src/components/shipyard/shipyard.js"
click node_shipinfo "https://github.com/zadnap/odin-battleship/blob/main/src/components/shipInfo/shipInfo.js"
click node_title "https://github.com/zadnap/odin-battleship/blob/main/src/components/gameboard/title.js"
click node_playermodel "https://github.com/zadnap/odin-battleship/blob/main/src/models/player.js"
click node_gameboard "https://github.com/zadnap/odin-battleship/blob/main/src/models/gameboard.js"
click node_ship "https://github.com/zadnap/odin-battleship/blob/main/src/models/ship.js"
click node_music "https://github.com/zadnap/odin-battleship/blob/main/src/components/musicButton/musicButton.js"
click node_track "https://github.com/zadnap/odin-battleship/blob/main/src/assets/audio/background-music.mp3"

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_start,node_form,node_loading,node_host,node_boardview,node_board,node_grid,node_cell,node_shipyard,node_shipinfo,node_title toneBlue
class node_entry,node_dom,node_game toneAmber
class node_playermodel,node_gameboard,node_ship toneMint
class node_music,node_track toneRose
class node_player toneIndigo
```

## Components

### Game interface

- [Start screen](https://github.com/zadnap/odin-battleship/blob/main/src/components/startScreen/startScreen.js): `src/components/startScreen/startScreen.js`
- [Player start form](https://github.com/zadnap/odin-battleship/blob/main/src/components/startScreen/startForm.js): `src/components/startScreen/startForm.js`
- [Loading view](https://github.com/zadnap/odin-battleship/blob/main/src/components/startScreen/loading.js): `src/components/startScreen/loading.js`
- [Game operator](https://github.com/zadnap/odin-battleship/blob/main/src/components/gameHost/gameHost.js): `src/components/gameHost/gameHost.js`
- [Gameboard view](https://github.com/zadnap/odin-battleship/blob/main/src/components/gameboard/gameboard.js): `src/components/gameboard/gameboard.js`
- [Player board view](https://github.com/zadnap/odin-battleship/blob/main/src/components/gameboard/board.js): `src/components/gameboard/board.js`
- [Grid view](https://github.com/zadnap/odin-battleship/blob/main/src/components/grid/grid.js): `src/components/grid/grid.js`
- [Grid cell](https://github.com/zadnap/odin-battleship/blob/main/src/components/grid/cell.js): `src/components/grid/cell.js`
- [Ship status list](https://github.com/zadnap/odin-battleship/blob/main/src/components/shipyard/shipyard.js): `src/components/shipyard/shipyard.js`
- [Ship status item](https://github.com/zadnap/odin-battleship/blob/main/src/components/shipInfo/shipInfo.js): `src/components/shipInfo/shipInfo.js`
- [Board title](https://github.com/zadnap/odin-battleship/blob/main/src/components/gameboard/title.js): `src/components/gameboard/title.js`

### Match orchestration

- [App entry](https://github.com/zadnap/odin-battleship/blob/main/src/index.js): `src/index.js`
- [DOM controller](https://github.com/zadnap/odin-battleship/blob/main/src/controllers/domController.js): `src/controllers/domController.js`
- [Game controller](https://github.com/zadnap/odin-battleship/blob/main/src/controllers/gameController.js): `src/controllers/gameController.js`

### Game domain

- [Player model](https://github.com/zadnap/odin-battleship/blob/main/src/models/player.js): `src/models/player.js`
- [Gameboard model](https://github.com/zadnap/odin-battleship/blob/main/src/models/gameboard.js): `src/models/gameboard.js`
- [Ship model](https://github.com/zadnap/odin-battleship/blob/main/src/models/ship.js): `src/models/ship.js`

### Audio

- [Music toggle](https://github.com/zadnap/odin-battleship/blob/main/src/components/musicButton/musicButton.js): `src/components/musicButton/musicButton.js`
- [Background track](https://github.com/zadnap/odin-battleship/blob/main/src/assets/audio/background-music.mp3): `src/assets/audio/background-music.mp3`

### Other components

- **Player**

## Connections

- Player → Start screen: enters name
- App entry → Game controller: creates (evidence: `src/index.js`)
- App entry → DOM controller: creates (evidence: `src/index.js`)
- App entry → DOM controller: renders start (evidence: `src/index.js`)
- App entry → DOM controller: renders music (evidence: `src/index.js`)
- DOM controller → Start screen: renders (evidence: `src/controllers/domController.js`)
- Start screen → Player start form: includes (evidence: `src/components/startScreen/startScreen.js`)
- Start screen → Loading view: uses (evidence: `src/components/startScreen/startScreen.js`)
- Player start form → Game controller: adds players (evidence: `src/components/startScreen/startForm.js`)
- Player start form → DOM controller: opens match (evidence: `src/components/startScreen/startForm.js`)
- DOM controller → Game operator: renders messages (evidence: `src/controllers/domController.js`)
- DOM controller → Gameboard view: renders boards (evidence: `src/controllers/domController.js`)
- DOM controller → Game controller: starts and plays (evidence: `src/controllers/domController.js`)
- Game controller → Player model: creates players (evidence: `src/controllers/gameController.js`)
- Game controller → Gameboard model: resolves attacks (evidence: `src/controllers/gameController.js`)
- Gameboard view → Player board view: renders (evidence: `src/components/gameboard/gameboard.js`)
- Player board view → Grid view: renders (evidence: `src/components/gameboard/board.js`)
- Player board view → Ship status list: renders (evidence: `src/components/gameboard/board.js`)
- Player board view → Board title: renders (evidence: `src/components/gameboard/board.js`)
- Grid view → Grid cell: creates cells (evidence: `src/components/grid/grid.js`)
- Ship status list → Ship status item: creates items (evidence: `src/components/shipyard/shipyard.js`)
- Player model → Gameboard model: owns board (evidence: `src/models/player.js`)
- Gameboard model → Ship model: creates ships (evidence: `src/models/gameboard.js`)
- Music toggle → Background track: loads audio (evidence: `src/components/musicButton/musicButton.js`)
