# soumya-ranjan-77/simon-game architecture

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

- Interactive diagram: https://gitdiagram.com/soumya-ranjan-77/simon-game
- Repository: https://github.com/soumya-ranjan-77/simon-game

## Overview

#### Purpose and Entry Points
This is a browser-only Simon memory game. `index.html` provides the game screen and controls, `style.css` defines visual states, and `app.js` owns all game state, input handling, sequence generation, playback, scoring, and restart behavior.

Paths: `index.html`, `app.js`, `style.css`

#### UI and DOM Boundary
The HTML exposes the level/status display and the colored Simon buttons that players click. JavaScript addresses these DOM elements by selector/class, while CSS supplies the button colors and transient visual feedback styles.

Paths: `index.html`, `app.js`, `style.css`

#### Game State Controller
`app.js` is the central controller. It maintains whether a game has started, the current level, the generated game pattern, and the player’s current input sequence. A keyboard event starts or restarts a session; button click events advance player input validation.

Paths: `app.js`

#### Sequence Generation Stage
At each level, the controller selects a random color/button and appends it to the persistent game sequence. The full sequence—not only the newest item—is then replayed so difficulty increases cumulatively.

Paths: `app.js`

#### Playback and Feedback Stage
Generated sequence items are rendered as timed button flashes, with sound/visual effects coordinated through DOM class changes or element interaction. This stage is intentionally separate from player clicking: users observe playback before reproducing it.

Paths: `app.js`, `style.css`, `index.html`

#### Player Input and Validation Flow
Clicking a colored button records the selected color into the current user pattern. The controller compares each click against the corresponding index in the generated pattern. A correct full sequence advances the level; a mismatch enters game-over handling.

Paths: `app.js`

#### Failure, Score, and Restart Flow
On an incorrect input, the game presents a failure state, preserves or updates high-score-related display behavior, and resets active sequence state so another key press can begin a new run. Restart is local in-memory browser state; no persistence layer or backend is indicated.

Paths: `app.js`, `index.html`, `style.css`

#### Runtime and Infrastructure
The application runs directly in a standard web browser using HTML, CSS, and client-side JavaScript. There are no server entry points, build pipeline files, databases, APIs, authentication systems, or external infrastructure shown in the repository.

Paths: `index.html`, `app.js`, `style.css`

Main entry points: [`app.js`](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js) (Input Validation), [`index.html`](https://github.com/soumya-ranjan-77/simon-game/blob/main/index.html) (Game Screen & Controls), [`style.css`](https://github.com/soumya-ranjan-77/simon-game/blob/main/style.css) (Visual States)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser Runtime"]
  node_html["Game Screen &amp; Controls<br/>HTML document<br/>[index.html]"]
  node_css["Visual States<br/>stylesheet<br/>[style.css]"]
end

subgraph group_game["Game Controller"]
  node_controller["Game Controller<br/>client-side JavaScript<br/>[app.js]"]
  node_start(("Start / Restart Input<br/>keyboard event<br/>[app.js]"))
  node_state["Session State<br/>in-memory state<br/>[app.js]"]
  node_generate["Sequence Generation<br/>game stage<br/>[app.js]"]
  node_playback["Sequence Playback<br/>timed feedback<br/>[app.js]"]
  node_clicks(("Player Button Input<br/>click event<br/>[app.js]"))
  node_validate["Input Validation<br/>game stage<br/>[app.js]"]
  node_advance["Level Advance<br/>game transition<br/>[app.js]"]
  node_gameover["Failure &amp; Reset<br/>game state<br/>[app.js]"]
end

node_html -->|"DOM controls and display"| node_controller
node_css -->|"styles"| node_html
node_css -->|"flash visuals"| node_playback
node_start -->|"starts session"| node_controller
node_controller -->|"maintains"| node_state
node_controller -->|"begins level"| node_generate
node_generate -->|"appends random item"| node_state
node_generate -->|"replay full pattern"| node_playback
node_playback -->|"updates button feedback"| node_html
node_clicks -->|"selected button"| node_validate
node_validate -->|"checks pattern index"| node_state
node_validate -->|"full sequence correct"| node_advance
node_validate -->|"mismatch"| node_gameover
node_advance -->|"next level"| node_generate
node_gameover -->|"failure and score display"| node_html
node_gameover -->|"resets session"| node_state
node_gameover -.->|"awaits key press"| node_start

click node_html "https://github.com/soumya-ranjan-77/simon-game/blob/main/index.html"
click node_css "https://github.com/soumya-ranjan-77/simon-game/blob/main/style.css"
click node_controller "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js"
click node_start "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js"
click node_state "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js"
click node_generate "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js"
click node_playback "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js"
click node_clicks "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js"
click node_validate "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js"
click node_advance "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js"
click node_gameover "https://github.com/soumya-ranjan-77/simon-game/blob/main/app.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_html,node_css toneBlue
class node_controller,node_start,node_state,node_generate,node_playback,node_clicks,node_validate,node_advance,node_gameover toneAmber
```

## Components

### Browser Runtime

- [Game Screen & Controls](https://github.com/soumya-ranjan-77/simon-game/blob/main/index.html): HTML document · Level display and Simon buttons. · `index.html`
- [Visual States](https://github.com/soumya-ranjan-77/simon-game/blob/main/style.css): stylesheet · Button colors and feedback styles. · `style.css`

### Game Controller

- [Game Controller](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): client-side JavaScript · Owns session state, events, scoring, and restart behavior. · `app.js`
- [Start / Restart Input](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): keyboard event · `app.js`
- [Session State](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): in-memory state · Started flag, level, game pattern, and user pattern. · `app.js`
- [Sequence Generation](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): game stage · Appends one random button to the persistent pattern. · `app.js`
- [Sequence Playback](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): timed feedback · Replays the complete pattern as button flashes. · `app.js`
- [Player Button Input](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): click event · `app.js`
- [Input Validation](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): game stage · Compares each player choice with the generated pattern. · `app.js`
- [Level Advance](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): game transition · Clears player input and starts the next sequence. · `app.js`
- [Failure & Reset](https://github.com/soumya-ranjan-77/simon-game/blob/main/app.js): game state · Shows failure feedback and resets active session state. · `app.js`

## Connections

- Game Screen & Controls → Game Controller: DOM controls and display
- Visual States → Game Screen & Controls: styles
- Visual States → Sequence Playback: flash visuals
- Start / Restart Input → Game Controller: starts session
- Game Controller → Session State: maintains
- Game Controller → Sequence Generation: begins level
- Sequence Generation → Session State: appends random item
- Sequence Generation → Sequence Playback: replay full pattern
- Sequence Playback → Game Screen & Controls: updates button feedback
- Player Button Input → Input Validation: selected button
- Input Validation → Session State: checks pattern index
- Input Validation → Level Advance: full sequence correct
- Input Validation → Failure & Reset: mismatch
- Level Advance → Sequence Generation: next level
- Failure & Reset → Game Screen & Controls: failure and score display
- Failure & Reset → Session State: resets session
- Failure & Reset → Start / Restart Input: awaits key press
