# luishuaranga/tetrisweb architecture

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

- Interactive diagram: https://gitdiagram.com/luishuaranga/tetrisweb
- Repository: https://github.com/luishuaranga/tetrisweb

## Overview

##### Project type and purpose
- This is a front-end only, single-page web application that implements a Tetris game.
- No server-side code or build tools—static files served directly to the browser.

##### File structure
Top-level items:
- index.html        → entry point of the web app
- css/styles.css    → styling for the game UI
- assets/images     → sprites or background images
- js/               → JavaScript modules that implement game logic and controls

Inside js/:
- index.js          → bootstraps the game: loads modules, initializes canvas or DOM elements, starts the game loop
- tetris.js         → core game loop, state management, collision detection and scoring
- bloque.js         → definition of a single “block” unit of a piece, drawing routines
- figura.js         → piece (tetromino) assembly, rotation logic
- controles.js      → input handling: key events, move/rotate/drop commands

No README content means no hidden services or external dependencies beyond standard web APIs.

##### README for additional insights
- README is empty. All architectural cues come from the file names and structure.

- Browser (Client runtime environment)
- Static web server (could be just a file host or CDN)
- index.html + css/styles.css + assets/images (UI layer)
- JavaScript modules (Game Logic Layer)

b. Relationships and interactions:
- Browser requests HTML/CSS/JS/Images from the static server
- index.html loads styles.css and all JS modules
- index.js orchestrates module initialization
- tetris.js interacts with bloque.js, figura.js, figuras-constantes.js, colores.js at runtime to update game state and render
- controles.js listens for keyboard events in the browser, routes commands to tetris.js

c. Architectural patterns / design principles
- Modular client-side architecture—separate JS modules by responsibility (rendering, input, state)
- Single-page application: no page reloads, uses a game loop for UI updates
- Clear separation of static assets (UI styles & images) vs. dynamic code (game logic)

d. Key technologies / libraries
- Vanilla JavaScript ES6 modules
- HTML5 canvas or DOM manipulation for rendering (depending on implementation in index.html)
- CSS for layout and styling
- Browser Web APIs (KeyboardEvent, requestAnimationFrame)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Static Server"
        Server["Static File Server"]    
    end

    subgraph "Browser (Client Runtime)"
        Browser["Browser"]    
    end

    Server -->|"GET index.html, styles.css, *.js, images"| Browser

    subgraph "Presentation Layer"
        HTML["index.html"]:::static
        CSS["styles.css"]:::static
        Images["assets/images"]:::static
        Canvas["Canvas Element"]:::static
    end

    Browser --> HTML
    Browser --> CSS
    Browser --> Images
    HTML --> Canvas

    subgraph "Game Logic Layer"
        Bootstrap["js/index.js\n(Bootstrap & Init)"]:::bootstrap
        Core["js/tetris.js\n(Core Engine)"]:::logic
        Input["js/controles.js\n(Input Handling)"]:::input
        Block["js/bloque.js\n(Block Definition & Draw)"]:::logic
        Piece["js/figura.js\n(Piece Assembly & Rotation)"]:::logic
        Shapes["js/figuras-constantes.js\n(Shapes & Color Maps)"]:::logic
        Colors["js/colores.js\n(Color Utilities)"]:::logic
    end

    HTML -->|"import & execute"| Bootstrap
    Bootstrap --> Core
    Bootstrap --> Input
    Core --> Block
    Core --> Piece
    Piece --> Shapes
    Core --> Colors
    Input --> Core
    Core --> Canvas
    Core -->|"requestAnimationFrame"| Core

    subgraph Legend
        A["Static Assets"]:::static
        B["Bootstrap Module"]:::bootstrap
        C["Core Logic Modules"]:::logic
        D["Input Module"]:::input
    end

    classDef static fill:#add8e6,stroke:#333;
    classDef logic fill:#90ee90,stroke:#333;
    classDef input fill:#ffa07a,stroke:#333;
    classDef bootstrap fill:#dda0dd,stroke:#333;

    click HTML "https://github.com/luishuaranga/tetrisweb/blob/main/index.html"
    click CSS "https://github.com/luishuaranga/tetrisweb/blob/main/css/styles.css"
    click Images "https://github.com/luishuaranga/tetrisweb/tree/main/assets/images"
    click Bootstrap "https://github.com/luishuaranga/tetrisweb/blob/main/js/index.js"
    click Core "https://github.com/luishuaranga/tetrisweb/blob/main/js/tetris.js"
    click Input "https://github.com/luishuaranga/tetrisweb/blob/main/js/controles.js"
    click Block "https://github.com/luishuaranga/tetrisweb/blob/main/js/bloque.js"
    click Piece "https://github.com/luishuaranga/tetrisweb/blob/main/js/figura.js"
    click Shapes "https://github.com/luishuaranga/tetrisweb/blob/main/js/figuras-constantes.js"
    click Colors "https://github.com/luishuaranga/tetrisweb/blob/main/js/colores.js"
```
