# toft08/make-game architecture

> Architecture diagram of the GitHub repository toft08/make-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/toft08/make-game
- Repository: https://github.com/toft08/make-game

## Overview

##### Project type and purpose
- This is a single‐page, browser‐based game built entirely with plain JavaScript, DOM APIs, HTML and CSS.
- Purpose: Implement a smooth 60 FPS, Tetris‐style game engine from scratch for learning performance optimization and core JS/DOM rendering.

##### File structure
- Top‐level assets:
- index.html – the container/page
- style.css – layout & visuals
- images/ – static assets (controls.jpg, favicon.ico)
- Core JS modules (each a separate component):
- game.js – bootstraps the loop and overall game state
- board.js – grid management, collision detection, row clearing
- tetrominos.js – piece definitions & rotation logic
- controls.js – keyboard input handler
- ui.js – DOM updates for score, timer, pause menu
- utils.js – helper functions (e.g., random, timing)

##### README for insights
- Rendering driven by requestAnimationFrame
- Goal is minimal layout thrashing; efficient DOM updates
- Features: pause menu, scoreboard, keyboard controls

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Static Assets"
        HTML["index.html"]:::util
        CSS["style.css"]:::util
        IMG["assets/images/"]:::util
    end

    subgraph "Browser Runtime"
        Browser["Browser (Event Loop & DOM API)"]:::util
    end

    subgraph "JavaScript Modules"
        subgraph "Input Module"
            Controls["Controls Module"]:::input
        end
        subgraph "Game Engine"
            Engine["Game Engine (game.js)"]:::engine
        end
        subgraph "Game Logic"
            Board["Board Logic (board.js)"]:::logic
            Tetrominos["Tetromino Logic (tetrominos.js)"]:::logic
        end
        subgraph "Rendering Module"
            UI["UI Renderer (ui.js)"]:::render
        end
        subgraph "Utilities"
            Utils["Utility Library (utils.js)"]:::util
        end
    end

    HTML --> Browser
    CSS --> Browser
    IMG --> Browser
    Browser -->|"loads modules"| Engine
    Browser -->|"keydown event"| Controls
    Controls -->|"move command"| Engine
    Engine -->|"update state"| Board
    Engine -->|"piece logic"| Tetrominos
    Board -->|"grid state"| Engine
    Tetrominos -->|"piece data"| Engine
    Engine -->|"requestAnimationFrame"| UI
    UI -->|"DOM updates"| Browser

    Utils --> Engine
    Utils --> Controls
    Utils --> Board
    Utils --> Tetrominos
    Utils --> UI

    click HTML "https://github.com/toft08/make-game/blob/main/index.html"
    click CSS "https://github.com/toft08/make-game/blob/main/style.css"
    click IMG "https://github.com/toft08/make-game/tree/main/images/"
    click Engine "https://github.com/toft08/make-game/blob/main/game.js"
    click Controls "https://github.com/toft08/make-game/blob/main/controls.js"
    click Board "https://github.com/toft08/make-game/blob/main/board.js"
    click Tetrominos "https://github.com/toft08/make-game/blob/main/tetrominos.js"
    click UI "https://github.com/toft08/make-game/blob/main/ui.js"
    click Utils "https://github.com/toft08/make-game/blob/main/utils.js"

    classDef input fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#333,stroke-width:1px
    classDef render fill:#FFA500,stroke:#333,stroke-width:1px
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef engine fill:#DA70D6,stroke:#333,stroke-width:1px
```
