# revanthmamidala/fantastic-octo-happiness architecture

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

- Interactive diagram: https://gitdiagram.com/revanthmamidala/fantastic-octo-happiness
- Repository: https://github.com/revanthmamidala/fantastic-octo-happiness

## Overview

This repository contains a browser-based, coding-error-themed block puzzle. The player uses keyboard controls to move, rotate, drop, and pause pieces; the game locks pieces onto a board, checks for a target pattern, updates the score and target on a match, and ends when a new piece collides at spawn. The sampled source shows these mechanics and pattern definitions, but not the HTML structure or script-loading configuration, so their wiring is not represented.

Main entry points: [`src/index.js`](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js) (Piece Movement), [`src/patterns.js`](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/patterns.js) (Error Pattern Catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Game Play"]
  node_controls["Keyboard Controls<br/>[index.js]"]
  node_game_loop["Game Loop<br/>[index.js]"]
  node_piece_movement["Piece Movement<br/>[index.js]"]
  node_collision["Collision Checks<br/>[index.js]"]
  node_piece_lock["Piece Locking<br/>[index.js]"]
  node_piece_spawn["Piece Spawning<br/>[index.js]"]
  node_game_state["Board And Score State<br/>[index.js]"]
end

subgraph group_patterns["Pattern Matching"]
  node_pattern_catalog["Error Pattern Catalog<br/>[patterns.js]"]
  node_target_pattern["Target Pattern<br/>[index.js]"]
  node_pattern_check["Pattern Matching<br/>[index.js]"]
  node_pattern_clear["Board Clearing<br/>[index.js]"]
  node_score_update["Score Update<br/>[index.js]"]
end

subgraph group_display["Rendering And Status"]
  node_canvas_render["Canvas Rendering<br/>[index.js]"]
  node_status_display["Status Display<br/>[index.js]"]
end

node_player(("Player"))

node_player -->|"presses keys"| node_controls
node_controls -->|"dispatches moves"| node_piece_movement
node_controls -->|"toggles pause"| node_game_loop
node_game_loop -->|"drops piece"| node_piece_movement
node_piece_movement -->|"checks position"| node_collision
node_piece_movement -->|"locks on impact"| node_piece_lock
node_piece_lock -->|"writes blocks"| node_game_state
node_piece_movement -->|"checks after lock"| node_pattern_check
node_piece_movement -->|"spawns next"| node_piece_spawn
node_piece_spawn -->|"checks spawn"| node_collision
node_collision -->|"ends game"| node_status_display
node_pattern_check -->|"matches target"| node_target_pattern
node_target_pattern -->|"selects pattern"| node_pattern_catalog
node_pattern_check -->|"clears on match"| node_pattern_clear
node_pattern_check -->|"adds points"| node_score_update
node_score_update -->|"chooses next"| node_target_pattern
node_game_loop -->|"draws frame"| node_canvas_render
node_target_pattern -->|"draws target"| node_canvas_render
node_score_update -->|"updates score"| node_status_display

click node_controls "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_game_loop "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_piece_movement "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_collision "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_piece_lock "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_piece_spawn "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_game_state "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_pattern_catalog "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/patterns.js"
click node_target_pattern "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_pattern_check "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_pattern_clear "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_score_update "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_canvas_render "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js"
click node_status_display "https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.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_controls,node_game_loop,node_piece_movement,node_collision,node_piece_lock,node_piece_spawn,node_game_state toneBlue
class node_pattern_catalog,node_target_pattern,node_pattern_check,node_pattern_clear,node_score_update toneAmber
class node_canvas_render,node_status_display toneMint
class node_player toneIndigo
```

## Components

### Game Play

- [Keyboard Controls](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Game Loop](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Piece Movement](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Collision Checks](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Piece Locking](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Piece Spawning](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Board And Score State](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`

### Pattern Matching

- [Error Pattern Catalog](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/patterns.js): `src/patterns.js`
- [Target Pattern](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Pattern Matching](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Board Clearing](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Score Update](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`

### Rendering And Status

- [Canvas Rendering](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`
- [Status Display](https://github.com/revanthmamidala/fantastic-octo-happiness/blob/main/src/index.js): `src/index.js`

### Other components

- **Player**

## Connections

- Player → Keyboard Controls: presses keys (evidence: `src/index.js`)
- Keyboard Controls → Piece Movement: dispatches moves (evidence: `src/index.js`)
- Keyboard Controls → Game Loop: toggles pause (evidence: `src/index.js`)
- Game Loop → Piece Movement: drops piece (evidence: `src/index.js`)
- Piece Movement → Collision Checks: checks position (evidence: `src/index.js`)
- Piece Movement → Piece Locking: locks on impact (evidence: `src/index.js`)
- Piece Locking → Board And Score State: writes blocks (evidence: `src/index.js`)
- Piece Movement → Pattern Matching: checks after lock (evidence: `src/index.js`)
- Piece Movement → Piece Spawning: spawns next (evidence: `src/index.js`)
- Piece Spawning → Collision Checks: checks spawn (evidence: `src/index.js`)
- Collision Checks → Status Display: ends game (evidence: `src/index.js`)
- Pattern Matching → Target Pattern: matches target (evidence: `src/index.js`)
- Target Pattern → Error Pattern Catalog: selects pattern (evidence: `src/index.js`)
- Pattern Matching → Board Clearing: clears on match (evidence: `src/index.js`)
- Pattern Matching → Score Update: adds points (evidence: `src/index.js`)
- Score Update → Target Pattern: chooses next (evidence: `src/index.js`)
- Game Loop → Canvas Rendering: draws frame (evidence: `src/index.js`)
- Target Pattern → Canvas Rendering: draws target (evidence: `src/index.js`)
- Score Update → Status Display: updates score (evidence: `src/index.js`)
